You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
5.9 KiB

  1. cmake_minimum_required (VERSION 2.6)
  2. project (MRMC-cpp CXX C)
  3. # The version number.
  4. set (MRMC_CPP_VERSION_MAJOR 1)
  5. set (MRMC_CPP_VERSION_MINOR 0)
  6. option(DEBUG "Sets whether the DEBUG mode is used" ON)
  7. option(DEFINE_UNIX "Defines the UNIX flag for compilation." OFF)
  8. option(USE_POPCNT "Sets whether the popcnt instruction is going to be used." OFF)
  9. if (DEBUG)
  10. set (CMAKE_BUILD_TYPE "DEBUG")
  11. else()
  12. set (CMAKE_BUILD_TYPE "RELEASE")
  13. endif()
  14. #Configurations for GCC
  15. if(CMAKE_COMPILER_IS_GNUCC)
  16. set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -pedantic")
  17. # Turn on popcnt instruction if possible
  18. if (USE_POPCNT)
  19. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
  20. endif(USE_POPCNT)
  21. endif()
  22. # configure a header file to pass some of the CMake settings
  23. # to the source code
  24. # Base path for test files
  25. set(MRMC_CPP_TESTS_BASE_PATH ${PROJECT_SOURCE_DIR}/test)
  26. configure_file (
  27. "${PROJECT_SOURCE_DIR}/MRMCConfig.h.in"
  28. "${PROJECT_BINARY_DIR}/MRMCConfig.h"
  29. )
  30. # add the binary tree to the search path for include files
  31. # so that we will find TutorialConfig.h
  32. include_directories("${PROJECT_BINARY_DIR}")
  33. # Main Sources
  34. file(GLOB_RECURSE MRMCHeaders ${PROJECT_SOURCE_DIR}/src/*.h)
  35. file(GLOB_RECURSE MRMCSources ${PROJECT_SOURCE_DIR}/src/*.cpp)
  36. # Test Sources
  37. # Note that the tests also need the source files, except the main file!
  38. file(GLOB_RECURSE MRMCTestHeaders ${PROJECT_SOURCE_DIR}/test/*.h)
  39. file(GLOB_RECURSE MRMCTestSources ${PROJECT_SOURCE_DIR}/test/*.cpp ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
  40. # Main Grouping
  41. source_group(Headers FILES ${MRMCHeaders})
  42. source_group(Sources FILES ${MRMCSources})
  43. # Test Grouping
  44. source_group(Headers FILES ${MRMCTestHeaders})
  45. source_group(Sources FILES ${MRMCTestSources})
  46. # Add base folder for better inclusion pathes
  47. include_directories("${PROJECT_SOURCE_DIR}")
  48. include_directories("${PROJECT_SOURCE_DIR}/src")
  49. # temp search path for Pantheios/STLSoft
  50. if (NOT GTEST_INCLUDE_DIR)
  51. set(GTEST_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/include)
  52. endif()
  53. if (NOT STLSOFT_INCLUDE_DIR)
  54. set(STLSOFT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/stlsoft-1.9.116/include)
  55. endif()
  56. if (NOT PANTHEIOS_INCLUDE_DIR)
  57. set(PANTHEIOS_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/pantheios-1.0.1-beta214/include)
  58. endif()
  59. message(STATUS "GTEST Include Dir is: ${GTEST_INCLUDE_DIR}")
  60. #message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  61. list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
  62. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0)
  63. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/pantheios-1.0.1-beta214)
  64. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/gteststlsoft-1.9.116)
  65. #message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  66. # external packages
  67. find_package(GTest REQUIRED)
  68. find_package(Threads REQUIRED)
  69. set(Boost_USE_STATIC_LIBS ON)
  70. set(Boost_USE_MULTITHREADED ON)
  71. set(Boost_USE_STATIC_RUNTIME OFF)
  72. find_package(Boost REQUIRED)
  73. find_package(Doxygen REQUIRED)
  74. find_package(STLSoft REQUIRED)
  75. # STLsoft headers
  76. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/stlsoft-1.9.114")
  77. # Pantheios Logging library
  78. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/pantheios-1.0.1-beta213")
  79. if (STLSOFT_FOUND)
  80. include_directories(${STLSOFT_INCLUDE_DIR})
  81. endif()
  82. find_package(STLSoft REQUIRED)
  83. #Dynamic runtime for Pantheios is configured for dll-files, hence only usable under Windows...
  84. if (WIN32)
  85. set(PANTHEIOS_USE_DYNAMIC_RUNTIME ON)
  86. else()
  87. set(PANTHEIOS_USE_DYNAMIC_RUNTIME OFF)
  88. endif()
  89. find_package(Pantheios REQUIRED COMPONENTS SimpleFrontEnd File)
  90. if (PANTHEIOS_FOUND)
  91. include_directories(${PANTHEIOS_INCLUDE_DIR})
  92. link_directories(${PANTHEIOS_LIBRARY_DIRS})
  93. else()
  94. message(STATUS "NO PANTHEIOS!")
  95. endif()
  96. if(Boost_FOUND)
  97. include_directories(${Boost_INCLUDE_DIRS})
  98. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  99. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  100. endif ()
  101. link_directories(${Boost_LIBRARY_DIRS})
  102. endif(Boost_FOUND)
  103. list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen/cmake/")
  104. set(EIGEN3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen)
  105. find_package(Eigen3 REQUIRED)
  106. if (EIGEN3_FOUND)
  107. include_directories(${EIGEN3_INCLUDE_DIR})
  108. endif()
  109. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  110. add_executable(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  111. add_executable(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  112. # Add target link deps for Pantheios
  113. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES})
  114. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  115. # add a target to generate API documentation with Doxygen
  116. if(DOXYGEN_FOUND)
  117. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  118. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  119. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  120. add_custom_target(doc ALL
  121. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  122. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  123. COMMENT "Generating API documentation with Doxygen" VERBATIM
  124. )
  125. endif(DOXYGEN_FOUND)
  126. if (GTEST_FOUND)
  127. # For make-based builds, defines make target named test.
  128. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  129. enable_testing()
  130. include_directories(${GTEST_INCLUDE_DIRS})
  131. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  132. add_test(
  133. NAME MRMC-tests
  134. COMMAND MRMC-tests
  135. )
  136. if( MSVC ) # VS2012 doesn't support correctly the tuples yet
  137. add_definitions( /D _VARIADIC_MAX=10 )
  138. endif()
  139. endif(GTEST_FOUND)
  140. if (THREADS_FOUND)
  141. include_directories(${THREADS_INCLUDE_DIRS})
  142. target_link_libraries (MRMC-tests ${CMAKE_THREAD_LIBS_INIT})
  143. target_link_libraries (MRMC-cpp ${CMAKE_THREAD_LIBS_INIT})
  144. endif(THREADS_FOUND)
  145. if (DEFINE_UNIX)
  146. add_definitions(-DUNIX)
  147. endif(DEFINE_UNIX)