Skip to content

Commit 46830b9

Browse files
committed
Replace explicit 'enable_testing' macro with CTest module
1 parent cc5cf62 commit 46830b9

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ project(Flibcpp VERSION 0.2.1 LANGUAGES CXX Fortran)
1313
#---------------------------------------------------------------------------#
1414

1515
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
16+
option(BUILD_TESTING "Enable CTest" ${FLIBCPP_DEV})
1617
option(FLIBCPP_DEV "Default to using development-centered options" OFF)
1718
option(FLIBCPP_BUILD_DOCS "Build documentation with Sphinx" ${FLIBCPP_DEV})
1819
option(FLIBCPP_BUILD_EXAMPLES "Build examples" ON)
19-
option(FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV})
20+
option(FLIBCPP_BUILD_TESTS "Build Flibcpp tests" ${BUILD_TESTING})
2021
option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
2122

2223
#---------------------------------------------------------------------------#
@@ -37,7 +38,7 @@ set(FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
3738
"Fortran standard for compiling generated code")
3839

3940
#---------------------------------------------------------------------------#
40-
# SWIG setup
41+
# MODULES TO LOAD
4142
#---------------------------------------------------------------------------#
4243

4344
if (FLIBCPP_USE_SWIG)
@@ -60,6 +61,9 @@ else()
6061
set(FLIBCPP_USE_SWIG FALSE)
6162
endif()
6263

64+
# Enable testing based on BUILD_TESTING flag
65+
include(CTest)
66+
6367
#---------------------------------------------------------------------------#
6468
# VERSIONING
6569
#---------------------------------------------------------------------------#
@@ -249,10 +253,6 @@ install(FILES
249253
# TESTING AND DOCS
250254
#---------------------------------------------------------------------------#
251255

252-
if (FLIBCPP_BUILD_TESTS OR FLIBCPP_BUILD_EXAMPLES)
253-
enable_testing()
254-
endif()
255-
256256
if (FLIBCPP_BUILD_TESTS)
257257
add_subdirectory(test)
258258
endif()

example/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ swig_fortran_add_example(sort
1717
swig_fortran_add_example(vecstr
1818
flc_string flc_vector)
1919

20-
add_test(
21-
NAME examples
22-
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run-examples.sh"
23-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
20+
if (BUILD_TESTING)
21+
add_test(
22+
NAME examples
23+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run-examples.sh"
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
25+
endif()
2426

2527
##---------------------------------------------------------------------------##
2628
## end of common/CMakeLists.txt

0 commit comments

Comments
 (0)