blob: c9f2ece17e62d1b4326d7f600025dfb844887aae [file] [log] [blame]
onqtamc7aaa962016-09-10 02:16:57 +03001cmake_minimum_required(VERSION 3.0)
onqtam4a655632016-05-26 14:20:52 +03002
onqtambff67f72017-04-16 20:04:32 +03003################################################################################
4## DOCTEST
5################################################################################
6
7file(READ ${CMAKE_CURRENT_SOURCE_DIR}/scripts/version.txt ver)
8project(doctest VERSION ${ver})
onqtam4a655632016-05-26 14:20:52 +03009
onqtam61954c32017-04-16 17:22:44 +030010option(DOCTEST_WITH_TESTS "Build tests/examples" ON)
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020011
onqtam61954c32017-04-16 17:22:44 +030012add_library(${PROJECT_NAME} INTERFACE)
13target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/doctest/>)
onqtam4a655632016-05-26 14:20:52 +030014
onqtam61954c32017-04-16 17:22:44 +030015################################################################################
16## TESTS/EXAMPLES
17################################################################################
onqtamcc9e8652016-08-02 14:23:38 +030018
onqtam61954c32017-04-16 17:22:44 +030019if(${DOCTEST_WITH_TESTS})
20 include(scripts/cmake/common.cmake)
onqtam98e12af2017-04-16 22:11:21 +030021
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020022 # setup coverage stuff only when COVERALLS_SERVICE_NAME is set (usually on travis CI)
23 if(DEFINED ENV{COVERALLS_SERVICE_NAME})
onqtam61954c32017-04-16 17:22:44 +030024 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/coveralls-cmake/cmake)
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020025 include(Coveralls)
26 coveralls_turn_on_coverage()
27
onqtam61954c32017-04-16 17:22:44 +030028 coveralls_setup("${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h" ON "${CMAKE_CURRENT_SOURCE_DIR}/scripts/coveralls-cmake/cmake")
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020029
onqtam98e12af2017-04-16 22:11:21 +030030 add_subdirectory(examples/all_features)
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020031
32 return()
33 endif()
onqtam98e12af2017-04-16 22:11:21 +030034
onqtam61954c32017-04-16 17:22:44 +030035 file(GLOB subdir_list "${CMAKE_CURRENT_SOURCE_DIR}/examples/*")
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020036 foreach(dir ${subdir_list})
37 if(IS_DIRECTORY ${dir})
38 get_filename_component(DIRNAME ${dir} NAME)
39 add_subdirectory(examples/${DIRNAME})
40 endif()
41 endforeach()
onqtama985f5a2017-04-16 22:48:07 +030042
43 add_subdirectory(scripts/playground)
Giuseppe Robertif3425ae2017-03-28 02:03:50 +020044endif()
Giuseppe Robertie01299b2017-03-26 14:18:59 +020045
onqtam61954c32017-04-16 17:22:44 +030046################################################################################
47## PACKAGE SUPPORT
48################################################################################
49
Giuseppe Robertie01299b2017-03-26 14:18:59 +020050set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
51
52set(include_install_dir "include/doctest/")
53set(config_install_dir "lib/cmake/${PROJECT_NAME}")
54
55set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
56set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
57set(targets_export_name "${PROJECT_NAME}Targets")
58set(namespace "${PROJECT_NAME}::")
59
60include(CMakePackageConfigHelpers)
61write_basic_package_version_file(
Giuseppe Robertic89cf822017-04-12 17:14:17 +020062 "${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion
Giuseppe Robertie01299b2017-03-26 14:18:59 +020063)
64
onqtam08cf7dc2017-04-16 11:37:22 +030065configure_file("scripts/cmake/Config.cmake.in" "${project_config}" @ONLY)
Giuseppe Robertie01299b2017-03-26 14:18:59 +020066
67install(
68 TARGETS ${PROJECT_NAME}
69 EXPORT "${targets_export_name}"
70 INCLUDES DESTINATION "${include_install_dir}"
71)
72
73install(
74 FILES "doctest/doctest.h"
75 DESTINATION "${include_install_dir}"
76)
77
78install(
79 FILES "${project_config}" "${version_config}"
80 DESTINATION "${config_install_dir}"
81)
82
83install(
84 EXPORT "${targets_export_name}"
85 NAMESPACE "${namespace}"
86 DESTINATION "${config_install_dir}"
87)