CMakeLists.txt 3.5 KB

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