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.

154 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. if (NOT GTEST_INCLUDE_DIR)
  38. set(GTEST_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/include)
  39. endif()
  40. if (NOT STLSOFT_INCLUDE_DIR)
  41. set(STLSOFT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/stlsoft-1.9.116/include)
  42. endif()
  43. if (NOT PANTHEIOS_INCLUDE_DIR)
  44. set(PANTHEIOS_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/pantheios-1.0.1-beta214/include)
  45. endif()
  46. message(STATUS "GTEST Include Dir is: ${GTEST_INCLUDE_DIR}")
  47. #message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  48. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
  49. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0)
  50. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/pantheios-1.0.1-beta214)
  51. #list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/resources/3rdparty/gteststlsoft-1.9.116)
  52. #message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
  53. # external packages
  54. find_package(GTest REQUIRED)
  55. find_package(Threads REQUIRED)
  56. set(Boost_USE_STATIC_LIBS ON)
  57. set(Boost_USE_MULTITHREADED ON)
  58. set(Boost_USE_STATIC_RUNTIME OFF)
  59. find_package(Boost REQUIRED)
  60. find_package(Doxygen REQUIRED)
  61. find_package(STLSoft REQUIRED)
  62. # STLsoft headers
  63. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/stlsoft-1.9.114")
  64. # Pantheios Logging library
  65. # include_directories("${PROJECT_SRC_DIR}/resources/3rdParty/pantheios-1.0.1-beta213")
  66. if (STLSOFT_FOUND)
  67. include_directories(${STLSOFT_INCLUDE_DIR})
  68. endif()
  69. find_package(STLSoft REQUIRED)
  70. #Dynamic runtime for Pantheios is configured for dll-files, hence only usable under Windows...
  71. if (WIN32)
  72. set(PANTHEIOS_USE_DYNAMIC_RUNTIME ON)
  73. else()
  74. set(PANTHEIOS_USE_DYNAMIC_RUNTIME OFF)
  75. endif()
  76. find_package(Pantheios REQUIRED COMPONENTS SimpleFrontEnd File)
  77. if (PANTHEIOS_FOUND)
  78. include_directories(${PANTHEIOS_INCLUDE_DIR})
  79. link_directories(${PANTHEIOS_LIBRARY_DIRS})
  80. else()
  81. message(STATUS "NO PANTHEIOS!")
  82. endif()
  83. if(Boost_FOUND)
  84. include_directories(${Boost_INCLUDE_DIRS})
  85. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  86. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  87. endif ()
  88. link_directories(${Boost_LIBRARY_DIRS})
  89. endif(Boost_FOUND)
  90. # must be created AFTER Boost was added because of LINK_DIRECTORIES
  91. add_executable(MRMC-cpp ${MRMCSources} ${MRMCHeaders})
  92. add_executable(MRMC-tests ${MRMCTestSources} ${MRMCTestHeaders})
  93. # Add target link deps for Pantheios
  94. target_link_libraries(MRMC-cpp ${PANTHEIOS_LIBRARIES})
  95. target_link_libraries(MRMC-tests ${PANTHEIOS_LIBRARIES})
  96. # add a target to generate API documentation with Doxygen
  97. if(DOXYGEN_FOUND)
  98. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  99. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  100. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  101. add_custom_target(doc ALL
  102. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  103. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
  104. COMMENT "Generating API documentation with Doxygen" VERBATIM
  105. )
  106. endif(DOXYGEN_FOUND)
  107. if (GTEST_FOUND)
  108. # For make-based builds, defines make target named test.
  109. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  110. enable_testing()
  111. include_directories(${GTEST_INCLUDE_DIRS})
  112. target_link_libraries(MRMC-tests ${GTEST_LIBRARIES})
  113. add_test(
  114. NAME MRMC-tests
  115. COMMAND MRMC-tests
  116. )
  117. if( MSVC ) # VS2012 doesn't support correctly the tuples yet
  118. add_definitions( /D _VARIADIC_MAX=10 )
  119. endif()
  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)