CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
  2. PROJECT(ARTIS_STAR CXX C)
  3. ENABLE_TESTING()
  4. SET(ARTIS_MAJOR 1)
  5. SET(ARTIS_MINOR 0)
  6. SET(ARTIS_PATCH 0)
  7. SET(ARTIS_EXTRA "")
  8. SET(ARTIS_VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}")
  9. SET(ARTIS_VERSION_SHORT "${ARTIS_MAJOR}.${ARTIS_MINOR}")
  10. SET(ARTIS_NAME "artis-star")
  11. SET(ARTIS_NAME_VERSION "${ARTIS_NAME}-${ARTIS_VERSION}")
  12. SET(ARTIS_LOCALE_NAME "${ARTIS_NAME}-${ARTIS_MAJOR}-${ARTIS_MINOR}")
  13. IF ("${ARTIS_EXTRA}" STREQUAL "")
  14. SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}")
  15. ELSE ("${ARTIS_EXTRA}" STREQUAL "")
  16. SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}-${ARTIS_EXTRA}")
  17. ENDIF ("${ARTIS_EXTRA}" STREQUAL "")
  18. SET(ARTIS_NAME_COMPLETE "${ARTIS_NAME}-${ARTIS_COMPLETE}")
  19. #
  20. # Installation variables
  21. #
  22. SET(ARTIS_LIBRARY_DIRS "lib/artis-star-${ARTIS_VERSION_SHORT}")
  23. SET(ARTIS_INCLUDE_DIRS "include/artis-star-${ARTIS_VERSION_SHORT}/artis-star")
  24. SET(ARTIS_INCLUDE_DIR "include/artis-star-${ARTIS_VERSION_SHORT}")
  25. SET(ARTIS_MANPAGE_PATH "share/man/man1")
  26. SET(ARTIS_SHARE_DIRS "share/artis-star-${ARTIS_VERSION_SHORT}")
  27. #
  28. # Append the library version information to the library target
  29. # properties.
  30. #
  31. SET (ARTIS_LIBRARY_PROPERTIES VERSION 0)
  32. SET (ARTIS_APP_PROPERTIES SOVERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}"
  33. VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}")
  34. #
  35. # Debug mode
  36. #
  37. IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
  38. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
  39. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -pthread")
  40. IF (UNIX)
  41. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
  42. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  43. ENDIF (UNIX)
  44. ENDIF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
  45. if (CMAKE_BUILD_TYPE STREQUAL "")
  46. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  47. endif ()
  48. #
  49. # Modules
  50. #
  51. INCLUDE(CheckIncludeFileCXX)
  52. INCLUDE(CheckIncludeFile)
  53. INCLUDE(CheckLibraryExists)
  54. INCLUDE(CMakeDetermineCCompiler)
  55. #
  56. # Boost libraries
  57. #
  58. set( Boost_USE_STATIC_LIBS OFF )
  59. set( Boost_USE_MULTITHREADED ON )
  60. set( Boost_USE_STATIC_RUNTIME OFF )
  61. find_package( Boost 1.71 COMPONENTS mpi timer serialization system )
  62. #
  63. # Generate the config.h
  64. #
  65. CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
  66. CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
  67. CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
  68. INCLUDE_DIRECTORIES(${ARTIS_STAR_BINARY_DIR})
  69. #
  70. # Generate the artis.pc pkg-config file.
  71. #
  72. SET(ARTIS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
  73. SET(ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
  74. SET(ARTIS_PKGCONFIG_LIBDIR "lib")
  75. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis-star.pc.in
  76. ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc @ONLY)
  77. INSTALL(FILES ${ARTIS_STAR_BINARY_DIR}/artis-star-${ARTIS_VERSION_SHORT}.pc
  78. DESTINATION lib/pkgconfig)
  79. #
  80. # Install the README
  81. #
  82. IF(UNIX)
  83. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}")
  84. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}")
  85. ELSE(UNIX)
  86. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "Readme.txt")
  87. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "CopyRight.txt")
  88. ENDIF(UNIX)
  89. #
  90. # Browse the src subdirectory
  91. #
  92. ADD_SUBDIRECTORY(src)
  93. #
  94. # Status
  95. #
  96. MESSAGE(STATUS "- - - -")
  97. MESSAGE(STATUS "${ARTIS_NAME_COMPLETE} configured successfully")
  98. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  99. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  100. IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  101. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  102. ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  103. IF (ARTIS_HAVE_EXECINFO)
  104. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  105. ENDIF (ARTIS_HAVE_EXECINFO)
  106. IF (Boost_FOUND)
  107. MESSAGE(STATUS "Build with boost..............: yes")
  108. ENDIF (Boost_FOUND)