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.

120 lines
3.7 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. # configure a header file to pass some of the CMake settings
  7. # to the source code
  8. configure_file (
  9. "${PROJECT_SOURCE_DIR}/src/MRMCConfig.h.in"
  10. "${PROJECT_BINARY_DIR}/MRMCConfig.h"
  11. )
  12. # add the binary tree to the search path for include files
  13. # so that we will find TutorialConfig.h
  14. include_directories("${PROJECT_BINARY_DIR}")
  15. # Main Sources
  16. FILE(GLOB_RECURSE MRMCHeaders ${PROJECT_SOURCE_DIR}/src/*.h)
  17. FILE(GLOB_RECURSE MRMCSources ${PROJECT_SOURCE_DIR}/src/*.cpp)
  18. # Test Sources
  19. FILE(GLOB_RECURSE MRMCTestHeaders ${PROJECT_SOURCE_DIR}/test/*.h)
  20. FILE(GLOB_RECURSE MRMCTestSources ${PROJECT_SOURCE_DIR}/test/*.cpp)
  21. # Main Grouping
  22. SOURCE_GROUP(Headers FILES ${MRMCHeaders})
  23. SOURCE_GROUP(Sources FILES ${MRMCSources})
  24. # Test Grouping
  25. SOURCE_GROUP(Headers FILES ${MRMCTestHeaders})
  26. SOURCE_GROUP(Sources FILES ${MRMCTestSources})
  27. # Add base folder for better inclusion pathes
  28. include_directories("${PROJECT_SOURCE_DIR}")
  29. include_directories("${PROJECT_SOURCE_DIR}/src")
  30. # temp search path for Pantheios/STLSoft
  31. message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  32. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
  33. message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  34. # external packages
  35. FIND_PACKAGE(GTest REQUIRED)
  36. find_package(Threads REQUIRED)
  37. SET(Boost_USE_STATIC_LIBS ON)
  38. SET(Boost_USE_MULTITHREADED ON)
  39. SET(Boost_USE_STATIC_RUNTIME OFF)
  40. FIND_PACKAGE(Boost REQUIRED)
  41. FIND_PACKAGE(Doxygen REQUIRED)
  42. FIND_PACKAGE(STLSoft REQUIRED)
  43. set(PANTHEIOS_USE_DYNAMIC_RUNTIME ON)
  44. FIND_PACKAGE(Pantheios REQUIRED COMPONENTS SimpleFrontEnd File)
  45. # STLsoft headers
  46. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/stlsoft-1.9.114")
  47. # Pantheios Logging library
  48. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/pantheios-1.0.1-beta213")
  49. if (STLSOFT_FOUND)
  50. message(STATUS "STLSoft found")
  51. INCLUDE_DIRECTORIES(${STLSOFT_INCLUDE_DIR})
  52. endif()
  53. IF (PANTHEIOS_FOUND)
  54. message(STATUS "Pantheios found")
  55. INCLUDE_DIRECTORIES(${PANTHEIOS_INCLUDE_DIR})
  56. LINK_DIRECTORIES(${PANTHEIOS_LIBRARY_DIRS})
  57. else()
  58. message(STATUS "NO PANTHEIOS!")
  59. ENDIF()
  60. if(Boost_FOUND)
  61. include_directories(${Boost_INCLUDE_DIRS})
  62. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  63. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  64. message(STATUS "Boost_LIBRARY_DIRS was empty, setting to ${Boost_LIBRARY_DIRS}")
  65. endif ()
  66. link_directories(${Boost_LIBRARY_DIRS})
  67. endif(Boost_FOUND)
  68. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  69. ADD_EXECUTABLE(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  70. ADD_EXECUTABLE(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  71. # Add target link deps for Pantheios
  72. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES})
  73. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  74. # add a target to generate API documentation with Doxygen
  75. if(DOXYGEN_FOUND)
  76. SET(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  77. STRING(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  78. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  79. add_custom_target(doc ALL
  80. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  81. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  82. COMMENT "Generating API documentation with Doxygen" VERBATIM
  83. )
  84. endif(DOXYGEN_FOUND)
  85. if (GTEST_FOUND)
  86. # For make-based builds, defines make target named test.
  87. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  88. enable_testing()
  89. include_directories(${GTEST_INCLUDE_DIRS})
  90. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  91. add_test(
  92. NAME MRMC-tests
  93. COMMAND MRMC-tests
  94. )
  95. endif(GTEST_FOUND)