Skip to content

Commit 481d793

Browse files
committed
Adds option to jsonfortran compilation library
1 parent 94f7176 commit 481d793

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
# this software. The contributing author, Izaak Beekman, retains all
1010
# rights permitted by the terms of the JSON-Fortran license.
1111

12-
cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR )
12+
cmake_minimum_required ( VERSION 3.18 FATAL_ERROR )
13+
14+
option (JSONFORTRAN_ENABLE_DOC_GENERATION "Enable doc generation" OFF)
15+
option (JSONFORTRAN_ENABLE_TESTS "Enable tests" OFF)
16+
option (JSONFORTRAN_STATIC_LIBRARY_ONLY "Generate only static library" ON)
1317

1418
# Use MSVS folders to organize projects on windows
1519
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -174,8 +178,12 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM)
174178
add_library ( ${LIB_NAME} SHARED $<TARGET_OBJECTS:${LIB_NAME}-obj> )
175179
add_library ( ${LIB_NAME}-static STATIC $<TARGET_OBJECTS:${LIB_NAME}-obj> )
176180
else()
177-
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
181+
if (JSONFORTRAN_STATIC_LIBRARY_ONLY)
182+
add_library ( ${LIB_NAME} STATIC ${JF_LIB_SRCS} )
178183
add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} )
184+
else()
185+
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
186+
endif()
179187
endif()
180188

181189
if(JSON_FORTRAN_USE_OpenCoarrays)
@@ -227,6 +235,10 @@ set_target_properties ( ${LIB_NAME}
227235
#-------------------------------------
228236
# Build the documentation with FORD
229237
#-------------------------------------
238+
if (JSONFORTRAN_ENABLE_DOC_GENERATION)
239+
set(SKIP_DOC_GEN FALSE)
240+
endif ()
241+
230242
set ( SKIP_DOC_GEN FALSE CACHE BOOL
231243
"Disable building the API documentation with FORD" )
232244
if ( NOT SKIP_DOC_GEN )
@@ -301,6 +313,9 @@ endif ()
301313
#--------------------------
302314
# Handle test related stuff
303315
#--------------------------
316+
if (JSONFORTRAN_ENABLE_TESTS)
317+
set (ENABLE_TESTS FALSE)
318+
endif ()
304319
set ( ENABLE_TESTS TRUE CACHE BOOL
305320
"Enable the JSON-Fortran tests." )
306321

0 commit comments

Comments
 (0)