From 021049208ac1a2f617bf11594803ebe070ead5a3 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 4 Jun 2024 12:43:26 +0200 Subject: [PATCH 1/3] Moved symbols into main lib --- CMakeLists.txt | 20 +++++++++++++------- src/bindings/CMakeLists.txt | 16 +++++++++++++--- tests/CMakeLists.txt | 7 ++++++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02d1b5c..4c147e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,15 @@ list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") option(BACKEND_EXTRAE "Enable Extrae" OFF) option(BACKEND_DLB "Enable DLB" OFF) option(BUILD_C_FORTRAN "Enable C and Fortran Interfaces" ON) +option(BUILD_FORTRAN_LIB "Build special fortran-only library - EXPERIMENTAL" OFF) option(GEN_BINDINGS "Use Shroud to Generate C/Fortran interface" OFF) +if(BUILD_C_FORTRAN) + enable_language(Fortran) + set(CMAKE_Fortran_FORMAT FREE) + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod) +endif() + add_library(sit SHARED) set(SIT_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -26,10 +33,7 @@ target_include_directories(sit PUBLIC ) -if(BUILD_C_FORTRAN) - enable_language(Fortran) - set(CMAKE_Fortran_FORMAT FREE) - set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod) +if(BUILD_C_FORTRAN AND BUILD_FORTRAN_LIB) add_library(sit_f) add_library(sit::sit_f ALIAS sit_f) endif() @@ -52,7 +56,7 @@ message(STATUS ${CMAKE_INSTALL_INCLUDEDIR}) -if(BUILD_C_FORTRAN) +if(BUILD_C_FORTRAN AND BUILD_FORTRAN_LIB) install(TARGETS sit sit_f EXPORT sitTargets @@ -62,8 +66,8 @@ install(TARGETS sit sit_f INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit ) install(FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/sit_mod.mod DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -else() +endif() + install(TARGETS sit EXPORT sitTargets @@ -74,6 +78,8 @@ install(TARGETS sit INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit ) +if(BUILD_C_FORTRAN) + install(FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/sit_mod.mod DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index 838d675..abeffcd 100644 --- a/src/bindings/CMakeLists.txt +++ b/src/bindings/CMakeLists.txt @@ -20,14 +20,24 @@ if(GEN_BINDINGS) endif() -target_sources(sit_f PRIVATE wrapfsit.f) target_sources(sit PRIVATE wrapsit.cpp) + +if(BUILD_FORTRAN_LIB) + target_sources(sit_f PRIVATE wrapfsit.f) + target_include_directories(sit_f PRIVATE ${SIT_PUBLIC_HEADERS}) + set_target_properties(sit_f PROPERTIES LINKER_LANGUAGE Fortran) +else() + target_sources(sit PRIVATE wrapfsit.f) +endif() + + + #set( CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) #set_source_files_properties(wrapsit.cpp PROPERTIES GENERATED TRUE) #set_source_files_properties(wrapfsit.f PROPERTIES GENERATED TRUE) -target_include_directories(sit_f PRIVATE ${SIT_PUBLIC_HEADERS}) -set_target_properties(sit_f PROPERTIES LINKER_LANGUAGE Fortran) + + #set_target_properties(st_f PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) #set_target_properties(sit_f PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 28b6b09..397a28e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,7 +46,12 @@ if(BUILD_C_FORTRAN) add_executable(TestFortranLink fortran/TestFortranModule.f90) - target_link_libraries(TestFortranLink sit sit_f) + if(BUILD_FORTRAN_LIB) + target_link_libraries(TestFortranLink sit sit_f) + else() + target_link_libraries(TestFortranLink sit) + endif() + target_include_directories(TestFortranLink PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) -- GitLab From 06f7f8f39550efbe78c06058184a0425c1117428 Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 4 Jun 2024 12:47:07 +0200 Subject: [PATCH 2/3] refactored install logic minorly to make easier --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c147e8..5cad486 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,10 +65,7 @@ install(TARGETS sit sit_f PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit ) - install(FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/sit_mod.mod DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -endif() - - +else() install(TARGETS sit EXPORT sitTargets FILE_SET HEADERS @@ -77,12 +74,20 @@ install(TARGETS sit PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit ) +endif() if(BUILD_C_FORTRAN) install(FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/sit_mod.mod DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() + + +if(BUILD_C_FORTRAN) + +endif() + + install(FILES ${SIT_PUBLIC_HEADERS}/sit/sit.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sit) # Export the Targets to install -- GitLab From d75e924f6ec532441f23cef863f4e1cf1041b04e Mon Sep 17 00:00:00 2001 From: Valentin Seitz Date: Tue, 4 Jun 2024 14:47:25 +0200 Subject: [PATCH 3/3] Renamed to a hopefully more clear option --- CMakeLists.txt | 6 +++--- src/bindings/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cad486..9228582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") option(BACKEND_EXTRAE "Enable Extrae" OFF) option(BACKEND_DLB "Enable DLB" OFF) option(BUILD_C_FORTRAN "Enable C and Fortran Interfaces" ON) -option(BUILD_FORTRAN_LIB "Build special fortran-only library - EXPERIMENTAL" OFF) +option(SPLIT_FORTRAN_LIBRARY "Split the fortran symbols into a special library (sit_f) - EXPERIMENTAL" OFF) option(GEN_BINDINGS "Use Shroud to Generate C/Fortran interface" OFF) if(BUILD_C_FORTRAN) @@ -33,7 +33,7 @@ target_include_directories(sit PUBLIC ) -if(BUILD_C_FORTRAN AND BUILD_FORTRAN_LIB) +if(BUILD_C_FORTRAN AND SPLIT_FORTRAN_LIBRARY) add_library(sit_f) add_library(sit::sit_f ALIAS sit_f) endif() @@ -56,7 +56,7 @@ message(STATUS ${CMAKE_INSTALL_INCLUDEDIR}) -if(BUILD_C_FORTRAN AND BUILD_FORTRAN_LIB) +if(BUILD_C_FORTRAN AND SPLIT_FORTRAN_LIBRARY) install(TARGETS sit sit_f EXPORT sitTargets diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index abeffcd..d1c8188 100644 --- a/src/bindings/CMakeLists.txt +++ b/src/bindings/CMakeLists.txt @@ -22,7 +22,7 @@ endif() target_sources(sit PRIVATE wrapsit.cpp) -if(BUILD_FORTRAN_LIB) +if(SPLIT_FORTRAN_LIBRARY) target_sources(sit_f PRIVATE wrapfsit.f) target_include_directories(sit_f PRIVATE ${SIT_PUBLIC_HEADERS}) set_target_properties(sit_f PROPERTIES LINKER_LANGUAGE Fortran) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 397a28e..5980f92 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,7 +46,7 @@ if(BUILD_C_FORTRAN) add_executable(TestFortranLink fortran/TestFortranModule.f90) - if(BUILD_FORTRAN_LIB) + if(SPLIT_FORTRAN_LIBRARY) target_link_libraries(TestFortranLink sit sit_f) else() target_link_libraries(TestFortranLink sit) -- GitLab