@@ -12,15 +12,16 @@ project(Flibcpp VERSION 0.1.0 LANGUAGES CXX Fortran)
12
12
# OPTIONS
13
13
#---------------------------------------------------------------------------#
14
14
15
- if (NOT DEFINED (FLIBCPP_DEV ))
16
- set (FLIBCPP_DEV OFF CACHE STRING
17
- "Default to using development-centered options" )
18
- endif ()
15
+ option (FLIBCPP_DEV "Default to using development-centered options" OFF )
16
+ option (FLIBCPP_BUILD_DOCS "Build documentation with Sphinx" ${FLIBCPP_DEV} )
17
+ option (FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV} )
18
+ option (FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV} )
19
+ option (FLIBCPP_BUILD_EXAMPLES "Build examples" ON )
20
+ option (BUILD_SHARED_LIBS "Build shared libraries" ON )
19
21
20
- if (NOT DEFINED (CMAKER_BUILD_SHARED ))
21
- set (FLIBCPP_DEV OFF CACHE STRING
22
- "Default to using development-centered options" )
23
- endif ()
22
+ #---------------------------------------------------------------------------#
23
+ # FLAGS
24
+ #---------------------------------------------------------------------------#
24
25
25
26
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
26
27
if (FLIBCPP_DEV )
@@ -32,16 +33,13 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
32
33
set (CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE} " CACHE STRING "Build type" FORCE )
33
34
endif ()
34
35
35
- option (BUILD_SHARED_LIBS "Build shared libraries" ON )
36
-
37
36
set (FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
38
37
"Fortran standard for compiling generated code" )
39
38
40
39
#---------------------------------------------------------------------------#
41
40
# SWIG setup
42
41
#---------------------------------------------------------------------------#
43
42
44
- option (FLIBCPP_USE_SWIG "Enable SWIG generation" ${FLIBCPP_DEV} )
45
43
if (FLIBCPP_USE_SWIG )
46
44
find_package (SWIG )
47
45
endif ()
@@ -50,7 +48,7 @@ if (FLIBCPP_USE_SWIG AND SWIG_FOUND)
50
48
# SWIG is requested and available; make sure it's the Fortran fork.
51
49
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake" )
52
50
include (CheckSWIGFortran )
53
- if (CMAKE_VERSION VERSION_LESS 3.20 )
51
+ if (CMAKE_VERSION VERSION_LESS 3.99 )
54
52
# TODO: This is until Fortran support gets added to the upstream cmake script
55
53
include (UseSWIGFortran )
56
54
else ()
@@ -66,7 +64,6 @@ endif()
66
64
# VERSIONING
67
65
#---------------------------------------------------------------------------#
68
66
69
-
70
67
# Get a possible Git version generated using git-archive (see the .gitattributes
71
68
# file)
72
69
file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR} /cmake/git-version.txt"
@@ -249,29 +246,21 @@ install(FILES
249
246
)
250
247
251
248
#---------------------------------------------------------------------------#
252
- # TESTING
249
+ # TESTING AND DOCS
253
250
#---------------------------------------------------------------------------#
254
251
255
- option (FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV} )
256
- if (FLIBCPP_BUILD_TESTS )
252
+ if (FLIBCPP_BUILD_TESTS OR FLIBCPP_BUILD_EXAMPLES )
257
253
enable_testing ()
258
- add_subdirectory (test )
259
254
endif ()
260
255
261
- # ---------------------------------------------------------------------------#
262
- # EXECUTABLES
263
- # ---------------------------------------------------------------------------#
256
+ if ( FLIBCPP_BUILD_TESTS )
257
+ add_subdirectory ( test )
258
+ endif ()
264
259
265
- option (FLIBCPP_BUILD_EXAMPLES "Build examples" ON )
266
260
if (FLIBCPP_BUILD_EXAMPLES )
267
261
add_subdirectory (example )
268
262
endif ()
269
263
270
- #---------------------------------------------------------------------------#
271
- # DOCUMENTATION
272
- #---------------------------------------------------------------------------#
273
-
274
- option (FLIBCPP_BUILD_DOCS "Build documentation" ${FLIBCPP_DEV} )
275
264
if (FLIBCPP_BUILD_DOCS )
276
265
add_subdirectory (doc )
277
266
endif ()
0 commit comments