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.

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