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.

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