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.

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