@@ -12,11 +12,16 @@ project(Flibcpp VERSION 0.2.1 LANGUAGES CXX Fortran)
12
12
# OPTIONS
13
13
#---------------------------------------------------------------------------#
14
14
15
+ if (FLIBCPP_DEV OR FLIBCPP_BUILD_EXAMPLES OR FLIBCPP_BUILD_TESTS)
16
+ set (_DEFAULT_BUILD_TESTING ON )
17
+ endif ()
18
+
15
19
option (BUILD_SHARED_LIBS "Build shared libraries" ON )
20
+ option (BUILD_TESTING "Enable CTest" ${_DEFAULT_BUILD_TESTING} )
16
21
option (FLIBCPP_DEV "Default to using development-centered options" OFF )
17
22
option (FLIBCPP_BUILD_DOCS "Build documentation with Sphinx" ${FLIBCPP_DEV} )
18
23
option (FLIBCPP_BUILD_EXAMPLES "Build examples" ON )
19
- option (FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV } )
24
+ option (FLIBCPP_BUILD_TESTS "Build Flibcpp tests" ${BUILD_TESTING } )
20
25
option (FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV} )
21
26
22
27
#---------------------------------------------------------------------------#
@@ -37,7 +42,7 @@ set(FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
37
42
"Fortran standard for compiling generated code" )
38
43
39
44
#---------------------------------------------------------------------------#
40
- # SWIG setup
45
+ # MODULES TO LOAD
41
46
#---------------------------------------------------------------------------#
42
47
43
48
if (FLIBCPP_USE_SWIG)
60
65
set (FLIBCPP_USE_SWIG FALSE )
61
66
endif ()
62
67
68
+ # Enable testing based on BUILD_TESTING flag
69
+ include (CTest)
70
+
63
71
#---------------------------------------------------------------------------#
64
72
# VERSIONING
65
73
#---------------------------------------------------------------------------#
@@ -72,7 +80,7 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/git-version.txt"
72
80
if (NOT FLIBCPP_VERSION_STRING MATCHES "\\ $Format:" )
73
81
# First line are decorators, second is hash
74
82
list (GET FLIBCPP_VERSION_STRING 0 _tag)
75
- string (REGEX REPLACE ".*, *( tag: *)? " "" _tag "${_tag} " )
83
+ string (REGEX REPLACE "tag: *" "" _tag "${_tag} " )
76
84
list (GET FLIBCPP_VERSION_STRING 1 _hash)
77
85
string (REGEX REPLACE " +" "" _hash "${_hash} " )
78
86
set (FLIBCPP_VERSION_STRING "${_tag} -g${_hash} " )
@@ -249,10 +257,6 @@ install(FILES
249
257
# TESTING AND DOCS
250
258
#---------------------------------------------------------------------------#
251
259
252
- if (FLIBCPP_BUILD_TESTS OR FLIBCPP_BUILD_EXAMPLES)
253
- enable_testing ()
254
- endif ()
255
-
256
260
if (FLIBCPP_BUILD_TESTS)
257
261
add_subdirectory (test )
258
262
endif ()
0 commit comments