diff --git a/CMakeLists.txt b/CMakeLists.txt index 02d1b5c4810177982185d849be727b9138afca3a..92285823f8e76bc7079d68fa85fea4900482447a 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(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) + 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 SPLIT_FORTRAN_LIBRARY) 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 SPLIT_FORTRAN_LIBRARY) install(TARGETS sit sit_f EXPORT sitTargets @@ -61,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}) - else() - install(TARGETS sit EXPORT sitTargets FILE_SET HEADERS @@ -73,7 +74,17 @@ 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() diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index 838d67563b708987f34aba9c8e7053c8b42706ae..d1c81886aeea7f0ebc996600865842ef3f1c6a0e 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(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) +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 28b6b096c809825f4920a4de3a7231fc7b2bf294..5980f92fb1fce1c0b21ec4c28d49b6032684d0d6 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(SPLIT_FORTRAN_LIBRARY) + target_link_libraries(TestFortranLink sit sit_f) + else() + target_link_libraries(TestFortranLink sit) + endif() + target_include_directories(TestFortranLink PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY})