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.

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