From 94f7176066d22e89e242c7faab9b7434e8b84423 Mon Sep 17 00:00:00 2001 From: Luis Manuel Diaz Angulo Date: Thu, 26 Oct 2023 12:37:36 +0200 Subject: [PATCH 1/3] Fixes compilation with Ninja and IntelLLVM when using OneAPI --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 036ca7d8f..ce53c7884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,8 +167,16 @@ endif () #--------------------------------------------- set ( LIB_NAME ${PROJECT_NAME} ) -add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} ) -add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} ) +if(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM) + add_library ( ${LIB_NAME}-obj OBJECT ${JF_LIB_SRCS} ) + set_property(TARGET ${LIB_NAME}-obj PROPERTY POSITION_INDEPENDENT_CODE 1) + + add_library ( ${LIB_NAME} SHARED $ ) + add_library ( ${LIB_NAME}-static STATIC $ ) +else() + add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} ) + add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} ) +endif() if(JSON_FORTRAN_USE_OpenCoarrays) target_link_libraries(${LIB_NAME} @@ -185,15 +193,26 @@ target_include_directories(${LIB_NAME}-static PUBLIC $ $) -set_target_properties ( ${LIB_NAME}-static - PROPERTIES - OUTPUT_NAME ${LIB_NAME} - if(NOT MSVC_IDE) - PREFIX lib - endif() - VERSION ${VERSION} - ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib - Fortran_MODULE_DIRECTORY ${MODULE_DIR} ) +if(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM) + set_target_properties ( ${LIB_NAME}-static + PROPERTIES + if(NOT MSVC_IDE) + PREFIX lib + endif() + VERSION ${VERSION} + ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib + Fortran_MODULE_DIRECTORY ${MODULE_DIR} ) +else() + set_target_properties ( ${LIB_NAME}-static + PROPERTIES + OUTPUT_NAME ${LIB_NAME} + if(NOT MSVC_IDE) + PREFIX lib + endif() + VERSION ${VERSION} + ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib + Fortran_MODULE_DIRECTORY ${MODULE_DIR} ) +endif() set_target_properties ( ${LIB_NAME} PROPERTIES OUTPUT_NAME ${LIB_NAME} From 481d793b75079078eae11fce8693e11ce1b628e1 Mon Sep 17 00:00:00 2001 From: Luis Manuel Diaz Angulo Date: Wed, 20 Dec 2023 08:21:20 +0100 Subject: [PATCH 2/3] Adds option to jsonfortran compilation library --- CMakeLists.txt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce53c7884..8ff4334f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,11 @@ # this software. The contributing author, Izaak Beekman, retains all # rights permitted by the terms of the JSON-Fortran license. -cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR ) +cmake_minimum_required ( VERSION 3.18 FATAL_ERROR ) + +option (JSONFORTRAN_ENABLE_DOC_GENERATION "Enable doc generation" OFF) +option (JSONFORTRAN_ENABLE_TESTS "Enable tests" OFF) +option (JSONFORTRAN_STATIC_LIBRARY_ONLY "Generate only static library" ON) # Use MSVS folders to organize projects on windows set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -174,8 +178,12 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM) add_library ( ${LIB_NAME} SHARED $ ) add_library ( ${LIB_NAME}-static STATIC $ ) else() - add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} ) + if (JSONFORTRAN_STATIC_LIBRARY_ONLY) + add_library ( ${LIB_NAME} STATIC ${JF_LIB_SRCS} ) add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} ) + else() + add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} ) + endif() endif() if(JSON_FORTRAN_USE_OpenCoarrays) @@ -227,6 +235,10 @@ set_target_properties ( ${LIB_NAME} #------------------------------------- # Build the documentation with FORD #------------------------------------- +if (JSONFORTRAN_ENABLE_DOC_GENERATION) + set(SKIP_DOC_GEN FALSE) +endif () + set ( SKIP_DOC_GEN FALSE CACHE BOOL "Disable building the API documentation with FORD" ) if ( NOT SKIP_DOC_GEN ) @@ -301,6 +313,9 @@ endif () #-------------------------- # Handle test related stuff #-------------------------- +if (JSONFORTRAN_ENABLE_TESTS) + set (ENABLE_TESTS FALSE) +endif () set ( ENABLE_TESTS TRUE CACHE BOOL "Enable the JSON-Fortran tests." ) From 9eaa63f35864f3c0038dde224200c7889dbf128c Mon Sep 17 00:00:00 2001 From: Luis Manuel Diaz Angulo Date: Wed, 20 Dec 2023 08:40:01 +0100 Subject: [PATCH 3/3] Adds options to cmake --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff4334f6..31d68702c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,11 +236,11 @@ set_target_properties ( ${LIB_NAME} # Build the documentation with FORD #------------------------------------- if (JSONFORTRAN_ENABLE_DOC_GENERATION) - set(SKIP_DOC_GEN FALSE) + set(SKIP_DOC_GEN FALSE CACHE BOOL "Disable building the API documentation with FORD") +else () + set(SKIP_DOC_GEN TRUE CACHE BOOL "Disable building the API documentation with FORD" ) endif () -set ( SKIP_DOC_GEN FALSE CACHE BOOL - "Disable building the API documentation with FORD" ) if ( NOT SKIP_DOC_GEN ) find_program ( FORD ford ) if ( FORD ) # Found @@ -314,10 +314,10 @@ endif () # Handle test related stuff #-------------------------- if (JSONFORTRAN_ENABLE_TESTS) - set (ENABLE_TESTS FALSE) + set ( ENABLE_TESTS TRUE CACHE BOOL "Enable the JSON-Fortran tests." ) +else () + set ( ENABLE_TESTS FALSE CACHE BOOL "Enable the JSON-Fortran tests." ) endif () -set ( ENABLE_TESTS TRUE CACHE BOOL - "Enable the JSON-Fortran tests." ) #--------------------------------------------------------------------- # Add some tests to ensure that the software is performing as expected