CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  2. PROJECT(ARTIS_TEST CXX C)
  3. ENABLE_TESTING()
  4. SET(MODEL_MAJOR 0)
  5. SET(MODEL_MINOR 1)
  6. SET(MODEL_PATCH 0)
  7. SET(MODEL_EXTRA "-dev")
  8. IF ("${MODEL_EXTRA}" STREQUAL "")
  9. SET(MODEL_NAME "${PROJECT_NAME}-${MODEL_MAJOR}.${MODEL_MINOR}.${MODEL_PATCH}")
  10. ELSE ("${MODEL_EXTRA}" STREQUAL "")
  11. SET(MODEL_NAME "${PROJECT_NAME}-${MODEL_MAJOR}.${MODEL_MINOR}.${MODEL_PATCH}${MODEL_EXTRA}")
  12. ENDIF ("${MODEL_EXTRA}" STREQUAL "")
  13. #
  14. # CPack configuration
  15. #
  16. INCLUDE(CMakeCPack.cmake)
  17. #
  18. # Debug mode
  19. #
  20. IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR
  21. ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
  22. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
  23. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -Wall -Wextra -std=c++11")
  24. IF (UNIX)
  25. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
  26. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  27. ENDIF (UNIX)
  28. ENDIF ()
  29. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  30. add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
  31. add_link_options(-fprofile-instr-generate)
  32. #Uncomment in case of linker errors
  33. #link_libraries(clang_rt.profile-x86_64)
  34. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  35. add_compile_options(--coverage)
  36. #Uncomment in case of linker errors
  37. link_libraries(gcov)
  38. endif ()
  39. if (CMAKE_BUILD_TYPE STREQUAL "")
  40. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  41. endif ()
  42. #
  43. # Thread
  44. #
  45. message(STATUS "checking for a (p)thread library")
  46. find_package(Threads REQUIRED)
  47. if (NOT Threads_FOUND)
  48. message(ERROR " failed to found a (p)thread support.")
  49. else ()
  50. message(STATUS " threads support enabled (${CMAKE_THREAD_LIBS_INIT})")
  51. endif ()
  52. #
  53. # Modules
  54. #
  55. INCLUDE(CheckIncludeFileCXX)
  56. INCLUDE(CheckIncludeFile)
  57. INCLUDE(CheckLibraryExists)
  58. INCLUDE(CMakeDetermineCCompiler)
  59. #
  60. # Check libraries with pkgconfig
  61. #
  62. FIND_PACKAGE(PkgConfig REQUIRED)
  63. PKG_CHECK_MODULES(ARTIS REQUIRED artis-star-1.0)
  64. #
  65. # Test the libboost header and libboost-text library.
  66. #
  67. OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
  68. SET(Boost_USE_MULTITHREADED ON)
  69. SET(Boost_USE_STATIC_LIBS OFF)
  70. SET(Boost_NO_SYSTEM_PATHS OFF)
  71. SET(Boost_USE_STATIC_RUNTIME ON)
  72. IF (WIN32)
  73. SET(Boost_THREADAPI "win32")
  74. ENDIF (WIN32)
  75. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR})
  76. find_package(MPI REQUIRED)
  77. if (NOT MPI_CXX_FOUND)
  78. message(ERROR " failed to found a C++ compiler with MPI support.")
  79. else ()
  80. message(STATUS " MPI support enabled")
  81. include_directories(${MPI_CXX_INCLUDE_PATH})
  82. endif ()
  83. message(STATUS "checking for Boost headers and libraries")
  84. find_package(Boost 1.55 REQUIRED COMPONENTS graph mpi timer serialization
  85. system)
  86. if (NOT Boost_FOUND)
  87. MESSAGE(FATAL_ERROR "The boost graph library is required")
  88. else ()
  89. message(STATUS " Boost found")
  90. include_directories(${Boost_INCLUDE_DIRS})
  91. link_directories(${Boost_LIBRARY_DIRS})
  92. endif ()
  93. #
  94. # Generate the config.h
  95. #
  96. CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
  97. CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
  98. CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
  99. #
  100. # Browse the src subdirectory
  101. #
  102. ADD_SUBDIRECTORY(src)
  103. #
  104. # Status
  105. #
  106. MESSAGE(STATUS "- - - -")
  107. MESSAGE(STATUS "${ARTIS_NAME_COMPLETE} configured successfully")
  108. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  109. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  110. IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  111. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  112. ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  113. IF (ARTIS_HAVE_EXECINFO)
  114. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  115. ENDIF (ARTIS_HAVE_EXECINFO)
  116. IF (Boost_FOUND)
  117. MESSAGE(STATUS "Build with boost..............: yes")
  118. ENDIF (Boost_FOUND)
  119. MESSAGE(STATUS "- - - -")