diff options
author | Dimitrij Mijoski <dmjpp@hotmail.com> | 2019-03-02 19:37:34 +0300 |
---|---|---|
committer | Viktor Kirilov <vik.kirilov@gmail.com> | 2019-03-02 19:37:34 +0300 |
commit | 0dbbd4f0ff6cfc69517e64ffd2fa0ca1e6610b5b (patch) | |
tree | bf2d4efeb9f6f1438b5f252a49af0cc9a12b1885 /CMakeLists.txt | |
parent | a7af1d61f15f46ef7794ae79e0c32bb66a32f2fb (diff) |
Move single header to a separate folder (#187)
* Move single header to a separate folder
It is much better for tests and examples to directly depend on the
original sources as errors and warnings are properly reported.
Previously, errors are warnings were reported against the single include,
but had to be fixed in doctest_fwd.h and doctest.cpp.
* Fix cmake target "playground"
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cfd673c5..5d1a0cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,13 +11,29 @@ option(DOCTEST_WITH_TESTS "Build tests/examples" ON) option(DOCTEST_WITH_MAIN_IN_STATIC_LIB "Build a static lib (cmake target) with a main entry point" ON) option(DOCTEST_NO_INSTALL "Skip the installation process" OFF) + +add_library(${PROJECT_NAME} INTERFACE) +target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>) + # hack to support building on XCode 6 and 7 - propagate the definition to everything if(DEFINED DOCTEST_THREAD_LOCAL) - add_definitions(-DDOCTEST_THREAD_LOCAL=${DOCTEST_THREAD_LOCAL}) + target_compile_definitions(${PROJECT_NAME} INTERFACE + DOCTEST_THREAD_LOCAL=${DOCTEST_THREAD_LOCAL}) endif() -add_library(${PROJECT_NAME} INTERFACE) -target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>) +# add a custom target that assembles the single header when any of the parts are touched + +set(doctest_parts_folder "${CMAKE_CURRENT_SOURCE_DIR}/doctest/parts") + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/single_include/doctest/doctest.h + DEPENDS + ${doctest_parts_folder}/doctest_fwd.h + ${doctest_parts_folder}/doctest.cpp + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/asemble_single_header.cmake + COMMENT "assembling the single header") + +add_custom_target(assemble_single_header ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/single_include/doctest/doctest.h) ################################################################################ ## TESTS/EXAMPLES/HELPERS @@ -25,9 +41,14 @@ target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_C if(${DOCTEST_WITH_MAIN_IN_STATIC_LIB}) include(scripts/cmake/common.cmake) - doctest_add_library(${PROJECT_NAME}_with_main STATIC EXCLUDE_FROM_ALL doctest/parts/doctest.cpp) - target_compile_definitions(${PROJECT_NAME}_with_main PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) - target_link_libraries(${PROJECT_NAME}_with_main PUBLIC ${PROJECT_NAME}) + add_library(${PROJECT_NAME}_with_main STATIC EXCLUDE_FROM_ALL doctest/parts/doctest.cpp) + target_compile_definitions(${PROJECT_NAME}_with_main PRIVATE + DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) + # hack to support building on XCode 6 and 7 - propagate the definition to everything + if(DEFINED DOCTEST_THREAD_LOCAL) + target_compile_definitions(${PROJECT_NAME}_with_main PRIVATE + DOCTEST_THREAD_LOCAL=${DOCTEST_THREAD_LOCAL}) + endif() endif() if(${DOCTEST_WITH_TESTS}) @@ -70,8 +91,9 @@ if (NOT ${DOCTEST_NO_INSTALL}) INCLUDES DESTINATION "${include_install_dir}" ) + # install the single include instead of original sources install( - FILES "doctest/doctest.h" + FILES "single_include/doctest/doctest.h" DESTINATION "${include_install_dir}/doctest" ) |