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.

158 lines
5.1 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. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  93. add_executable(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  94. add_executable(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  95. # Add target link deps for Pantheios
  96. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES})
  97. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  98. # add a target to generate API documentation with Doxygen
  99. if(DOXYGEN_FOUND)
  100. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  101. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  102. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  103. add_custom_target(doc ALL
  104. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  105. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  106. COMMENT "Generating API documentation with Doxygen" VERBATIM
  107. )
  108. endif(DOXYGEN_FOUND)
  109. if (GTEST_FOUND)
  110. # For make-based builds, defines make target named test.
  111. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  112. enable_testing()
  113. include_directories(${GTEST_INCLUDE_DIRS})
  114. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  115. add_test(
  116. NAME MRMC-tests
  117. COMMAND MRMC-tests
  118. )
  119. if( MSVC ) # VS2012 doesn't support correctly the tuples yet
  120. add_definitions( /D _VARIADIC_MAX=10 )
  121. endif()
  122. endif(GTEST_FOUND)
  123. if (THREADS_FOUND)
  124. include_directories(${THREADS_INCLUDE_DIRS})
  125. target_link_libraries (MRMC-tests ${CMAKE_THREAD_LIBS_INIT})
  126. target_link_libraries (MRMC-cpp ${CMAKE_THREAD_LIBS_INIT})
  127. endif(THREADS_FOUND)