Skip to content

Commit 4a1719a

Browse files
authored
Default to *not* build tests when we are not the main CMake project (#13)
1 parent 4e80cc2 commit 4a1719a

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

CMakeLists.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@ project(Flibcpp VERSION "${Flibcpp_VERSION}" LANGUAGES CXX Fortran)
1717
#---------------------------------------------------------------------------#
1818
# OPTIONS
1919
#---------------------------------------------------------------------------#
20-
21-
if (FLIBCPP_DEV OR FLIBCPP_BUILD_EXAMPLES OR FLIBCPP_BUILD_TESTS)
22-
set(_DEFAULT_BUILD_TESTING ON)
23-
endif()
24-
2520
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
26-
option(BUILD_TESTING "Enable CTest" ${_DEFAULT_BUILD_TESTING})
2721
option(FLIBCPP_DEV "Default to using development-centered options" OFF)
2822
option(FLIBCPP_BUILD_DOCS "Build documentation with Sphinx" ${FLIBCPP_DEV})
29-
option(FLIBCPP_BUILD_EXAMPLES "Build examples" ON)
30-
option(FLIBCPP_BUILD_TESTS "Build Flibcpp tests" ${BUILD_TESTING})
3123
option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
3224

25+
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
26+
set(_DEFAULT_BUILD_EXAMPLES ON)
27+
endif()
28+
option(FLIBCPP_BUILD_EXAMPLES "Build examples" ${_DEFAULT_BUILD_EXAMPLES})
29+
30+
if (FLIBCPP_DEV)
31+
set(_DEFAULT_BUILD_TESTS ON)
32+
endif()
33+
option(FLIBCPP_BUILD_TESTS "Build Flibcpp tests" ${_DEFAULT_BUILD_TESTS})
34+
35+
if (FLIBCPP_BUILD_TESTS OR FLIBCPP_BUILD_EXAMPLES)
36+
set(_DEFAULT_BUILD_TESTING ON)
37+
endif()
38+
option(BUILD_TESTING "Enable CTest" ${_DEFAULT_BUILD_TESTING})
39+
3340
#---------------------------------------------------------------------------#
3441
# FLAGS
3542
#---------------------------------------------------------------------------#

0 commit comments

Comments
 (0)