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
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
0246 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
0247 # not working on mac by default...
0248 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" ON)
0249 else()
0250 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" OFF)
0251 endif()
0252 ################################################################################
0253
0254 ################################################################################
0255 # Submakes
0256 ################################################################################
0257 # Recurse into the project subdirectories. This does not actually
0258 # cause another cmake executable to run. The same process will walk through
0259 # the project's entire directory structure.
0260 add_subdirectory (libnstd)
0261 add_subdirectory (embedfile)
0262 add_subdirectory (libcgreen)
0263 add_subdirectory (libubf)
0264 add_subdirectory (libnetproto)
0265 add_subdirectory (mkfldhdr)
0266 # Enduro/X sub-directories for ATMI
0267 add_subdirectory (libatmi) # General Purpose ATMI library
0268 add_subdirectory (libatmisrv) # ATMI server library
0269 add_subdirectory (libatmiclt) # ATMI client library
0270 add_subdirectory (libtux) # Tux lib emulation
0271 add_subdirectory (libexnet)
0272 add_subdirectory (libexmemck)
0273 add_subdirectory (libndrxconf)
0274
0275 IF (NOT DEFINE_DISABLEPSCRIPT)
0276 add_subdirectory (libps) # Platform script
0277 add_subdirectory (libpsstdlib) # Platform script standard library
0278 ENDIF()
0279
0280 add_subdirectory (tpevsrv)
0281 add_subdirectory (tpcachesv)
0282 add_subdirectory (tpcached)
0283 add_subdirectory (tprecover) # Special recovery server
0284 add_subdirectory (tpbrdcstsv) # tpbroadcast remote machine dispatcher
0285 add_subdirectory (ud)
0286
0287
0288 IF (NOT DEFINE_DISABLEPSCRIPT)
0289 add_subdirectory (pscript) # Platform script interpreter
0290 ENDIF()
0291
0292 add_subdirectory (viewc) # View compiler
0293 add_subdirectory (ndrxd) # Enduro X daemon
0294 add_subdirectory (tpadmsv) # Enduro/X Admin API Server
0295 add_subdirectory (exsinglesv) # Enduro/X Singleton Lock provider
0296 add_subdirectory (migration) # Migration tools
0297 add_subdirectory (xadmin) # Enduro X command line interface
0298 add_subdirectory (buildtools) # buildserver,buildclient,buildtms
0299 add_subdirectory (lmdb_util) # LMDB/EXDB Admin utilities
0300 add_subdirectory (xmemck) # Enduro X memcory checking tool
0301 add_subdirectory (bridge) # Cluster bridge server
0302 add_subdirectory (tmsrv) # Transaction Manager server for XA transactions
0303 add_subdirectory (tmqueue) # Persistant Queue server
0304 add_subdirectory (cpmsrv) # Client Process Monitor
0305 add_subdirectory (xadrv) # XA Drivers for RMs
0306 add_subdirectory (cconfsrv) # Common-Config server
0307 add_subdirectory (exbench) # Enduro/X benchmark tools
0308 add_subdirectory (plugins) # XA Drivers for RMs
0309 add_subdirectory (enctools) # XA Drivers for RMs
0310 add_subdirectory (libextest) # Shared test resource library
0311 add_subdirectory (ubftest) # UBF library testing
0312 add_subdirectory (atmitest) # ATMI testing
0313
0314 IF(DEFINE_DISABLEDOC)
0315 message("Documentation disabled - not building")
0316 ELSE (DEFINE_DISABLEDOC)
0317 add_subdirectory (doc) # Documentation project.
0318 ENDIF (DEFINE_DISABLEDOC)
0319
0320 add_subdirectory (include) # For install
0321 add_subdirectory (scripts) # For install
0322 add_subdirectory (cmake) # For install
0323
0324 #
0325 # Install license files
0326 #
0327 install (FILES
0328 LICENSE
0329 DESTINATION share/endurox)
0330
0331 #
0332 # Install third party licenses
0333 #
0334 install (FILES
0335 doc/third_party_licences.adoc
0336 DESTINATION share/endurox
0337 RENAME THIRD_PARTY_LICENCES)
0338
0339 #
0340 # Install stock RM file
0341 #
0342 install (FILES
0343 scripts/RM
0344 DESTINATION udataobj)
0345
0346 ################################################################################
0347 # uninstall target
0348 ################################################################################
0349 configure_file(
0350 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
0351 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0352 IMMEDIATE @ONLY)
0353
0354 add_custom_target(uninstall
0355 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
0356 ################################################################################
0357 # Packages
0358 ################################################################################
0359
0360 # Resolve OS versions...
0361 ex_osver()
0362
0363 # Support only for Linux
0364 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_NAME = " ${CMAKE_SYSTEM_NAME} )
0365 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
0366 set(CPACK_MONOLITHIC_INSTALL 1)
0367
0368 #
0369 # Generate configuration
0370 #
0371 configure_file ("${PROJECT_SOURCE_DIR}/include/ndrx_config.h.in"
0372 "${PROJECT_BINARY_DIR}/include/ndrx_config.h" )
0373
0374 # Test the available generators and then configure output
0375 find_program(RPMPROG "rpmbuild")
0376 find_program(APTPROG "dpkg")
0377
0378 # 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
0379 # problems...
0380 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man
0381 /usr/share/man/man3
0382 /usr/share/man/man5
0383 /usr/share/man/man8
0384 /usr/lib64/pkgconfig
0385 /usr/lib/pkgconfig)
0386 message("Excl: ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
0387
0388 set(CPACK_GENERATOR "TGZ")
0389 if(RPMPROG)
0390 message("Outputting RPM")
0391 set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
0392 endif()
0393
0394 if(APTPROG)
0395 message("Outputting DEB")
0396 set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
0397 endif()
0398
0399 ex_cpuarch()
0400
0401
0402 set(CPACK_PACKAGE_CONTACT "contact@mavimax.com")
0403 set(CPACK_PACKAGE_VERSION ${VERSION})
0404 set(CPACK_PACKAGE_VENDOR "Mavimax Ltd")
0405 set(CPACK_RPM_PACKAGE_RELEASE ${RELEASE})
0406 set(CPACK_RPM_PACKAGE_RELEASE_DIST ${RELEASE})
0407 set(CPACK_DEBIAN_PACKAGE_RELEASE ${RELEASE})
0408 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LO)
0409 message("CPack:Debug: PROJECT NAME = ${PROJECT_NAME_LO}")
0410 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})
0411 string(TOLOWER ${CPACK_PACKAGE_FILE_NAME} CPACK_PACKAGE_FILE_NAME)
0412 message("CPack:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
0413 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Enduro/X Middleware Platform")
0414 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0415 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0416 set(CPACK_RPM_PACKAGE_AUTOREQ "0")
0417 #set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
0418
0419 include(CPack)
0420 ################################################################################
0421 # Source indexing for quick symbol lookup
0422 # note that "glimpse" package must be installed.
0423 # to exclude any directory or name from indexing,
0424 # put the name in the glimpse_index/.glimpse_exclude
0425 ################################################################################
0426
0427 add_custom_target(index glimpseindex -n -H ./glimpse_index ${PROJECT_SOURCE_DIR}
0428 COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/glimpse_index/glim.cmake)
0429 #this also shall generate the glimp command in the current project
0430
0431 # vim: set ts=4 sw=4 et smartindent: