Back to home page

Enduro/X

 
 

    


0001 ##
0002 ## @brief Enduro Execution platform main Make descriptor
0003 ##
0004 ## @file CMakeLists.txt
0005 ##
0006 ## -----------------------------------------------------------------------------
0007 ## Enduro/X Middleware Platform for Distributed Transaction Processing
0008 ## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009 ## Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010 ## This software is released under one of the following licenses:
0011 ## AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012 ## See LICENSE file for full text.
0013 ## -----------------------------------------------------------------------------
0014 ## AGPL license:
0015 ##
0016 ## This program is free software; you can redistribute it and/or modify it under
0017 ## the terms of the GNU Affero General Public License, version 3 as published
0018 ## by the Free Software Foundation;
0019 ##
0020 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023 ## for more details.
0024 ##
0025 ## You should have received a copy of the GNU Affero General Public License along 
0026 ## with this program; if not, write to the Free Software Foundation, Inc.,
0027 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028 ##
0029 ## -----------------------------------------------------------------------------
0030 ## A commercial use license is available from Mavimax, Ltd
0031 ## contact@mavimax.com
0032 ## -----------------------------------------------------------------------------
0033 ##
0034 
0035 cmake_minimum_required (VERSION 3.1) 
0036 project (ENDUROX)
0037 
0038 include(cmake/ex_osver.cmake)
0039 include(cmake/ex_comp.cmake)
0040 
0041 set(VERSION "8.0.8")
0042 set(PROJ_NAME "Enduro/X")
0043 set(RELEASE "1")
0044 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
0045 
0046 string(REPLACE "." ";" VERSION_LIST ${VERSION})
0047 list(GET VERSION_LIST 0 NDRX_VERSION_MAJOR)
0048 list(GET VERSION_LIST 1 NDRX_VERSION_MINOR)
0049 list(GET VERSION_LIST 2 NDRX_VERSION_PATCH)
0050 MATH (EXPR NDRX_VERSION_NUM "${NDRX_VERSION_MAJOR} * 10000 + ${NDRX_VERSION_MINOR} * 100 + ${NDRX_VERSION_PATCH}")
0051 
0052 ################################################################################
0053 # Check versions if defined, export build env
0054 ################################################################################
0055 
0056 if(DEFINED ENV{NDRX_BLD_VERSION})
0057     IF(NOT ENV{NDRX_BLD_VERSION} MATCHES VERSION)
0058         message( FATAL_ERROR "Invalid versions: ENV: [$ENV{NDRX_BLD_VERSION}] Code: [${VERSION}]" )
0059     endif()
0060 endif()
0061 
0062 if(DEFINED ENV{NDRX_BLD_RELEASE})
0063     set(RELEASE $ENV{NDRX_BLD_RELEASE})
0064 endif()
0065 
0066 message("CMake RELEASE  = ${RELEASE}")
0067 
0068 SET (NDRX_BLD_PRODUCT   $ENV{NDRX_BLD_PRODUCT})
0069 SET (NDRX_BLD_SYSTEM    $ENV{NDRX_BLD_SYSTEM})
0070 SET (NDRX_BLD_CONFIG    $ENV{NDRX_BLD_CONFIG})
0071 SET (NDRX_BLD_VERSION   $ENV{NDRX_BLD_VERSION})
0072 SET (NDRX_BLD_RELEASE   $ENV{NDRX_BLD_RELEASE})
0073 SET (NDRX_BLD_TAG       $ENV{NDRX_BLD_TAG})
0074 SET (NDRX_BLD_BRANCH    $ENV{NDRX_BLD_BRANCH})
0075 SET (NDRX_BLD_COMMIT    $ENV{NDRX_BLD_COMMIT})
0076 SET (NDRX_BLD_FLAGS     $ENV{NDRX_BLD_FLAGS})
0077 
0078 
0079 #
0080 # Get the git version (the version which is
0081 #
0082 execute_process(
0083     COMMAND
0084         git rev-parse HEAD
0085     RESULT_VARIABLE
0086         gitres
0087     OUTPUT_VARIABLE
0088         NDRX_BLD_HASH
0089     )
0090 
0091 string(REGEX REPLACE "\n$" "" NDRX_BLD_HASH "${NDRX_BLD_HASH}")
0092 
0093 
0094 if (NOT gitres EQUAL 0)
0095     SET (NDRX_BLD_HASH  "unknown")
0096 endif ()
0097 
0098 ################################################################################
0099 # OS Configuration
0100 ################################################################################
0101 
0102 # configure compiler
0103 ex_comp_settings()
0104 
0105 # Enable oracle test to run
0106 IF (ENABLE_TEST47)
0107     set(NDRX_ENABLE_TEST47 "1")
0108 ENDIF()
0109 
0110 IF(EX_USE_SYSVQ)
0111     set(EX_POLLER_STR   "SystemV")
0112 ELSEIF(EX_USE_FDPOLL)
0113     set(EX_POLLER_STR   "fdpoll")
0114 ELSEIF(EX_USE_EMQ)
0115     set(EX_POLLER_STR   "emq")
0116 ELSEIF(EX_USE_POLL)
0117     set(EX_POLLER_STR   "poll")
0118 ELSEIF(EX_USE_EPOLL)
0119     set(EX_POLLER_STR   "epoll")
0120 ELSEIF(EX_USE_KQUEUE)
0121     set(EX_POLLER_STR   "kqueue")
0122 ELSEIF(EX_USE_SVAPOLL)
0123     set(EX_POLLER_STR   "svapoll")
0124 ELSE()
0125     message( FATAL_ERROR "ERROR! Invalid queue transport backend!" )
0126 ENDIF()
0127 
0128 message("CMake EX_ALIGNMENT_BYTES  = ${EX_ALIGNMENT_BYTES}")
0129 message("Poller  = ${EX_POLLER_STR}")
0130 message("ALIGNMENT_FORCE  = ${EX_ALIGNMENT_FORCE}")
0131 
0132 ################################################################################
0133 # "Configure"
0134 ################################################################################
0135 
0136 # In this file we are doing all of our 'configure' checks. Things like checking
0137 # for headers, functions, libraries, types and size of types.
0138 
0139 # Includes from osver package
0140 ex_osver_include()
0141 
0142 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
0143 INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
0144 INCLUDE (${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake)
0145 INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
0146 INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
0147 INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
0148 
0149 
0150 CHECK_C_SOURCE_COMPILES("int main() {__builtin_expect(1, 1);}" HAVE_EXPECT)
0151 CHECK_CXX_SOURCE_COMPILES("int main() {__builtin_expect(1, 1);}" HAVE_EXPECT_CXX)
0152 CHECK_C_SOURCE_COMPILES("int main() { int X = 0; __sync_bool_compare_and_swap(&X, 0, 1); __sync_synchronize();}" HAVE_SYNC)
0153 CHECK_C_SOURCE_COMPILES("#include <stdio.h> \n int main() {char buf[128]; size_t len; getline(buf, &len, stdin);}" HAVE_GETLINE)
0154 CHECK_C_SOURCE_COMPILES("#include <sys/sem.h> \n int main(int argc, char **argv) {union semun u; return 0;}" EX_HAVE_SEMUN)
0155 
0156 if(CMAKE_OS_NAME STREQUAL "AIX")
0157     # it compiles OK, but we have no header where it is defined
0158     # thus we get lots of warnings
0159     message("No strlcpy/strcat_s/asprintf/__progname test for AIX")
0160     set(HAVE_STRLCPY "0")
0161     set(EX_HAVE_STRCAT_S "0")
0162 else()
0163     CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char dest[1]; char src[1]; strlcpy(dest, src, 1);}" HAVE_STRLCPY)
0164     CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char tmp[8]={0x0}; strcat_s(tmp, sizeof(tmp), \"abc\");}" EX_HAVE_STRCAT_S)
0165     CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char *tmp; asprintf(&tmp, \"HELLO\");}" EX_HAVE_ASPRINTF)
0166     CHECK_C_SOURCE_COMPILES("extern const char * __progname; int main() {return __progname[0];}" HAVE_PROGNAME)
0167 endif()
0168 
0169 CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {strnlen(\"ABC\", 1);}" HAVE_STRNLEN)
0170 CHECK_C_SOURCE_COMPILES("#include <stdatomic.h> \n int main() {int i=0; atomic_fetch_add( &i, 1 );}" EX_HAVE_STDATOMIC)
0171 CHECK_C_SOURCE_COMPILES("int main() {int i=0; __sync_fetch_and_add( &i, 1 );}" EX_HAVE_SYNCFETCHADD)
0172 
0173 # To check for an include file you do this: 
0174 CHECK_INCLUDE_FILE("stdint.h"        HAVE_STDINT_H)
0175 CHECK_INCLUDE_FILE("getopt.h"       HAVE_GETOPT_H)
0176         
0177 
0178 # To check the size of a primitive type:
0179 CHECK_TYPE_SIZE("int"   EX_SIZEOF_INT)
0180 CHECK_TYPE_SIZE("long"  EX_SIZEOF_LONG)
0181 CHECK_TYPE_SIZE("void*"  EX_SIZEOF_VOIDPTR)
0182 
0183 MATH (EXPR EX_PLATFORM_BITS "${EX_SIZEOF_VOIDPTR} * 8")
0184 
0185 IF (DEFINE_DISABLEPSCRIPT)
0186     set(NDRX_DISABLEPSCRIPT "1")
0187 ENDIF()
0188 
0189 IF (DEFINE_SANITIZE)
0190     set(NDRX_SANITIZE "1")
0191 ENDIF()
0192 
0193 IF (MUTEX_DEBUG)
0194     set(NDRX_MUTEX_DEBUG "1")
0195 ENDIF()
0196 
0197 IF (ENABLE_POSTGRES)
0198     set(NDRX_USE_POSTGRES "1")
0199 ENDIF()
0200 
0201 # Output the project version
0202 set(NDRX_VERSION_STR "${PROJ_NAME} ${VERSION}")
0203 
0204 # avoid configure warnings of not being used
0205 # as they are used.
0206 set(ignoreWarning "${DISABLE_ECPG} ${PostgreSQL_TYPE_INCLUDE_DIR}")
0207 ################################################################################
0208 # Install dir config
0209 ################################################################################
0210 get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
0211 
0212 message("LIB: ${LIB64}")
0213 
0214 if(CMAKE_OS_NAME STREQUAL "DARWIN")
0215     set(LIB_SUFFIX "")
0216 # Seems like BSD does not use lib64 folder
0217 elseif (CMAKE_OS_NAME STREQUAL "FREEBSD")
0218     set(LIB_SUFFIX "")
0219 elseif (CMAKE_OS_NAME STREQUAL "AIX")
0220     set(LIB_SUFFIX "")
0221 elseif (LIB64 STREQUAL "TRUE")
0222     set(LIB_SUFFIX 64)
0223 else()
0224     set(LIB_SUFFIX "")
0225 endif()
0226 
0227 message("LIB_SUFFIX: ${LIB_SUFFIX}")
0228 
0229 set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH "Installation directory for libraries")
0230 
0231 message("INSTALL_LIB_DIR: ${INSTALL_LIB_DIR}")
0232 
0233 mark_as_advanced(INSTALL_LIB_DIR) 
0234 MESSAGE( STATUS "INSTALL_LIB_DIR: " ${INSTALL_LIB_DIR} )
0235 
0236 ################################################################################
0237 # Options
0238 ################################################################################
0239 OPTION(DEFINE_DISABLEGPGME "Use GPG-ME encryption (not used, for compatiblity)" OFF)
0240 OPTION(DEFINE_DISABLEPSCRIPT "Disable Platform Script" OFF)
0241 ###############################################################################
0242 
0243 ################################################################################
0244 # Option to disable documentation build (dos are enabled by default)
0245 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" OFF) 
0246 ################################################################################
0247 
0248 ################################################################################
0249 # Submakes
0250 ################################################################################
0251 # Recurse into the project subdirectories. This does not actually
0252 # cause another cmake executable to run. The same process will walk through 
0253 # the project's entire directory structure. 
0254 add_subdirectory (libnstd)
0255 add_subdirectory (embedfile)
0256 add_subdirectory (libcgreen)
0257 add_subdirectory (libubf)
0258 add_subdirectory (libnetproto)
0259 add_subdirectory (mkfldhdr)
0260 # Enduro/X sub-directories for ATMI
0261 add_subdirectory (libatmi) # General Purpose ATMI library
0262 add_subdirectory (libatmisrv) #  ATMI server library 
0263 add_subdirectory (libatmiclt) #  ATMI client library 
0264 add_subdirectory (libtux) #  Tux lib emulation
0265 add_subdirectory (libexnet)
0266 add_subdirectory (libexmemck)
0267 add_subdirectory (libndrxconf)
0268 
0269 IF (NOT DEFINE_DISABLEPSCRIPT)
0270     add_subdirectory (libps) # Platform script
0271     add_subdirectory (libpsstdlib) # Platform script standard library
0272 ENDIF()
0273 
0274 add_subdirectory (tpevsrv)
0275 add_subdirectory (tpcachesv)
0276 add_subdirectory (tpcached)
0277 add_subdirectory (tprecover) # Special recovery server
0278 add_subdirectory (tpbrdcstsv) # tpbroadcast remote machine dispatcher
0279 add_subdirectory (ud)
0280 
0281 
0282 IF (NOT DEFINE_DISABLEPSCRIPT)
0283     add_subdirectory (pscript) # Platform script interpreter
0284 ENDIF()
0285 
0286 add_subdirectory (viewc) # View compiler
0287 add_subdirectory (ndrxd) # Enduro X daemon
0288 add_subdirectory (tpadmsv) # Enduro/X Admin API Server
0289 add_subdirectory (migration) # Migration tools
0290 add_subdirectory (xadmin) # Enduro X command line interface
0291 add_subdirectory (buildtools) # buildserver,buildclient,buildtms
0292 add_subdirectory (lmdb_util) # LMDB/EXDB Admin utilities
0293 add_subdirectory (xmemck) # Enduro X memcory checking tool
0294 add_subdirectory (bridge) # Cluster bridge server
0295 add_subdirectory (tmsrv) # Transaction Manager server for XA transactions
0296 add_subdirectory (tmqueue) # Persistant Queue server
0297 add_subdirectory (cpmsrv) # Client Process Monitor
0298 add_subdirectory (xadrv) # XA Drivers for RMs
0299 add_subdirectory (cconfsrv) # Common-Config server
0300 add_subdirectory (exbench) # Enduro/X benchmark tools
0301 add_subdirectory (plugins) # XA Drivers for RMs
0302 add_subdirectory (enctools) # XA Drivers for RMs
0303 add_subdirectory (libextest) # Shared test resource library
0304 add_subdirectory (ubftest) # UBF library testing
0305 add_subdirectory (atmitest) #  ATMI testing
0306 
0307 IF(DEFINE_DISABLEDOC)
0308         message("Documentation disabled - not building")
0309 ELSE (DEFINE_DISABLEDOC)
0310         add_subdirectory (doc) #  Documentation project.
0311 ENDIF (DEFINE_DISABLEDOC)
0312 
0313 add_subdirectory (include) #  For install
0314 add_subdirectory (scripts) #  For install
0315 add_subdirectory (cmake) #  For install
0316 
0317 #
0318 # Install license files
0319 #
0320 install (FILES
0321     LICENSE
0322     DESTINATION share/endurox)
0323 
0324 #
0325 # Install third party licenses
0326 #
0327 install (FILES
0328     doc/third_party_licences.adoc
0329     DESTINATION share/endurox
0330     RENAME THIRD_PARTY_LICENCES)
0331 
0332 #
0333 # Install stock RM file
0334 #
0335 install (FILES
0336     scripts/RM
0337     DESTINATION udataobj)
0338 
0339 ################################################################################
0340 # uninstall target
0341 ################################################################################
0342 configure_file(
0343     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
0344     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0345     IMMEDIATE @ONLY)
0346 
0347 add_custom_target(uninstall
0348     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
0349 ################################################################################
0350 # Packages
0351 ################################################################################
0352 
0353 # Resolve OS versions...
0354 ex_osver()
0355 
0356 # Support only for Linux
0357 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_NAME = " ${CMAKE_SYSTEM_NAME} )
0358 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
0359 set(CPACK_MONOLITHIC_INSTALL 1)
0360 
0361 #
0362 # Generate configuration 
0363 #
0364 configure_file ("${PROJECT_SOURCE_DIR}/include/ndrx_config.h.in"
0365                 "${PROJECT_BINARY_DIR}/include/ndrx_config.h" )
0366 
0367 # Test the available generators and then configure output
0368 find_program(RPMPROG "rpmbuild")
0369 find_program(APTPROG "dpkg")
0370 
0371 # avoid file /usr/share/man from install of endurox-3.5.1-1.x86_64 conflicts with file from package filesystem-3.2-21.el7.x86_64
0372 # problems...
0373 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man
0374                 /usr/share/man/man3
0375                 /usr/share/man/man5
0376                 /usr/share/man/man8
0377                 /usr/lib64/pkgconfig
0378                 /usr/lib/pkgconfig)
0379 message("Excl: ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
0380 
0381 set(CPACK_GENERATOR "TGZ")
0382 if(RPMPROG)
0383     message("Outputting RPM")
0384     set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
0385 endif()
0386 
0387 if(APTPROG)
0388     message("Outputting DEB")
0389     set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
0390 endif()
0391 
0392 ex_cpuarch()
0393 
0394 
0395 set(CPACK_PACKAGE_CONTACT "contact@mavimax.com")
0396 set(CPACK_PACKAGE_VERSION ${VERSION})
0397 set(CPACK_PACKAGE_VENDOR "Mavimax Ltd")
0398 set(CPACK_RPM_PACKAGE_RELEASE ${RELEASE})
0399 set(CPACK_RPM_PACKAGE_RELEASE_DIST ${RELEASE})
0400 set(CPACK_DEBIAN_PACKAGE_RELEASE ${RELEASE})
0401 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LO)
0402 message("CPack:Debug: PROJECT NAME = ${PROJECT_NAME_LO}")
0403 set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LO}-${VERSION}-${RELEASE}.${LSB_RELEASE_OUTPUT_OS}${LSB_RELEASE_OUTPUT_VER}_${CMAKE_C_COMPILER_ID}_${EX_POLLER_STR}.${EX_CPU_ARCH})
0404 string(TOLOWER ${CPACK_PACKAGE_FILE_NAME}  CPACK_PACKAGE_FILE_NAME)
0405 message("CPack:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
0406 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Enduro/X Middleware Platform")
0407 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION  ${CPACK_PACKAGE_DESCRIPTION})
0408 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0409 set(CPACK_RPM_PACKAGE_AUTOREQ "0")
0410 #set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
0411 
0412 include(CPack)
0413 ################################################################################
0414 # Source indexing for quick symbol lookup
0415 # note that "glimpse" package must be installed.
0416 # to exclude any directory or name from indexing,
0417 # put the name in the glimpse_index/.glimpse_exclude
0418 ################################################################################
0419 
0420 add_custom_target(index glimpseindex -n -H ./glimpse_index ${PROJECT_SOURCE_DIR}
0421                     COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/glimpse_index/glim.cmake)
0422 #this also shall generate the glimp command in the current project
0423 
0424 # vim: set ts=4 sw=4 et smartindent: