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-2018, Mavimax, Ltd. All Rights Reserved.
0010 ## This software is released under one of the following licenses:
0011 ## AGPL or Mavimax's license for commercial use.
0012 ## -----------------------------------------------------------------------------
0013 ## AGPL license:
0014 ## 
0015 ## This program is free software; you can redistribute it and/or modify it under
0016 ## the terms of the GNU Affero General Public License, version 3 as published
0017 ## by the Free Software Foundation;
0018 ##
0019 ## This program is distributed in the hope that it will be useful, but WITHOUT ANY
0020 ## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0021 ## PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0022 ## for more details.
0023 ##
0024 ## You should have received a copy of the GNU Affero General Public License along 
0025 ## with this program; if not, write to the Free Software Foundation, Inc., 
0026 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0027 ##
0028 ## -----------------------------------------------------------------------------
0029 ## A commercial use license is available from Mavimax, Ltd
0030 ## contact@mavimax.com
0031 ## -----------------------------------------------------------------------------
0032 ##
0033 
0034 cmake_minimum_required (VERSION 2.6) 
0035 project (ENDUROX) 
0036 set(VERSION "6.0.3")
0037 set(PROJ_NAME "Enduro/X")
0038 set(RELEASE "1")
0039 
0040 
0041 ################################################################################
0042 # OS Configuration
0043 ################################################################################
0044 
0045 EXEC_PROGRAM(uname ARGS -a OUTPUT_VARIABLE _TMP_CMAKE_OS_NAME)
0046 string(REGEX MATCH "^[a-zA-Z0-9-]*" _TMP_CMAKE_OS_NAME_EXTR ${_TMP_CMAKE_OS_NAME})
0047 string(TOUPPER ${_TMP_CMAKE_OS_NAME_EXTR} CMAKE_OS_NAME)
0048 
0049 # Force C++ for C
0050 #SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})
0051 
0052 message("CMake CMAKE_OS_NAME  = ${CMAKE_OS_NAME}")
0053 message("CMake CMAKE_C_COMPILER_ID  = ${CMAKE_C_COMPILER_ID}")
0054 message("CMake CMAKE_CXX_COMPILER_ID  = ${CMAKE_CXX_COMPILER_ID}")
0055 
0056 OPTION(DEFINE_FORCEPOLL "Force POLL (even on linux)" OFF)
0057 OPTION(DEFINE_FORCEFDPOLL "Force FDPOLL" OFF)
0058 OPTION(DEFINE_FORCEKQUEUE "Force Kqueue (BSD poll framework)" OFF)
0059 
0060 OPTION(DEFINE_RELEASEBUILD "Do relesae build" OFF)
0061 OPTION(DEFINE_FORCEEMQ "Force Emulated Message Queue" OFF)
0062 OPTION(DEFINE_SYSVQ "Force System V Message Queue" OFF)
0063 OPTION(DEFINE_ALIGNMENT_FORCE "Force alignment" OFF)
0064 OPTION(DEFINE_SANITIZE "Enable GCC/Clang Address Sanitizer (for debug)" OFF)
0065 
0066 SET (EX_ALIGNMENT_BYTES "4")
0067 
0068 SET ( CMAKE_CXX_FLAGS "-O2 -fno-exceptions -fno-rtti" CACHE STRING "compile flags" FORCE)
0069 
0070 # Support #310 Ubuntu 18.04 prints lot of unneeded warnings...
0071 if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
0072 #    SET(CMAKE_C_FLAGS "-Wno-format-truncation -Wstringop-overflow=0 -D_DEFAULT_SOURCE=1 ${CMAKE_C_FLAGS}")
0073     SET(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-format-truncation -Wformat-overflow=0 ${CMAKE_C_FLAGS}")
0074 endif()
0075 
0076 # Enable release only if specified.
0077 # By default if RELEASE_BUILD is not defined, then we run in debug!
0078 IF (DEFINE_RELEASEBUILD)
0079         MESSAGE( RELEASE_BUILD )
0080         SET(CMAKE_BUILD_TYPE release)
0081         SET(CMAKE_C_FLAGS "-fstack-protector -O2 ${CMAKE_C_FLAGS}")
0082 ELSE ()
0083         MESSAGE( DEBUG_BUILD )
0084         SET(CMAKE_BUILD_TYPE debug)
0085 # Memory debugging:
0086 #       SET(CMAKE_C_FLAGS "-fsanitize=alignment -fsanitize=address -fno-omit-frame-pointer -O1 -ggdb ${CMAKE_C_FLAGS}")
0087 
0088     IF (DEFINE_SANITIZE)
0089         SET(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -O1 -ggdb ${CMAKE_C_FLAGS}")
0090     ELSE ()
0091         SET(CMAKE_C_FLAGS "-fstack-protector -O2 -ggdb ${CMAKE_C_FLAGS}")
0092     ENDIF()
0093 ENDIF ()
0094 
0095 # -pthread needed for System V pthread_atfork()
0096 SET(RT_LIB rt dl)
0097 if( ${CMAKE_OS_NAME} STREQUAL "LINUX" )
0098     set(EX_OS_LINUX "1")
0099     set(NDRX_LD_LIBRARY_PATH "LD_LIBRARY_PATH")
0100     # Configure backend transport
0101     IF(DEFINE_SYSVQ)
0102         message("Linux - forced poll()")
0103         set(EX_USE_SYSVQ "1")
0104     ELSEIF(DEFINE_FORCEPOLL)
0105         message("Linux - forced poll()")
0106         set(EX_USE_POLL "1")
0107     ELSEIF(DEFINE_FORCEFDPOLL)
0108         message("Linux - forced fdpoll()")
0109         set(EX_USE_FDPOLL "1")
0110     ELSEIF(DEFINE_FORCEEMQ)
0111         message("Linux - forced emulated message q")
0112         set(EX_USE_EMQ "1")
0113         set(EX_USE_POLL "1")
0114     ELSE()
0115         message("Linux - forced epoll()")
0116         set(EX_USE_EPOLL "1")
0117     ENDIF()
0118 elseif(${CMAKE_OS_NAME} STREQUAL "AIX")
0119 # Configure the compiler, we support XLC too..
0120 
0121         message("No threads mode for CPM - bit slower child process exit status check...")
0122         # Seems aix 7.1 does not like threads mixed with fork...
0123         set(EX_CPM_NO_THREADS "1")
0124         set(NDRX_LD_LIBRARY_PATH "LD_LIBRARY_PATH")
0125 
0126         if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
0127             message("GNU compiler")
0128             set ( CMAKE_C_FLAGS "-D_SEM_SEMUN_UNDEFINED -D_THREAD_SAFE -pthread -maix64 ${CMAKE_C_FLAGS}")
0129         elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "XL")
0130             message("XL compiler")
0131             set ( CMAKE_C_FLAGS " -D_SEM_SEMUN_UNDEFINED -D_THREAD_SAFE ")
0132             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qwarn64 -qpic -bexpfull -b64")
0133             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -brtl -qtls -q64 -qlanglvl=extc99")
0134             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-997 -qprocimported=setjmp -lbsd")
0135             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-747")
0136             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-742")
0137             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-743")
0138             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-744")
0139             set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsuppress=1506-745")
0140 
0141             if (NOT DEFINE_RELEASEBUILD)
0142                     message("XL compiler: with -g (debug symbols...)")
0143                     set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
0144             endif()
0145         endif()
0146 
0147     set(EX_USE_SYSVQ "1")
0148     set(EX_OS_AIX "1")
0149 elseif(${CMAKE_OS_NAME} STREQUAL "HP-UX")
0150     set(EX_USE_POLL "1")
0151     set(EX_OS_HPUX "1")
0152     set(NDRX_LD_LIBRARY_PATH "SHLIB_PATH")
0153 elseif(${CMAKE_OS_NAME} STREQUAL "SUNOS")
0154     set(EX_CPM_NO_THREADS "1")
0155     set(EX_OS_SUNOS "1")
0156     set(EX_USE_SYSVQ "1")
0157     set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -m64")
0158     set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -m64")
0159 
0160     set(NDRX_LD_LIBRARY_PATH "LD_LIBRARY_PATH")
0161     # Bug #219 !!! _REENTRANT makes errno thread safe
0162     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT")
0163 
0164     if ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
0165         # set new config for SunPro
0166         SET(CMAKE_C_FLAGS "-D_REENTRANT -m64")
0167         message("SUN Studio compiler (building for 64bit) ")
0168 
0169         # Bug #219 !!! _REENTRANT makes errno thread safe
0170         # For GNU I guess 
0171         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -errtags -fast -xc99=all -erroff=E_PTR_TO_VOID_IN_ARITHMETIC ")
0172         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=E_EMPTY_MBR_DECLARATION -erroff=E_NO_IMPLICIT_DECL_ALLOWED")
0173         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=E_EMPTY_DECLARATION -erroff=E_ARGUEMENT_MISMATCH -erroff=E_ZERO_OR_NEGATIVE_SUBSCRIPT")
0174         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=E_ARG_INCOMPATIBLE_WITH_ARG_L")
0175         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=E_BAD_PTR_INT_COMBINATION")
0176 
0177         # Add Sun Studio C runtime
0178         SET(RT_LIB ${RT_LIB} Crun)
0179     endif()
0180 
0181 elseif(${CMAKE_OS_NAME} STREQUAL "FREEBSD")
0182     set(RT_LIB rt)
0183     # seem that threading model also does not work here...
0184     set(EX_CPM_NO_THREADS "1")
0185     set(EX_OS_FREEBSD "1")
0186     # Best option...
0187     set(EX_USE_KQUEUE "1")
0188     set(NDRX_LD_LIBRARY_PATH "LD_LIBRARY_PATH")
0189 elseif(${CMAKE_OS_NAME} STREQUAL "CYGWIN")
0190     set(EX_OS_CYGWIN "1")
0191     set(EX_USE_POLL "1")
0192     set(NDRX_LD_LIBRARY_PATH "LD_LIBRARY_PATH")
0193 elseif(${CMAKE_OS_NAME} STREQUAL "DARWIN")
0194     set(RT_LIB dl)
0195     set(EX_OS_DARWIN "1")
0196     set(EX_USE_EMQ "1")
0197     set(EX_USE_POLL "1")
0198     set(NDRX_LD_LIBRARY_PATH "DYLD_FALLBACK_LIBRARY_PATH")
0199 # Unknown OS:
0200 else()
0201         message( FATAL_ERROR "Unsupported OS" )
0202 endif()
0203 
0204 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
0205     set(EX_ALIGNMENT_BYTES "8")
0206     set(EX_ALIGNMENT_FORCE "1")
0207 ENDIF ()
0208 
0209 IF (DEFINE_ALIGNMENT_FORCE)
0210     set(EX_ALIGNMENT_FORCE "1")
0211 ENDIF()
0212 
0213 IF(EX_USE_SYSVQ)
0214     set(EX_POLLER_STR   "SystemV")
0215 ELSEIF(EX_USE_FDPOLL)
0216     set(EX_POLLER_STR   "fdpoll")
0217 ELSEIF(EX_USE_EMQ)
0218     set(EX_POLLER_STR   "emq")
0219 ELSEIF(EX_USE_POLL)
0220     set(EX_POLLER_STR   "poll")
0221 ELSEIF(EX_USE_EPOLL)
0222     set(EX_POLLER_STR   "epoll")
0223 ELSEIF(EX_USE_KQUEUE)
0224     set(EX_POLLER_STR   "kqueue")
0225 ELSE()
0226     message( FATAL_ERROR "ERROR! Invalid queue transport backend!" )
0227 ENDIF()
0228 
0229 message("CMake EX_ALIGNMENT_BYTES  = ${EX_ALIGNMENT_BYTES}")
0230 message("Poller  = ${EX_POLLER_STR}")
0231 message("ALIGNMENT_FORCE  = ${EX_ALIGNMENT_FORCE}")
0232 
0233 ################################################################################
0234 # "Configure"
0235 ################################################################################
0236 
0237 # In this file we are doing all of our 'configure' checks. Things like checking
0238 # for headers, functions, libraries, types and size of types.
0239 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
0240 INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
0241 INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
0242 INCLUDE (${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake)
0243 INCLUDE (${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
0244 INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
0245 INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
0246 
0247 
0248 CHECK_C_SOURCE_COMPILES("extern const char * __progname; int main() {return __progname[0];}" HAVE_PROGNAME)
0249 CHECK_C_SOURCE_COMPILES("int main() {__builtin_expect(1, 1);}" HAVE_EXPECT)
0250 CHECK_C_SOURCE_COMPILES("int main() { int X = 0; __sync_bool_compare_and_swap(&X, 0, 1); __sync_synchronize();}" HAVE_SYNC)
0251 CHECK_C_SOURCE_COMPILES("#include <stdio.h> \n int main() {char buf[128]; size_t len; getline(buf, &len, stdin);}" HAVE_GETLINE)
0252 CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char dest[1]; char src[1]; strlcpy(dest, src, 1);}" HAVE_STRLCPY)
0253 CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {strnlen(\"ABC\", 1);}" HAVE_STRNLEN)
0254 CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char tmp[8]={0x0}; strcat_s(tmp, sizeof(tmp), \"abc\");}" EX_HAVE_STRCAT_S)
0255 CHECK_C_SOURCE_COMPILES("#include <string.h> \n int main() {char *tmp; asprintf(&tmp, \"HELLO\");}" EX_HAVE_ASPRINTF)
0256 
0257 # To check for an include file you do this: 
0258 CHECK_INCLUDE_FILE("stdint.h"        HAVE_STDINT_H)
0259 CHECK_INCLUDE_FILE("getopt.h"       HAVE_GETOPT_H)
0260         
0261 
0262 # To check the size of a primitive type:
0263 CHECK_TYPE_SIZE("int"   EX_SIZEOF_INT)
0264 CHECK_TYPE_SIZE("long"  EX_SIZEOF_LONG)
0265 CHECK_TYPE_SIZE("void*"  EX_SIZEOF_VOIDPTR)
0266 
0267 MATH (EXPR EX_PLATFORM_BITS "${EX_SIZEOF_VOIDPTR} * 8")
0268 
0269 IF (DEFINE_DISABLEPSCRIPT)
0270     set(NDRX_DISABLEPSCRIPT "1")
0271 ENDIF()
0272 
0273 IF (DEFINE_SANITIZE)
0274     set(NDRX_SANITIZE "1")
0275 ENDIF()
0276 
0277 # Output the project version
0278 set(NDRX_VERSION_STR "${PROJ_NAME} ${VERSION}")
0279 
0280 ################################################################################
0281 # Install dir config
0282 ################################################################################
0283 get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
0284 
0285 message("LIB: ${LIB64}")
0286 
0287 if(${CMAKE_OS_NAME} STREQUAL "DARWIN")
0288     set(LIB_SUFFIX "")
0289 # Seems like BSD does not use lib64 folder
0290 elseif ("${CMAKE_OS_NAME}" STREQUAL "FREEBSD")
0291     set(LIB_SUFFIX "")
0292 elseif ("${LIB64}" STREQUAL "TRUE")
0293     set(LIB_SUFFIX 64)
0294 else()
0295     set(LIB_SUFFIX "")
0296 endif()
0297 
0298 message("LIB_SUFFIX: ${LIB_SUFFIX}")
0299 
0300 set(INSTALL_LIB_DIR lib${LIB_SUFFIX} CACHE PATH "Installation directory for libraries")
0301 
0302 message("INSTALL_LIB_DIR: ${INSTALL_LIB_DIR}")
0303 
0304 mark_as_advanced(INSTALL_LIB_DIR) 
0305 MESSAGE( STATUS "INSTALL_LIB_DIR: " ${INSTALL_LIB_DIR} )
0306 
0307 ################################################################################
0308 # Options
0309 ################################################################################
0310 
0311 # Option to disable gpg-me (gpg-me enabled by default)
0312 
0313 OPTION(DEFINE_DISABLEGPGME "Use GPG-ME encryption" OFF)
0314  
0315 IF(DEFINE_DISABLEGPGME)
0316     ADD_DEFINITIONS(-DDISABLEGPGME)
0317 ENDIF(DEFINE_DISABLEGPGME)
0318 
0319 OPTION(DEFINE_DISABLEPSCRIPT "Disable Platform Script" OFF)
0320 ###############################################################################
0321 
0322 ################################################################################
0323 # Option to disable documentation build (dos are enabled by default)
0324 OPTION(DEFINE_DISABLEDOC "Disable documentation generation" OFF) 
0325 ################################################################################
0326 
0327 ################################################################################
0328 # Submakes
0329 ################################################################################
0330 # Recurse into the project subdirectories. This does not actually
0331 # cause another cmake executable to run. The same process will walk through 
0332 # the project's entire directory structure. 
0333 add_subdirectory (libnstd)
0334 add_subdirectory (embedfile)
0335 add_subdirectory (libcgreen)
0336 add_subdirectory (libexuuid)
0337 add_subdirectory (libubf)
0338 add_subdirectory (libnetproto)
0339 add_subdirectory (libthpool)
0340 add_subdirectory (ubftest)
0341 add_subdirectory (mkfldhdr)
0342 # Enduro/X sub-directories for ATMI
0343 add_subdirectory (libatmi) # General Purpose ATMI library
0344 add_subdirectory (libatmisrv) #  ATMI server library 
0345 add_subdirectory (libatmiclt) #  ATMI client library 
0346 add_subdirectory (libexnet)
0347 add_subdirectory (libexmemck)
0348 add_subdirectory (libndrxconf)
0349 
0350 IF (NOT DEFINE_DISABLEPSCRIPT)
0351         add_subdirectory (libps) # Platform script
0352         add_subdirectory (libpsstdlib) # Platform script standard library
0353 ENDIF()
0354 
0355 add_subdirectory (tpevsrv)
0356 add_subdirectory (tpcachesv)
0357 add_subdirectory (tpcached)
0358 add_subdirectory (tprecover) # Special recovery server
0359 add_subdirectory (tpbrdcstsv) # tpbroadcast remote machine dispatcher
0360 add_subdirectory (ud)
0361 
0362 
0363 IF (NOT DEFINE_DISABLEPSCRIPT)
0364         add_subdirectory (pscript) # Platform script interpreter
0365 ENDIF()
0366 
0367 add_subdirectory (viewc) # View compiler
0368 add_subdirectory (ndrxd) # Enduro X daemon
0369 add_subdirectory (xadmin) # Enduro X command line interface
0370 add_subdirectory (lmdb_util) # LMDB/EXDB Admin utilities
0371 add_subdirectory (xmemck) # Enduro X memcory checking tool
0372 add_subdirectory (bridge) # Cluster bridge server
0373 add_subdirectory (tmsrv) # Transaction Manager server for XA transactions
0374 add_subdirectory (tmqueue) # Persistant Queue server
0375 add_subdirectory (cpmsrv) # Client Process Monitor
0376 add_subdirectory (xadrv) # XA Drivers for RMs
0377 add_subdirectory (cconfsrv) # Common-Config server
0378 add_subdirectory (plugins) # XA Drivers for RMs
0379 add_subdirectory (enctools) # XA Drivers for RMs
0380 add_subdirectory (atmitest) #  ATMI testing
0381 
0382 IF(DEFINE_DISABLEDOC)
0383         message("Documentation disabled - not building")
0384 ELSE (DEFINE_DISABLEDOC)
0385         add_subdirectory (doc) #  Documentation project.
0386 ENDIF (DEFINE_DISABLEDOC)
0387 
0388 add_subdirectory (include) #  For install
0389 add_subdirectory (scripts) #  For install
0390 add_subdirectory (sampleconfig) #  For install
0391 
0392 
0393 ################################################################################
0394 # uninstall target
0395 ################################################################################
0396 configure_file(
0397     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
0398     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0399     IMMEDIATE @ONLY)
0400 
0401 add_custom_target(uninstall
0402     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
0403 ################################################################################
0404 # Packages
0405 ################################################################################
0406 
0407 find_program(LSB_RELEASE_EXECUTABLE lsb_release)
0408 if(LSB_RELEASE_EXECUTABLE)
0409         execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -si
0410                 OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT_OS
0411                 ERROR_QUIET
0412                 OUTPUT_STRIP_TRAILING_WHITESPACE)
0413 
0414         string(TOLOWER 
0415                 ${_TMP_LSB_RELEASE_OUTPUT_OS}
0416         LSB_RELEASE_OUTPUT_OS)
0417         string(REPLACE " " "_" LSB_RELEASE_OUTPUT_OS ${LSB_RELEASE_OUTPUT_OS})
0418 
0419         execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -sr
0420                 OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT_VER
0421                 ERROR_QUIET
0422                 OUTPUT_STRIP_TRAILING_WHITESPACE)
0423         string(REPLACE "." "_" LSB_RELEASE_OUTPUT_VER ${_TMP_LSB_RELEASE_OUTPUT_VER})
0424         #string(REGEX MATCH "^[0-9]+" LSB_RELEASE_OUTPUT_VER ${_TMP_LSB_RELEASE_OUTPUT_VER})
0425 elseif (EXISTS /etc/os-release)
0426 
0427         execute_process(COMMAND bash -c "cat /etc/os-release | egrep '^NAME=' | cut -d '\"' -f2"
0428                 OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT_OS
0429                 OUTPUT_STRIP_TRAILING_WHITESPACE)
0430 
0431         string(TOLOWER 
0432                 ${_TMP_LSB_RELEASE_OUTPUT_OS}
0433         LSB_RELEASE_OUTPUT_OS)
0434         string(REPLACE " " "_" LSB_RELEASE_OUTPUT_OS ${LSB_RELEASE_OUTPUT_OS})
0435 
0436         execute_process(COMMAND bash -c "cat /etc/os-release | egrep '^VERSION=' | cut -d '\"' -f2"
0437                 OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT_VER
0438                 OUTPUT_STRIP_TRAILING_WHITESPACE)
0439         string(REPLACE "." "_" LSB_RELEASE_OUTPUT_VER ${_TMP_LSB_RELEASE_OUTPUT_VER})
0440         #string(REGEX MATCH "^[0-9]+" LSB_RELEASE_OUTPUT_VER ${_TMP_LSB_RELEASE_OUTPUT_VER})
0441 else ()
0442         set(LSB_RELEASE_OUTPUT_OS ${CMAKE_OS_NAME})
0443 
0444         string(REPLACE "." "_" _TMP_LSB_RELEASE_OUTPUT_VER ${CMAKE_SYSTEM_VERSION})
0445         string(REPLACE "-" "_" LSB_RELEASE_OUTPUT_VER ${_TMP_LSB_RELEASE_OUTPUT_VER})
0446         
0447         # If it is AIX, then we can extract version from uname
0448         if(${CMAKE_OS_NAME} STREQUAL "AIX")
0449                 execute_process(COMMAND uname -v
0450                         OUTPUT_VARIABLE _TMP_OS_MAJOR_VER OUTPUT_STRIP_TRAILING_WHITESPACE)
0451                 execute_process(COMMAND uname -r
0452                         OUTPUT_VARIABLE _TMP_OS_MINOR_VER OUTPUT_STRIP_TRAILING_WHITESPACE)
0453                 set(LSB_RELEASE_OUTPUT_VER ${_TMP_OS_MAJOR_VER}_${_TMP_OS_MINOR_VER})
0454         endif()
0455         
0456 endif()
0457 
0458 message("LSB_RELEASE OS  = ${LSB_RELEASE_OUTPUT_OS}")
0459 message("LSB_RELEASE VER = ${LSB_RELEASE_OUTPUT_VER}")
0460 set(EX_LSB_RELEASE_VER ${LSB_RELEASE_OUTPUT_VER})
0461 
0462 string(REPLACE "_" ";" LSB_VERSION_LIST ${LSB_RELEASE_OUTPUT_VER})
0463 
0464 list( LENGTH LSB_VERSION_LIST TMP_LIST_LEN ) 
0465 
0466 if (TMP_LIST_LEN LESS 1)
0467         # No version at all!!
0468         set(EX_LSB_RELEASE_VER_MAJOR "0")
0469         set(EX_LSB_RELEASE_VER_MINOR "0")
0470 elseif (TMP_LIST_LEN LESS 2)
0471         # Bug #198 - FedoraCore do not have minor version numbers
0472         list(GET LSB_VERSION_LIST 0 EX_LSB_RELEASE_VER_MAJOR)
0473         set(EX_LSB_RELEASE_VER_MINOR "0")
0474 
0475 else ()
0476         list(GET LSB_VERSION_LIST 0 EX_LSB_RELEASE_VER_MAJOR)
0477         list(GET LSB_VERSION_LIST 1 EX_LSB_RELEASE_VER_MINOR)
0478 endif()
0479 
0480 MESSAGE( "EX_LSB_RELEASE_VER_MAJOR = " ${EX_LSB_RELEASE_VER_MAJOR} )
0481 MESSAGE( "EX_LSB_RELEASE_VER_MINOR = " ${EX_LSB_RELEASE_VER_MINOR} )
0482 
0483 # Support only for Linux
0484 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_NAME = " ${CMAKE_SYSTEM_NAME} )
0485 MESSAGE( "CPack:Debug: CMAKE_SYSTEM_PROCESSOR = " ${CMAKE_SYSTEM_PROCESSOR} )
0486 set(CPACK_MONOLITHIC_INSTALL 1)
0487 
0488 #
0489 # Generate configuration 
0490 #
0491 configure_file ("${PROJECT_SOURCE_DIR}/include/ndrx_config.h.in"
0492                 "${PROJECT_BINARY_DIR}/include/ndrx_config.h" )
0493 
0494 # Test the available generators and then configure output
0495 find_program(RPMPROG "rpmbuild")
0496 find_program(APTPROG "dpkg")
0497 
0498 # 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
0499 # problems...
0500 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man
0501                 /usr/share/man/man3
0502                 /usr/share/man/man5
0503                 /usr/share/man/man8
0504                 /usr/lib64/pkgconfig
0505                 /usr/lib/pkgconfig)
0506 message("Excl: ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
0507 
0508 set(CPACK_GENERATOR "TGZ")
0509 if(RPMPROG)
0510         message("Outputting RPM")
0511         set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
0512 endif()
0513 
0514 if(APTPROG)
0515         message("Outputting DEB")
0516         set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
0517 endif()
0518 
0519 set(CPACK_PACKAGE_CONTACT "madars.vitolins@gmail.com")
0520 set(CPACK_PACKAGE_VERSION ${VERSION})
0521 #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libxml2,openssl,libgpgme11")
0522 #set(CPACK_RPM_PACKAGE_REQUIRES "libxml2,openssl,libssl,libgpgme11")
0523 string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LO)
0524 message("CPack:Debug: PROJECT NAME = ${PROJECT_NAME_LO}")
0525 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}.${CMAKE_SYSTEM_PROCESSOR}_${EX_PLATFORM_BITS})
0526 message("CPack:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
0527 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Enduro/X Middleware Platform")
0528 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION  ${CPACK_PACKAGE_DESCRIPTION})
0529 set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
0530 #set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
0531 
0532 include(CPack)
0533 ################################################################################
0534 # Source indexing for quick symbol lookup
0535 # note that "glimpse" package must be installed.
0536 # to exclude any directory or name from indexing,
0537 # put the name in the glimpse_index/.glimpse_exclude
0538 ################################################################################
0539 
0540 add_custom_target(index glimpseindex -H ./glimpse_index ${PROJECT_SOURCE_DIR}
0541                     COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/glimpse_index/glim.cmake)
0542 #this also shall generate the glimp command in the current project
0543 
0544 # vim: set ts=4 sw=4 et smartindent: