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.

CMakeLists.txt 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. cmake_minimum_required(VERSION 3.0)
  2. if(POLICY CMP0077)
  3. cmake_policy(SET CMP0077 NEW)
  4. endif()
  5. ################################################################################
  6. ## DOCTEST
  7. ################################################################################
  8. project(doctest VERSION 2.4.6 LANGUAGES CXX)
  9. # Determine if doctest is built as a subproject (using add_subdirectory) or if it is the main project.
  10. set(MAIN_PROJECT OFF)
  11. if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  12. set(MAIN_PROJECT ON)
  13. endif()
  14. option(DOCTEST_WITH_TESTS "Build tests/examples" ${MAIN_PROJECT})
  15. option(DOCTEST_WITH_MAIN_IN_STATIC_LIB "Build a static lib (cmake target) with a default main entry point" ON)
  16. option(DOCTEST_NO_INSTALL "Skip the installation process" OFF)
  17. option(DOCTEST_USE_STD_HEADERS "Use std headers" OFF)
  18. add_library(${PROJECT_NAME} INTERFACE)
  19. add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
  20. if(NOT CMAKE_VERSION VERSION_LESS 3.8)
  21. target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)
  22. endif()
  23. set(doctest_parts_folder "${CMAKE_CURRENT_SOURCE_DIR}/doctest/parts")
  24. set(doctest_folder "${CMAKE_CURRENT_SOURCE_DIR}/") # in order to have the mpi extension files, not included into the doctest.h single header
  25. if(MAIN_PROJECT)
  26. # use a special hidden version of the header which directly includes the 2 parts - proper reporting of file/line locations during dev
  27. target_include_directories(${PROJECT_NAME} INTERFACE
  28. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/scripts/development_only/>
  29. $<BUILD_INTERFACE:${doctest_parts_folder}>
  30. $<BUILD_INTERFACE:${doctest_folder}>)
  31. # add a custom target that assembles the single header when any of the parts are touched
  32. add_custom_command(
  33. OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h
  34. DEPENDS
  35. ${doctest_parts_folder}/doctest_fwd.h
  36. ${doctest_parts_folder}/doctest.cpp
  37. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/assemble_single_header.cmake
  38. COMMENT "assembling the single header")
  39. add_custom_target(assemble_single_header ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h)
  40. else()
  41. target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>)
  42. endif()
  43. # hack to support building on XCode 6 and 7 - propagate the definition to everything
  44. if(DEFINED DOCTEST_THREAD_LOCAL)
  45. target_compile_definitions(${PROJECT_NAME} INTERFACE
  46. DOCTEST_THREAD_LOCAL=${DOCTEST_THREAD_LOCAL})
  47. endif()
  48. if(DOCTEST_USE_STD_HEADERS)
  49. target_compile_definitions(${PROJECT_NAME} INTERFACE DOCTEST_CONFIG_USE_STD_HEADERS)
  50. endif()