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.

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