CMakeLists.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  2. PROJECT(PARADEVS_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_BUILD_TYPE STREQUAL "")
  30. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  31. endif ()
  32. #
  33. # Thread
  34. #
  35. message(STATUS "checking for a (p)thread library")
  36. find_package(Threads REQUIRED)
  37. if (NOT Threads_FOUND)
  38. message(ERROR " failed to found a (p)thread support.")
  39. else ()
  40. message(STATUS " threads support enabled (${CMAKE_THREAD_LIBS_INIT})")
  41. endif ()
  42. #
  43. # Modules
  44. #
  45. INCLUDE(CheckIncludeFileCXX)
  46. INCLUDE(CheckIncludeFile)
  47. INCLUDE(CheckLibraryExists)
  48. INCLUDE(CMakeDetermineCCompiler)
  49. #
  50. # Check libraries with pkgconfig
  51. #
  52. FIND_PACKAGE(PkgConfig REQUIRED)
  53. # FIXME use old-style link directories for now
  54. IF (COMMAND CMAKE_POLICY)
  55. CMAKE_POLICY(SET CMP0003 OLD)
  56. ENDIF (COMMAND CMAKE_POLICY)
  57. PKG_CHECK_MODULES(PARADEVS REQUIRED paradevs-1.0)
  58. PKG_CHECK_MODULES(LIBXML REQUIRED libxml-2.0)
  59. #
  60. # Test the libboost header and libboost-text library.
  61. #
  62. OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
  63. SET(Boost_USE_MULTITHREADED ON)
  64. SET(Boost_USE_STATIC_LIBS OFF)
  65. SET(Boost_NO_SYSTEM_PATHS OFF)
  66. SET(Boost_USE_STATIC_RUNTIME ON)
  67. IF (WIN32)
  68. SET(Boost_THREADAPI "win32")
  69. ENDIF (WIN32)
  70. include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
  71. ${CMAKE_BINARY_DIR})
  72. find_package(MPI REQUIRED)
  73. if (NOT MPI_CXX_FOUND)
  74. message(ERROR " failed to found a C++ compiler with MPI support.")
  75. else()
  76. message(STATUS " MPI support enabled")
  77. include_directories(${MPI_CXX_INCLUDE_PATH})
  78. endif ()
  79. message(STATUS "checking for Boost headers and libraries")
  80. find_package(Boost 1.55 REQUIRED COMPONENTS graph mpi timer serialization
  81. system)
  82. if (NOT Boost_FOUND)
  83. MESSAGE(FATAL_ERROR "The boost graph library is required")
  84. else ()
  85. message(STATUS " Boost found")
  86. include_directories(${Boost_INCLUDE_DIRS})
  87. link_directories(${Boost_LIBRARY_DIRS})
  88. endif ()
  89. #
  90. # Generate the config.h
  91. #
  92. CHECK_INCLUDE_FILE_CXX(cxxabi.h PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  93. CHECK_INCLUDE_FILE_CXX(execinfo.h PARADEVS_HAVE_EXECINFO)
  94. CHECK_INCLUDE_FILE_CXX(signal.h PARADEVS_HAVE_SIGNAL)
  95. #
  96. # Browse the src subdirectory
  97. #
  98. ADD_SUBDIRECTORY(src)
  99. #
  100. # Status
  101. #
  102. MESSAGE(STATUS "- - - -")
  103. MESSAGE(STATUS "${PARADEVS_NAME_COMPLETE} configured successfully")
  104. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  105. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  106. IF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  107. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  108. ENDIF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  109. IF (PARADEVS_HAVE_EXECINFO)
  110. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  111. ENDIF (PARADEVS_HAVE_EXECINFO)
  112. IF (Boost_FOUND)
  113. MESSAGE(STATUS "Build with boost..............: yes")
  114. ENDIF (Boost_FOUND)
  115. MESSAGE(STATUS "- - - -")
  116. # vim:tw=0:ts=8:tw=0:sw=2:sts=2