@@ -74,7 +74,7 @@ endif()
74
74
# Get version (semantic versioning)
75
75
# C.F. semver.org
76
76
#----------------------------------
77
- file ( STRINGS "${CMAKE_SOURCE_DIR } /.VERSION" VERSION )
77
+ file ( STRINGS "${PROJECT_SOURCE_DIR } /.VERSION" VERSION )
78
78
string ( REPLACE "." ";" VERSION_LIST ${VERSION} )
79
79
list (GET VERSION_LIST 0 VERSION_MAJOR)
80
80
list (GET VERSION_LIST 1 VERSION_MINOR)
@@ -92,13 +92,13 @@ set ( JF_LIB_SRCS src/json_kinds.F90
92
92
src/json_file_module.F90
93
93
src/json_module.F90 )
94
94
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" )
95
- set ( JF_TEST_UCS4_SUPPORT_SRC "${CMAKE_SOURCE_DIR } /src/tests/introspection/test_iso_10646_support.f90" )
95
+ set ( JF_TEST_UCS4_SUPPORT_SRC "${PROJECT_SOURCE_DIR } /src/tests/introspection/test_iso_10646_support.f90" )
96
96
97
97
#-----------------------------------------
98
98
# Collect all the mod files into their own
99
99
# directory to ease installation issues
100
100
#-----------------------------------------
101
- set ( MODULE_DIR "${CMAKE_BINARY_DIR } /include" )
101
+ set ( MODULE_DIR "${PROJECT_BINARY_DIR } /include" )
102
102
103
103
#-------------------------------------
104
104
# Define where our files get installed
@@ -109,7 +109,7 @@ set ( USE_GNU_INSTALL_CONVENTION FALSE
109
109
110
110
# Set the package name to be specific to the compiler used, so that
111
111
# versions compiled with different compilers can be installed in parallel
112
- string ( TOLOWER ${CMAKE_PROJECT_NAME } -${CMAKE_Fortran_COMPILER_ID} PACKAGE_NAME )
112
+ string ( TOLOWER ${PROJECT_NAME } -${CMAKE_Fortran_COMPILER_ID} PACKAGE_NAME )
113
113
set ( PACKAGE_VERSION "${PACKAGE_NAME} -${VERSION} " )
114
114
115
115
if (USE_GNU_INSTALL_CONVENTION)
@@ -153,7 +153,7 @@ set ( ENABLE_UNICODE FALSE CACHE BOOL
153
153
"Enable unicode/UCS4 support" )
154
154
if ( ENABLE_UNICODE )
155
155
try_run ( UCS4_TEST_RUNS UCS4_TEST_COMPILES
156
- ${CMAKE_BINARY_DIR } /bin ${JF_TEST_UCS4_SUPPORT_SRC} )
156
+ ${PROJECT_BINARY_DIR } /bin ${JF_TEST_UCS4_SUPPORT_SRC} )
157
157
if (UCS4_TEST_RUNS EQUAL 0)
158
158
add_definitions (-DUSE_UCS4)
159
159
else ()
@@ -166,7 +166,7 @@ endif ()
166
166
# Build a shared and static library by default
167
167
#---------------------------------------------
168
168
169
- set ( LIB_NAME ${CMAKE_PROJECT_NAME } )
169
+ set ( LIB_NAME ${PROJECT_NAME } )
170
170
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
171
171
add_library ( ${LIB_NAME} -static STATIC ${JF_LIB_SRCS} )
172
172
@@ -184,7 +184,7 @@ set_target_properties ( ${LIB_NAME}-static
184
184
PREFIX lib
185
185
endif ()
186
186
VERSION ${VERSION}
187
- ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR } /lib
187
+ ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR } /lib
188
188
Fortran_MODULE_DIRECTORY ${MODULE_DIR} )
189
189
set_target_properties ( ${LIB_NAME}
190
190
PROPERTIES
@@ -194,8 +194,8 @@ set_target_properties ( ${LIB_NAME}
194
194
endif ()
195
195
SOVERSION ${VERSION_MAJOR} .${VERSION_MINOR}
196
196
VERSION ${VERSION}
197
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR } /lib
198
- Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR } )
197
+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR } /lib
198
+ Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR } )
199
199
200
200
#-------------------------------------
201
201
# Build the documentation with FORD
@@ -205,12 +205,12 @@ set ( SKIP_DOC_GEN FALSE CACHE BOOL
205
205
if ( NOT SKIP_DOC_GEN )
206
206
find_program ( FORD ford )
207
207
if ( FORD ) # Found
208
- file ( COPY "${CMAKE_SOURCE_DIR } /media" DESTINATION "${CMAKE_BINARY_DIR } /" )
209
- file ( GLOB_RECURSE PAGES_FILES "${CMAKE_SOURCE_DIR } /pages/*.*" )
210
- set ( DOC_DIR "${CMAKE_BINARY_DIR } /doc" )
211
- set ( PAGES_DIR "${CMAKE_SOURCE_DIR } /pages" )
212
- set ( PROJ_DIR "${CMAKE_SOURCE_DIR } /src" )
213
- set ( FORD_PROJECT_FILE "${CMAKE_SOURCE_DIR } /json-fortran.md" )
208
+ file ( COPY "${PROJECT_SOURCE_DIR } /media" DESTINATION "${PROJECT_BINARY_DIR } /" )
209
+ file ( GLOB_RECURSE PAGES_FILES "${PROJECT_SOURCE_DIR } /pages/*.*" )
210
+ set ( DOC_DIR "${PROJECT_BINARY_DIR } /doc" )
211
+ set ( PAGES_DIR "${PROJECT_SOURCE_DIR } /pages" )
212
+ set ( PROJ_DIR "${PROJECT_SOURCE_DIR } /src" )
213
+ set ( FORD_PROJECT_FILE "${PROJECT_SOURCE_DIR } /json-fortran.md" )
214
214
if ( ENABLE_UNICODE )
215
215
set ( MACRO_FLAG "-m USE_UCS4" )
216
216
else ()
@@ -222,7 +222,7 @@ if ( NOT SKIP_DOC_GEN )
222
222
else ()
223
223
set ( FPP "gfortran -E\n " ) # default to gfortran -E for gfortran and unsupported compilers
224
224
endif ()
225
- file ( WRITE "${CMAKE_BINARY_DIR } /.PREPROCESSOR" "${FPP} " )
225
+ file ( WRITE "${PROJECT_BINARY_DIR } /.PREPROCESSOR" "${FPP} " )
226
226
# Dynamically generate the FORD outputs list
227
227
message ( STATUS "Dynamically computing FORD output information..." )
228
228
if ( NOT (DEFINED FORD_OUTPUTS_CACHED) )
@@ -244,16 +244,16 @@ if ( NOT SKIP_DOC_GEN )
244
244
endif ()
245
245
message ( STATUS "Done dynamically computing FORD outputs." )
246
246
247
- foreach ( DOC_SRC_FILE ${JF_LIB_SRCS} ${JF_TEST_SRCS} ${CMAKE_SOURCE_DIR } /README.md
248
- ${CMAKE_SOURCE_DIR } /CHANGELOG.md ${CMAKE_SOURCE_DIR } /.github/CONTRIBUTING.md
249
- ${CMAKE_SOURCE_DIR } /LICENSE ${CMAKE_SOURCE_DIR } /json-fortran.md ${PAGES_FILES} )
247
+ foreach ( DOC_SRC_FILE ${JF_LIB_SRCS} ${JF_TEST_SRCS} ${PROJECT_SOURCE_DIR } /README.md
248
+ ${PROJECT_SOURCE_DIR } /CHANGELOG.md ${PROJECT_SOURCE_DIR } /.github/CONTRIBUTING.md
249
+ ${PROJECT_SOURCE_DIR } /LICENSE ${PROJECT_SOURCE_DIR } /json-fortran.md ${PAGES_FILES} )
250
250
list ( APPEND FORD_DEPENDS "${DOC_SRC_FILE} " )
251
251
endforeach ()
252
252
add_custom_command ( OUTPUT ${FORD_OUTPUTS_CACHED}
253
- COMMAND "${FORD} " --debug ${MACRO_FLAG} -d "${PROJ_DIR} " -o "${DOC_DIR} " -p "${CMAKE_SOURCE_DIR } /pages" "${FORD_PROJECT_FILE} "
253
+ COMMAND "${FORD} " --debug ${MACRO_FLAG} -d "${PROJ_DIR} " -o "${DOC_DIR} " -p "${PROJECT_SOURCE_DIR } /pages" "${FORD_PROJECT_FILE} "
254
254
MAIN_DEPENDENCY "${FORD_PROJECT_FILE} "
255
255
DEPENDS ${FORD_DEPENDS}
256
- COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME } using FORD" )
256
+ COMMENT "Building HTML documentation for ${PROJECT_NAME } using FORD" )
257
257
add_custom_target ( documentation ALL
258
258
DEPENDS ${FORD_OUTPUTS_CACHED} )
259
259
set ( INSTALL_API_DOCUMENTATION TRUE
@@ -290,7 +290,7 @@ if ( ENABLE_TESTS )
290
290
291
291
find_program ( JSONLINT jsonlint )
292
292
293
- set ( DATA_DIR "${CMAKE_SOURCE_DIR } /files" )
293
+ set ( DATA_DIR "${PROJECT_SOURCE_DIR } /files" )
294
294
295
295
set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
296
296
"${FORD_CLEAN_OUTPUTS} " )
@@ -323,13 +323,13 @@ if ( ENABLE_TESTS )
323
323
endif ()
324
324
325
325
add_test (NAME jf-cleanup-fixture
326
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR } "
327
- COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR } /files" )
326
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } "
327
+ COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_BINARY_DIR } /files" )
328
328
set_tests_properties (jf-cleanup-fixture
329
329
PROPERTIES FIXTURES_SETUP JF)
330
330
add_test (NAME jf-setup-fixture
331
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR } "
332
- COMMAND ${CMAKE_COMMAND} -E copy_directory "${DATA_DIR} " "${CMAKE_BINARY_DIR } /files" )
331
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } "
332
+ COMMAND ${CMAKE_COMMAND} -E copy_directory "${DATA_DIR} " "${PROJECT_BINARY_DIR } /files" )
333
333
set_tests_properties (jf-setup-fixture
334
334
PROPERTIES FIXTURES_SETUP JF
335
335
DEPENDS jf-cleanup-fixture)
@@ -338,17 +338,17 @@ if ( ENABLE_TESTS )
338
338
foreach ( UNIT_TEST ${JF_TEST_SRCS} )
339
339
get_filename_component ( TEST ${UNIT_TEST} NAME_WE )
340
340
if (MSVC_IDE )
341
- link_directories (${CMAKE_BINARY_DIR } /lib)
341
+ link_directories (${PROJECT_BINARY_DIR } /lib)
342
342
endif ()
343
343
add_executable ( ${TEST} EXCLUDE_FROM_ALL ${UNIT_TEST} )
344
344
target_link_libraries ( ${TEST} ${LIB_NAME} )
345
345
add_dependencies ( check ${TEST} )
346
346
add_dependencies ( build_tests ${TEST} )
347
347
set_target_properties ( ${TEST}
348
348
PROPERTIES
349
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR } /bin )
349
+ RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR } /bin )
350
350
add_test ( NAME ${TEST}
351
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR } /bin
351
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR } /bin
352
352
COMMAND ./${TEST} )
353
353
set_tests_properties ( ${TEST}
354
354
PROPERTIES FIXTURES_REQUIRED JF)
@@ -375,7 +375,7 @@ if ( ENABLE_TESTS )
375
375
foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
376
376
get_filename_component ( TESTNAME ${JSON_FILE} NAME )
377
377
add_test ( NAME validate-output -${TESTNAME}
378
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR } /files"
378
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } /files"
379
379
COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} )
380
380
set_property ( TEST validate-output -${TESTNAME}
381
381
APPEND
@@ -392,7 +392,7 @@ if ( ENABLE_TESTS )
392
392
foreach ( JSON_FILE ${EXPECTED_OUTPUTS} )
393
393
get_filename_component (OUTPUT ${JSON_FILE} NAME )
394
394
add_test ( NAME regression-${OUTPUT}
395
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR } /files"
395
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR } /files"
396
396
COMMAND ${CMAKE_COMMAND} -E compare_files ${JSON_FORTRAN_COMPARE_FLAG} ${OUTPUT} expected-outputs/${OUTPUT} )
397
397
set_property ( TEST regression-${OUTPUT}
398
398
APPEND
@@ -429,19 +429,19 @@ install(
429
429
# Add portable unistall command to makefile
430
430
#------------------------------------------
431
431
# Adapted from the CMake Wiki FAQ
432
- configure_file ( "${CMAKE_SOURCE_DIR } /cmake/uninstall.cmake.in" "${CMAKE_BINARY_DIR } /uninstall.cmake"
432
+ configure_file ( "${PROJECT_SOURCE_DIR } /cmake/uninstall.cmake.in" "${PROJECT_BINARY_DIR } /uninstall.cmake"
433
433
@ONLY)
434
434
435
435
add_custom_target ( uninstall
436
- COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR } /uninstall.cmake" )
436
+ COMMAND ${CMAKE_COMMAND} -P "${PROJECT_BINARY_DIR } /uninstall.cmake" )
437
437
438
438
#-----------------------------------------------------
439
439
# Publicize installed location to other CMake projects
440
440
#-----------------------------------------------------
441
441
install ( EXPORT ${PACKAGE_NAME} -targets DESTINATION "${EXPORT_INSTALL_DIR} " )
442
442
443
443
include ( CMakePackageConfigHelpers ) # Standard CMake module
444
- write_basic_package_version_file( "${CMAKE_BINARY_DIR } /${PACKAGE_NAME} -config-version.cmake"
444
+ write_basic_package_version_file( "${PROJECT_BINARY_DIR } /${PACKAGE_NAME} -config-version.cmake"
445
445
VERSION ${VERSION}
446
446
COMPATIBILITY SameMajorVersion )
447
447
@@ -450,15 +450,15 @@ include ( cmake/FCompilerConsistencyCheck.cmake )
450
450
451
451
# install package config file
452
452
configure_package_config_file (
453
- "${CMAKE_SOURCE_DIR } /cmake/pkg/${CMAKE_PROJECT_NAME } -config.cmake.in"
454
- "${CMAKE_BINARY_DIR } /pkg/${PACKAGE_NAME} -config.cmake"
453
+ "${PROJECT_SOURCE_DIR } /cmake/pkg/${PROJECT_NAME } -config.cmake.in"
454
+ "${PROJECT_BINARY_DIR } /pkg/${PACKAGE_NAME} -config.cmake"
455
455
INSTALL_DESTINATION "${EXPORT_INSTALL_DIR} "
456
456
PATH_VARS EXPORT_INSTALL_DIR INSTALL_MOD_DIR )
457
457
458
458
# Install the config and version files so that we can find this project with others
459
459
install ( FILES
460
- "${CMAKE_BINARY_DIR } /pkg/${PACKAGE_NAME} -config.cmake"
461
- "${CMAKE_BINARY_DIR } /${PACKAGE_NAME} -config-version.cmake"
460
+ "${PROJECT_BINARY_DIR } /pkg/${PACKAGE_NAME} -config.cmake"
461
+ "${PROJECT_BINARY_DIR } /${PACKAGE_NAME} -config-version.cmake"
462
462
DESTINATION "${EXPORT_INSTALL_DIR} " )
463
463
464
464
#----------------------------------------------
@@ -468,8 +468,8 @@ export ( TARGETS ${LIB_NAME} ${LIB_NAME}-static FILE ${PACKAGE_NAME}-targets.cma
468
468
469
469
# build tree package config file, NOT installed
470
470
configure_file (
471
- "${CMAKE_SOURCE_DIR } /cmake/${CMAKE_PROJECT_NAME } -config.cmake.in"
472
- "${CMAKE_BINARY_DIR } /${PACKAGE_NAME} -config.cmake"
471
+ "${PROJECT_SOURCE_DIR } /cmake/${PROJECT_NAME } -config.cmake.in"
472
+ "${PROJECT_BINARY_DIR } /${PACKAGE_NAME} -config.cmake"
473
473
@ONLY )
474
474
475
475
set ( ENABLE_BUILD_TREE_EXPORT FALSE CACHE BOOL
0 commit comments