CMakeLists.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  2. PROJECT(ARTIS_ADDONS CXX C)
  3. ENABLE_TESTING()
  4. SET(ARTIS_ADDONS_MAJOR 1)
  5. SET(ARTIS_ADDONS_MINOR 0)
  6. SET(ARTIS_ADDONS_PATCH 0)
  7. SET(ARTIS_ADDONS_EXTRA "-dev")
  8. SET(ARTIS_ADDONS_VERSION "${ARTIS_ADDONS_MAJOR}.${ARTIS_ADDONS_MINOR}.${ARTIS_ADDONS_PATCH}")
  9. SET(ARTIS_ADDONS_VERSION_SHORT "${ARTIS_ADDONS_MAJOR}.${ARTIS_ADDONS_MINOR}")
  10. SET(ARTIS_ADDONS_NAME "artis-addons")
  11. SET(ARTIS_ADDONS_NAME_VERSION "${ARTIS_ADDONS_NAME}-${ARTIS_ADDONS_VERSION}")
  12. SET(ARTIS_ADDONS_LOCALE_NAME "${ARTIS_ADDONS_NAME}-${ARTIS_ADDONS_MAJOR}-${ARTIS_ADDONS_MINOR}")
  13. IF ("${ARTIS_ADDONS_EXTRA}" STREQUAL "")
  14. SET(ARTIS_ADDONS_COMPLETE "${ARTIS_ADDONS_MAJOR}.${ARTIS_ADDONS_MINOR}.${ARTIS_ADDONS_PATCH}")
  15. ELSE ("${ARTIS_ADDONS_EXTRA}" STREQUAL "")
  16. SET(ARTIS_ADDONS_COMPLETE "${ARTIS_ADDONS_MAJOR}.${ARTIS_ADDONS_MINOR}.${ARTIS_ADDONS_PATCH}-${ARTIS_ADDONS_EXTRA}")
  17. ENDIF ("${ARTIS_ADDONS_EXTRA}" STREQUAL "")
  18. SET(ARTIS_ADDONS_NAME_COMPLETE "${ARTIS_ADDONS_NAME}-${ARTIS_ADDONS_COMPLETE}")
  19. #
  20. # Installation variables
  21. #
  22. SET(ARTIS_ADDONS_LIBRARY_DIRS "lib/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}")
  23. SET(ARTIS_ADDONS_INCLUDE_DIRS "include/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}/artis-addons")
  24. SET(ARTIS_ADDONS_INCLUDE_DIR "include/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}")
  25. SET(ARTIS_ADDONS_MANPAGE_PATH "share/man/man1")
  26. SET(ARTIS_ADDONS_SHARE_DIRS "share/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}")
  27. #
  28. # Append the library version information to the library target
  29. # properties.
  30. #
  31. SET (ARTIS_ADDONS_LIBRARY_PROPERTIES VERSION 0)
  32. #
  33. # CPack configuration
  34. #
  35. INCLUDE(CMakeCPack.cmake)
  36. #
  37. # Debug mode
  38. #
  39. IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR
  40. ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
  41. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
  42. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -Wall -Wextra -std=c++11")
  43. IF (UNIX)
  44. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
  45. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  46. ENDIF (UNIX)
  47. ENDIF ()
  48. if (CMAKE_BUILD_TYPE STREQUAL "")
  49. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  50. endif ()
  51. #
  52. # Thread
  53. #
  54. message(STATUS "checking for a (p)thread library")
  55. find_package(Threads REQUIRED)
  56. if (NOT Threads_FOUND)
  57. message(ERROR " failed to found a (p)thread support.")
  58. else ()
  59. message(STATUS " threads support enabled (${CMAKE_THREAD_LIBS_INIT})")
  60. endif ()
  61. #
  62. # Modules
  63. #
  64. INCLUDE(CheckIncludeFileCXX)
  65. INCLUDE(CheckIncludeFile)
  66. INCLUDE(CheckLibraryExists)
  67. INCLUDE(CMakeDetermineCCompiler)
  68. #
  69. # Check libraries with pkgconfig
  70. #
  71. FIND_PACKAGE(PkgConfig REQUIRED)
  72. PKG_CHECK_MODULES(ARTIS REQUIRED artis-star-1.0)
  73. #
  74. # Test the libboost header and libboost-text library.
  75. #
  76. OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
  77. SET(Boost_USE_MULTITHREADED ON)
  78. SET(Boost_USE_STATIC_LIBS OFF)
  79. SET(Boost_NO_SYSTEM_PATHS OFF)
  80. SET(Boost_USE_STATIC_RUNTIME ON)
  81. IF (WIN32)
  82. SET(Boost_THREADAPI "win32")
  83. ENDIF (WIN32)
  84. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR})
  85. find_package(MPI REQUIRED)
  86. if (NOT MPI_CXX_FOUND)
  87. message(ERROR " failed to found a C++ compiler with MPI support.")
  88. else ()
  89. message(STATUS " MPI support enabled")
  90. include_directories(${MPI_CXX_INCLUDE_PATH})
  91. endif ()
  92. message(STATUS "checking for Boost headers and libraries")
  93. find_package(Boost 1.55 REQUIRED COMPONENTS graph mpi timer serialization
  94. system)
  95. if (NOT Boost_FOUND)
  96. MESSAGE(FATAL_ERROR "The boost graph library is required")
  97. else ()
  98. message(STATUS " Boost found")
  99. include_directories(${Boost_INCLUDE_DIRS})
  100. link_directories(${Boost_LIBRARY_DIRS})
  101. endif ()
  102. #
  103. # Generate the config.h
  104. #
  105. CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
  106. CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
  107. CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
  108. #
  109. # Generate the artis.pc pkg-config file.
  110. #
  111. SET(ARTIS_ADDONS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
  112. SET(ARTIS_ADDONS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
  113. SET(ARTIS_ADDONS_PKGCONFIG_LIBDIR "lib")
  114. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis-addons.pc.in
  115. ${ARTIS_ADDONS_BINARY_DIR}/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}.pc @ONLY)
  116. INSTALL(FILES ${ARTIS_ADDONS_BINARY_DIR}/artis-addons-${ARTIS_ADDONS_VERSION_SHORT}.pc
  117. DESTINATION lib/pkgconfig)
  118. #
  119. # Browse the src subdirectory
  120. #
  121. ADD_SUBDIRECTORY(src)
  122. #
  123. # Status
  124. #
  125. MESSAGE(STATUS "- - - -")
  126. MESSAGE(STATUS "${ARTIS_ADDONS_NAME} configured successfully")
  127. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  128. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  129. IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  130. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  131. ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  132. IF (ARTIS_HAVE_EXECINFO)
  133. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  134. ENDIF (ARTIS_HAVE_EXECINFO)
  135. IF (Boost_FOUND)
  136. MESSAGE(STATUS "Build with boost..............: yes")
  137. ENDIF (Boost_FOUND)
  138. MESSAGE(STATUS "- - - -")