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.

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