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.

188 lines
6.0 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. set(BOOST_PROGRAM_OPTIONS_LIBRARY "boost_program_options")
  98. include_directories(${Boost_INCLUDE_DIRS})
  99. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  100. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  101. endif ()
  102. link_directories(${Boost_LIBRARY_DIRS})
  103. endif(Boost_FOUND)
  104. list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen/cmake/")
  105. set(EIGEN3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen)
  106. find_package(Eigen3 REQUIRED)
  107. if (EIGEN3_FOUND)
  108. include_directories(${EIGEN3_INCLUDE_DIR})
  109. endif()
  110. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  111. add_executable(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  112. add_executable(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  113. # Add target link deps for Pantheios
  114. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES} ${BOOST_PROGRAM_OPTIONS_LIBRARY})
  115. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  116. # add a target to generate API documentation with Doxygen
  117. if(DOXYGEN_FOUND)
  118. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  119. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  120. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  121. add_custom_target(doc ALL
  122. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  123. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  124. COMMENT "Generating API documentation with Doxygen" VERBATIM
  125. )
  126. endif(DOXYGEN_FOUND)
  127. if (GTEST_FOUND)
  128. # For make-based builds, defines make target named test.
  129. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  130. enable_testing()
  131. include_directories(${GTEST_INCLUDE_DIRS})
  132. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  133. add_test(
  134. NAME MRMC-tests
  135. COMMAND MRMC-tests
  136. )
  137. if( MSVC ) # VS2012 doesn't support correctly the tuples yet
  138. add_definitions( /D _VARIADIC_MAX=10 )
  139. endif()
  140. endif(GTEST_FOUND)
  141. if (THREADS_FOUND)
  142. include_directories(${THREADS_INCLUDE_DIRS})
  143. target_link_libraries (MRMC-tests ${CMAKE_THREAD_LIBS_INIT})
  144. target_link_libraries (MRMC-cpp ${CMAKE_THREAD_LIBS_INIT})
  145. endif(THREADS_FOUND)
  146. if (DEFINE_UNIX)
  147. add_definitions(-DUNIX)
  148. endif(DEFINE_UNIX)