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.

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