Skip to content

Commit 7928b46

Browse files
committed
Simplify flags in CMake script
1 parent 6b04383 commit 7928b46

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

CMakeLists.txt

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ project(Flibcpp VERSION 0.1.0 LANGUAGES CXX Fortran)
1212
# OPTIONS
1313
#---------------------------------------------------------------------------#
1414

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)
1921

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+
#---------------------------------------------------------------------------#
2425

2526
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2627
if (FLIBCPP_DEV)
@@ -32,16 +33,13 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
3233
set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type" FORCE)
3334
endif()
3435

35-
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
36-
3736
set(FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
3837
"Fortran standard for compiling generated code")
3938

4039
#---------------------------------------------------------------------------#
4140
# SWIG setup
4241
#---------------------------------------------------------------------------#
4342

44-
option(FLIBCPP_USE_SWIG "Enable SWIG generation" ${FLIBCPP_DEV})
4543
if (FLIBCPP_USE_SWIG)
4644
find_package(SWIG)
4745
endif()
@@ -50,7 +48,7 @@ if (FLIBCPP_USE_SWIG AND SWIG_FOUND)
5048
# SWIG is requested and available; make sure it's the Fortran fork.
5149
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
5250
include(CheckSWIGFortran)
53-
if (CMAKE_VERSION VERSION_LESS 3.20)
51+
if (CMAKE_VERSION VERSION_LESS 3.99)
5452
# TODO: This is until Fortran support gets added to the upstream cmake script
5553
include(UseSWIGFortran)
5654
else()
@@ -66,7 +64,6 @@ endif()
6664
# VERSIONING
6765
#---------------------------------------------------------------------------#
6866

69-
7067
# Get a possible Git version generated using git-archive (see the .gitattributes
7168
# file)
7269
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/git-version.txt"
@@ -249,29 +246,21 @@ install(FILES
249246
)
250247

251248
#---------------------------------------------------------------------------#
252-
# TESTING
249+
# TESTING AND DOCS
253250
#---------------------------------------------------------------------------#
254251

255-
option(FLIBCPP_BUILD_TESTS "Build unit tests" ${FLIBCPP_DEV})
256-
if (FLIBCPP_BUILD_TESTS)
252+
if (FLIBCPP_BUILD_TESTS OR FLIBCPP_BUILD_EXAMPLES)
257253
enable_testing()
258-
add_subdirectory(test)
259254
endif()
260255

261-
#---------------------------------------------------------------------------#
262-
# EXECUTABLES
263-
#---------------------------------------------------------------------------#
256+
if (FLIBCPP_BUILD_TESTS)
257+
add_subdirectory(test)
258+
endif()
264259

265-
option(FLIBCPP_BUILD_EXAMPLES "Build examples" ON)
266260
if (FLIBCPP_BUILD_EXAMPLES)
267261
add_subdirectory(example)
268262
endif()
269263

270-
#---------------------------------------------------------------------------#
271-
# DOCUMENTATION
272-
#---------------------------------------------------------------------------#
273-
274-
option(FLIBCPP_BUILD_DOCS "Build documentation" ${FLIBCPP_DEV})
275264
if (FLIBCPP_BUILD_DOCS)
276265
add_subdirectory(doc)
277266
endif()

0 commit comments

Comments
 (0)