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.

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