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.

159 lines
4.9 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. set (CMAKE_CXX_FLAGS "-g")
  7. # configure a header file to pass some of the CMake settings
  8. # to the source code
  9. configure_file (
  10. "${PROJECT_SOURCE_DIR}/src/MRMCConfig.h.in"
  11. "${PROJECT_BINARY_DIR}/MRMCConfig.h"
  12. )
  13. # add the binary tree to the search path for include files
  14. # so that we will find TutorialConfig.h
  15. include_directories("${PROJECT_BINARY_DIR}")
  16. # Main Sources
  17. FILE(GLOB_RECURSE MRMCHeaders ${PROJECT_SOURCE_DIR}/src/*.h)
  18. FILE(GLOB_RECURSE MRMCSources ${PROJECT_SOURCE_DIR}/src/*.cpp)
  19. # Test Sources
  20. # Note that the tests also need the source files, except the main file!
  21. FILE(GLOB_RECURSE MRMCTestHeaders ${PROJECT_SOURCE_DIR}/test/*.h)
  22. FILE(GLOB_RECURSE MRMCTestSources ${PROJECT_SOURCE_DIR}/test/*.cpp ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
  23. # Main Grouping
  24. SOURCE_GROUP(Headers FILES ${MRMCHeaders})
  25. SOURCE_GROUP(Sources FILES ${MRMCSources})
  26. # Test Grouping
  27. SOURCE_GROUP(Headers FILES ${MRMCTestHeaders})
  28. SOURCE_GROUP(Sources FILES ${MRMCTestSources})
  29. # Add base folder for better inclusion pathes
  30. include_directories("${PROJECT_SOURCE_DIR}")
  31. include_directories("${PROJECT_SOURCE_DIR}/src")
  32. # temp search path for Pantheios/STLSoft
  33. message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  34. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
  35. message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  36. # external packages
  37. FIND_PACKAGE(GTest REQUIRED)
  38. FIND_PACKAGE(Threads REQUIRED)
  39. SET(Boost_USE_STATIC_LIBS ON)
  40. SET(Boost_USE_MULTITHREADED ON)
  41. SET(Boost_USE_STATIC_RUNTIME OFF)
  42. FIND_PACKAGE(Boost REQUIRED)
  43. FIND_PACKAGE(Doxygen REQUIRED)
  44. FIND_PACKAGE(STLSoft REQUIRED)
  45. #set(PANTHEIOS_USE_DYNAMIC_RUNTIME ON)
  46. FIND_PACKAGE(Pantheios REQUIRED COMPONENTS SimpleFrontEnd File)
  47. # STLsoft headers
  48. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/stlsoft-1.9.114")
  49. # Pantheios Logging library
  50. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/pantheios-1.0.1-beta213")
  51. if (STLSOFT_FOUND)
  52. message(STATUS "STLSoft found")
  53. INCLUDE_DIRECTORIES(${STLSOFT_INCLUDE_DIR})
  54. endif()
  55. FIND_PACKAGE(STLSoft REQUIRED)
  56. #Dynamic runtime for Pantheios is configured for dll-files, hence only usable under Windows...
  57. if (WIN32)
  58. set(PANTHEIOS_USE_DYNAMIC_RUNTIME ON)
  59. else()
  60. set(PANTHEIOS_USE_DYNAMIC_RUNTIME OFF)
  61. endif()
  62. FIND_PACKAGE(Pantheios REQUIRED COMPONENTS SimpleFrontEnd File)
  63. # STLsoft headers
  64. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/stlsoft-1.9.114")
  65. # Pantheios Logging library
  66. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/pantheios-1.0.1-beta213")
  67. if (STLSOFT_FOUND)
  68. message(STATUS "STLSoft found")
  69. INCLUDE_DIRECTORIES(${STLSOFT_INCLUDE_DIR})
  70. endif()
  71. IF (PANTHEIOS_FOUND)
  72. message(STATUS "Pantheios found")
  73. INCLUDE_DIRECTORIES(${PANTHEIOS_INCLUDE_DIR})
  74. LINK_DIRECTORIES(${PANTHEIOS_LIBRARY_DIRS})
  75. else()
  76. message(STATUS "NO PANTHEIOS!")
  77. ENDIF()
  78. IF (PANTHEIOS_FOUND)
  79. message(STATUS "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. message(STATUS "Boost_LIBRARY_DIRS was empty, setting to ${Boost_LIBRARY_DIRS}")
  90. endif ()
  91. link_directories(${Boost_LIBRARY_DIRS})
  92. endif(Boost_FOUND)
  93. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  94. ADD_EXECUTABLE(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  95. ADD_EXECUTABLE(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  96. # Add target link deps for Pantheios
  97. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES})
  98. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  99. # add a target to generate API documentation with Doxygen
  100. if(DOXYGEN_FOUND)
  101. SET(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  102. STRING(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  103. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  104. add_custom_target(doc ALL
  105. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  106. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  107. COMMENT "Generating API documentation with Doxygen" VERBATIM
  108. )
  109. endif(DOXYGEN_FOUND)
  110. if (GTEST_FOUND)
  111. # For make-based builds, defines make target named test.
  112. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  113. enable_testing()
  114. include_directories(${GTEST_INCLUDE_DIRS})
  115. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  116. add_test(
  117. NAME MRMC-tests
  118. COMMAND MRMC-tests
  119. )
  120. endif(GTEST_FOUND)
  121. if (THREADS_FOUND)
  122. include_directories(${THREADS_INCLUDE_DIRS})
  123. target_link_libraries (MRMC-tests ${CMAKE_THREAD_LIBS_INIT})
  124. target_link_libraries (MRMC-cpp ${CMAKE_THREAD_LIBS_INIT})
  125. endif(THREADS_FOUND)