onqtam | c7aaa96 | 2016-09-10 02:16:57 +0300 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.0) |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 2 | |
onqtam | bff67f7 | 2017-04-16 20:04:32 +0300 | [diff] [blame^] | 3 | ################################################################################ |
| 4 | ## DOCTEST |
| 5 | ################################################################################ |
| 6 | |
| 7 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/scripts/version.txt ver) |
| 8 | project(doctest VERSION ${ver}) |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 9 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 10 | option(DOCTEST_WITH_TESTS "Build tests/examples" ON) |
Giuseppe Roberti | f3425ae | 2017-03-28 02:03:50 +0200 | [diff] [blame] | 11 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 12 | add_library(${PROJECT_NAME} INTERFACE) |
| 13 | target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/doctest/>) |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 14 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 15 | ################################################################################ |
| 16 | ## TESTS/EXAMPLES |
| 17 | ################################################################################ |
onqtam | cc9e865 | 2016-08-02 14:23:38 +0300 | [diff] [blame] | 18 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 19 | if(${DOCTEST_WITH_TESTS}) |
| 20 | include(scripts/cmake/common.cmake) |
| 21 | |
Giuseppe Roberti | f3425ae | 2017-03-28 02:03:50 +0200 | [diff] [blame] | 22 | # setup coverage stuff only when COVERALLS_SERVICE_NAME is set (usually on travis CI) |
| 23 | if(DEFINED ENV{COVERALLS_SERVICE_NAME}) |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 24 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/coveralls-cmake/cmake) |
Giuseppe Roberti | f3425ae | 2017-03-28 02:03:50 +0200 | [diff] [blame] | 25 | include(Coveralls) |
| 26 | coveralls_turn_on_coverage() |
| 27 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 28 | coveralls_setup("${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h" ON "${CMAKE_CURRENT_SOURCE_DIR}/scripts/coveralls-cmake/cmake") |
Giuseppe Roberti | f3425ae | 2017-03-28 02:03:50 +0200 | [diff] [blame] | 29 | |
| 30 | add_subdirectory(scripts/code_coverage_source) |
| 31 | |
| 32 | return() |
| 33 | endif() |
| 34 | |
onqtam | b478ca6 | 2016-08-16 07:22:15 +0300 | [diff] [blame] | 35 | add_subdirectory(scripts/code_coverage_source) |
onqtam | 4a65563 | 2016-05-26 14:20:52 +0300 | [diff] [blame] | 36 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 37 | file(GLOB subdir_list "${CMAKE_CURRENT_SOURCE_DIR}/examples/*") |
Giuseppe Roberti | f3425ae | 2017-03-28 02:03:50 +0200 | [diff] [blame] | 38 | foreach(dir ${subdir_list}) |
| 39 | if(IS_DIRECTORY ${dir}) |
| 40 | get_filename_component(DIRNAME ${dir} NAME) |
| 41 | add_subdirectory(examples/${DIRNAME}) |
| 42 | endif() |
| 43 | endforeach() |
| 44 | endif() |
Giuseppe Roberti | e01299b | 2017-03-26 14:18:59 +0200 | [diff] [blame] | 45 | |
onqtam | 61954c3 | 2017-04-16 17:22:44 +0300 | [diff] [blame] | 46 | ################################################################################ |
| 47 | ## PACKAGE SUPPORT |
| 48 | ################################################################################ |
| 49 | |
Giuseppe Roberti | e01299b | 2017-03-26 14:18:59 +0200 | [diff] [blame] | 50 | set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") |
| 51 | |
| 52 | set(include_install_dir "include/doctest/") |
| 53 | set(config_install_dir "lib/cmake/${PROJECT_NAME}") |
| 54 | |
| 55 | set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") |
| 56 | set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") |
| 57 | set(targets_export_name "${PROJECT_NAME}Targets") |
| 58 | set(namespace "${PROJECT_NAME}::") |
| 59 | |
| 60 | include(CMakePackageConfigHelpers) |
| 61 | write_basic_package_version_file( |
Giuseppe Roberti | c89cf82 | 2017-04-12 17:14:17 +0200 | [diff] [blame] | 62 | "${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion |
Giuseppe Roberti | e01299b | 2017-03-26 14:18:59 +0200 | [diff] [blame] | 63 | ) |
| 64 | |
onqtam | 08cf7dc | 2017-04-16 11:37:22 +0300 | [diff] [blame] | 65 | configure_file("scripts/cmake/Config.cmake.in" "${project_config}" @ONLY) |
Giuseppe Roberti | e01299b | 2017-03-26 14:18:59 +0200 | [diff] [blame] | 66 | |
| 67 | install( |
| 68 | TARGETS ${PROJECT_NAME} |
| 69 | EXPORT "${targets_export_name}" |
| 70 | INCLUDES DESTINATION "${include_install_dir}" |
| 71 | ) |
| 72 | |
| 73 | install( |
| 74 | FILES "doctest/doctest.h" |
| 75 | DESTINATION "${include_install_dir}" |
| 76 | ) |
| 77 | |
| 78 | install( |
| 79 | FILES "${project_config}" "${version_config}" |
| 80 | DESTINATION "${config_install_dir}" |
| 81 | ) |
| 82 | |
| 83 | install( |
| 84 | EXPORT "${targets_export_name}" |
| 85 | NAMESPACE "${namespace}" |
| 86 | DESTINATION "${config_install_dir}" |
| 87 | ) |