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.5)
0036 project (ENDUROX)
0037
0038 include(cmake/ex_osver.cmake)
0039 include(cmake/ex_comp.cmake)
0040
0041 set(VERSION "8.0.12")
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 CHECK_C_SOURCE_COMPILES("#include <fcntl.h> \n int main() {posix_fadvise(0, 0, 0, POSIX_FADV_DONTNEED);}" EX_HAVE_POSIX_FADVISE)
0173
0174 # To check for an include file you do this:
0175 CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
0176 CHECK_INCLUDE_FILE("getopt.h" HAVE_GETOPT_H)
0177
0178
0179 # To check the size of a primitive type:
0180 CHECK_TYPE_SIZE("int" EX_SIZEOF_INT)
0181 CHECK_TYPE_SIZE("long" EX_SIZEOF_LONG)
0182 CHECK_TYPE_SIZE("void*" EX_SIZEOF_VOIDPTR)
0183
0184 MATH (EXPR EX_PLATFORM_BITS "${EX_SIZEOF_VOIDPTR} * 8")
0185
0186 IF (DEFINE_DISABLEPSCRIPT)
0187 set(NDRX_DISABLEPSCRIPT "1")
0188 ENDIF()
0189
0190 IF (DEFINE_SANITIZE)
0191 set(NDRX_SANITIZE "1")
0192 ENDIF()
0193
0194 IF (MUTEX_DEBUG)
0195 set(NDRX_MUTEX_DEBUG "1")
0196 ENDIF()
0197
0198 IF (ENABLE_POSTGRES)
0199 set(NDRX_USE_POSTGRES "1")
0200 ENDIF()
0201
0202 # Output the project version
0203 set(NDRX_VERSION_STR "${PROJ_NAME} ${VERSION}")
0204
0205 # avoid configure warnings of not being used
0206 # as they are used.
0207 set(ignoreWarning "${DISABLE_ECPG} ${PostgreSQL_TYPE_INCLUDE_DIR}")
0208 ################################################################################
0209 # Install dir config
0210 ################################################################################
0211 get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
0212
0213 message("LIB: ${LIB64}")
0214
0215 if(CMAKE_OS_NAME STREQUAL "DARWIN")
0216 set(LIB_SUFFIX "")
0217 # Seems like BSD does not use lib64 folder
0218 elseif (CMAKE_OS_NAME STREQUAL "FREEBSD")
0219 set(LIB_SUFFIX "")
0220 elseif (CMAKE_OS_NAME STREQUAL "AIX")
0221 set(LIB_SUFFIX "")
0222 elseif (LIB64 STREQUAL "TRUE")
0223 set(LIB_SUFFIX 64)
0224 else()
0225 set(LIB_SUFFIX "")
0226 endif()
0227
0228 message("LIB_SUFFIX: ${LIB_SUFFIX}")
0229
0230 set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH "Installation directory for libraries")
0231
0232 message("INSTALL_LIB_DIR: ${INSTALL_LIB_DIR}")
0233
0234 mark_as_advanced(INSTALL_LIB_DIR)
0235 MESSAGE( STATUS "INSTALL_LIB_DIR: " ${INSTALL_LIB_DIR} )
0236
0237 ################################################################################
0238 # Options
0239 ################################################################################
0240 OPTION(DEFINE_DISABLEGPGME "Use GPG-ME encryption (not used, for compatiblity)" OFF)
0241 OPTION(DEFINE_DISABLEPSCRIPT "Disable Platform Script" OFF)
0242 ###############################################################################
0243
0244 ################################################################################
0245 # Option to disable documentation build (dos are enabled by default)
0246
0247 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
0248 # not working on mac by default...
0249 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" ON)
0250 else()
0251 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" OFF)
0252 endif()
0253 ################################################################################
0254
0255 ################################################################################
0256 # Submakes
0257 ################################################################################
0258 # Recurse into the project subdirectories. This does not actually
0259 # cause another cmake executable to run. The same process will walk through
0260 # the project's entire directory structure.
0261 add_subdirectory (libnstd)
0262 add_subdirectory (embedfile)
0263 add_subdirectory (libcgreen)
0264 add_subdirectory (libubf)
0265 add_subdirectory (libnetproto)
0266 add_subdirectory (mkfldhdr)
0267 # Enduro/X sub-directories for ATMI
0268 add_subdirectory (libatmi) # General Purpose ATMI library
0269 add_subdirectory (libatmisrv) # ATMI server library
0270 add_subdirectory (libatmiclt) # ATMI client library
0271 add_subdirectory (libtux) # Tux lib emulation
0272 add_subdirectory (libexnet)
0273 add_subdirectory (libexmemck)
0274 add_subdirectory (libndrxconf)
0275
0276 IF (NOT DEFINE_DISABLEPSCRIPT)
0277 add_subdirectory (libps) # Platform script
0278 add_subdirectory (libpsstdlib) # Platform script standard library
0279 ENDIF()
0280
0281 add_subdirectory (tpevsrv)
0282 add_subdirectory (tpcachesv)
0283 add_subdirectory (tpcached)
0284 add_subdirectory (tprecover) # Special recovery server
0285 add_subdirectory (tpbrdcstsv) # tpbroadcast remote machine dispatcher
0286 add_subdirectory (ud)
0287
0288
0289 IF (NOT DEFINE_DISABLEPSCRIPT)
0290 add_subdirectory (pscript) # Platform script interpreter
0291 ENDIF()
0292
0293 add_subdirectory (viewc) # View compiler
0294 add_subdirectory (ndrxd) # Enduro X daemon
0295 add_subdirectory (tpadmsv) # Enduro/X Admin API Server
0296 add_subdirectory (exsinglesv) # Enduro/X Singleton Lock provider
0297 add_subdirectory (migration) # Migration tools
0298 add_subdirectory (xadmin) # Enduro X command line interface
0299 add_subdirectory (buildtools) # buildserver,buildclient,buildtms
0300 add_subdirectory (lmdb_util) # LMDB/EXDB Admin utilities
0301 add_subdirectory (xmemck) # Enduro X memcory checking tool
0302 add_subdirectory (bridge) # Cluster bridge server
0303 add_subdirectory (tmsrv) # Transaction Manager server for XA transactions
0304 add_subdirectory (tmqueue) # Persistant Queue server
0305 add_subdirectory (cpmsrv) # Client Process Monitor
0306 add_subdirectory (xadrv) # XA Drivers for RMs
0307 add_subdirectory (cconfsrv) # Common-Config server
0308 add_subdirectory (exbench) # Enduro/X benchmark tools
0309 add_subdirectory (plugins) # XA Drivers for RMs
0310 add_subdirectory (enctools) # XA Drivers for RMs
0311 add_subdirectory (libextest) # Shared test resource library
0312 add_subdirectory (ubftest) # UBF library testing
0313 add_subdirectory (atmitest) # ATMI testing
0314
0315 IF(DEFINE_DISABLEDOC)
0316 message("Documentation disabled - not building")
0317 ELSE (DEFINE_DISABLEDOC)
0318 add_subdirectory (doc) # Documentation project.
0319 ENDIF (DEFINE_DISABLEDOC)
0320
0321 add_subdirectory (include) # For install
0322 add_subdirectory (scripts) # For install
0323 add_subdirectory (cmake) # For install
0324
0325 #
0326 # Install license files
0327 #
0328 install (FILES
0329 LICENSE
0330 DESTINATION share/endurox)
0331
0332 #
0333 # Install third party licenses
0334 #
0335 install (FILES
0336 doc/third_party_licences.adoc
0337 DESTINATION share/endurox
0338 RENAME THIRD_PARTY_LICENCES)
0339
0340 #
0341 # Install stock RM file
0342 #
0343 install (FILES
0344 scripts/RM
0345 DESTINATION udataobj)
0346
0347 ################################################################################
0348 # uninstall target
0349 ################################################################################
0350 configure_file(
0351 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
0352 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0353 IMMEDIATE @ONLY)
0354
0355 add_custom_target(uninstall
0356 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
0357 ################################################################################
0358 # Packages
0359 ################################################################################
0360
0361 # Resolve OS versions...
0362 ex_osver()
0363
0364 # Support only for Linux
0365 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_NAME = " ${CMAKE_SYSTEM_NAME} )
0366 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
0367 set(CPACK_MONOLITHIC_INSTALL 1)
0368
0369 #
0370 # Generate configuration
0371 #
0372 configure_file ("${PROJECT_SOURCE_DIR}/include/ndrx_config.h.in"
0373 "${PROJECT_BINARY_DIR}/include/ndrx_config.h" )
0374
0375 # Test the available generators and then configure output
0376 find_program(RPMPROG "rpmbuild")
0377 find_program(APTPROG "dpkg")
0378
0379 # 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
0380 # problems...
0381 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man
0382 /usr/share/man/man3
0383 /usr/share/man/man5
0384 /usr/share/man/man8
0385 /usr/lib64/pkgconfig
0386 /usr/lib/pkgconfig)
0387 message("Excl: ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
0388
0389 set(CPACK_GENERATOR "TGZ")
0390 if(RPMPROG)
0391 message("Outputting RPM")
0392 set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
0393 endif()
0394
0395 if(APTPROG)
0396 message("Outputting DEB")
0397 set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
0398 endif()
0399
0400 ex_cpuarch()
0401
0402
0403 set(CPACK_PACKAGE_CONTACT "contact@mavimax.com")
0404 set(CPACK_PACKAGE_VERSION ${VERSION})
0405 set(CPACK_PACKAGE_VENDOR "Mavimax Ltd")
0406 set(CPACK_RPM_PACKAGE_RELEASE ${RELEASE})
0407 set(CPACK_RPM_PACKAGE_RELEASE_DIST ${RELEASE})
0408 set(CPACK_DEBIAN_PACKAGE_RELEASE ${RELEASE})
0409 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LO)
0410 message("CPack:Debug: PROJECT NAME = ${PROJECT_NAME_LO}")
0411 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})
0412 string(TOLOWER ${CPACK_PACKAGE_FILE_NAME} CPACK_PACKAGE_FILE_NAME)
0413 message("CPack:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
0414 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Enduro/X Middleware Platform")
0415 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0416 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0417 set(CPACK_RPM_PACKAGE_AUTOREQ "0")
0418 #set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
0419
0420 include(CPack)
0421 ################################################################################
0422 # Source indexing for quick symbol lookup
0423 # note that "glimpse" package must be installed.
0424 # to exclude any directory or name from indexing,
0425 # put the name in the glimpse_index/.glimpse_exclude
0426 ################################################################################
0427
0428 add_custom_target(index glimpseindex -n -H ./glimpse_index ${PROJECT_SOURCE_DIR}
0429 COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/glimpse_index/glim.cmake)
0430 #this also shall generate the glimp command in the current project
0431
0432 # vim: set ts=4 sw=4 et smartindent: