|
8 | 8 | #
|
9 | 9 | # the config file is generatet in the build and install directories
|
10 | 10 |
|
11 |
| -cmake_minimum_required(VERSION 3.10...3.13) |
| 11 | +cmake_minimum_required(VERSION 3.10...3.15) |
12 | 12 | project(PENF VERSION 1.2.1 LANGUAGES Fortran)
|
13 | 13 |
|
14 | 14 | # seach path for additional cmake modules
|
15 | 15 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules)
|
16 | 16 |
|
17 |
| - |
18 | 17 | # set export variables needed for building
|
19 | 18 | set(TARGETS_EXPORT_NAME "${PROJECT_NAME}-targets")
|
20 | 19 | set(NAMESPACE "${PROJECT_NAME}::")
|
21 | 20 |
|
22 |
| - |
23 | 21 | # generate the library and install instructions
|
24 | 22 | add_subdirectory(src/lib)
|
25 | 23 |
|
26 | 24 | # testing
|
27 | 25 | if(${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
28 | 26 | set(main_project TRUE)
|
| 27 | + enable_testing() |
| 28 | + option(BUILD_TESTING "Build the testing tree." ON) |
| 29 | + #include(CTest) |
29 | 30 | else()
|
30 | 31 | set(main_project FALSE)
|
31 |
| -endif() |
32 | 32 |
|
33 |
| -include(CMakeDependentOption) |
34 |
| -cmake_dependent_option(BUILD_TESTING_${PROJECT_NAME} |
35 |
| - "Build the testing tree for project ${PROJECT_NAME}." OFF |
36 |
| - "BUILD_TESTING;NOT main_project" OFF |
37 |
| -) |
| 33 | + # if this is not the main project but BUILD_TESTIG is set to TRUE |
| 34 | + # the tests for this project can be enabled by also setting |
| 35 | + # BUILD_TESTING_${PROJECT_NAME} to TRUE |
| 36 | + include(CMakeDependentOption) |
| 37 | + cmake_dependent_option(BUILD_TESTING_${PROJECT_NAME} |
| 38 | + "Build the testing tree for project ${PROJECT_NAME}." OFF |
| 39 | + "BUILD_TESTING;NOT main_project" OFF |
| 40 | + ) |
| 41 | +endif() |
38 | 42 |
|
39 |
| -if((main_project AND BUILD_TESTING) OR BUILD_TESTING_${PROJECT_NAME}) |
40 |
| - enable_testing() |
| 43 | +if((main_project OR BUILD_TESTING_${PROJECT_NAME}) AND BUILD_TESTING) |
41 | 44 | add_subdirectory(src/tests)
|
42 | 45 | endif()
|
43 | 46 |
|
|
0 commit comments