@@ -26,6 +26,8 @@ endif()
26
26
27
27
cmake_path(APPEND CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} "include" )
28
28
29
+ option (BUILD_SHARED_LIBS "Build shared/dynamic libraries" OFF )
30
+
29
31
################################################################################
30
32
# Fortran
31
33
################################################################################
@@ -61,11 +63,11 @@ endif()
61
63
################################################################################
62
64
63
65
find_package (MPI REQUIRED COMPONENTS Fortran)
66
+ find_package (FMS REQUIRED COMPONENTS R8)
64
67
find_package (PkgConfig REQUIRED)
65
- pkg_check_modules(FMS REQUIRED IMPORTED_TARGET "FMS" )
66
68
pkg_check_modules(MOCSY REQUIRED IMPORTED_TARGET "mocsy" )
67
69
68
- add_library (gtracers STATIC )
70
+ add_library (gtracers)
69
71
70
72
target_sources (gtracers PRIVATE
71
73
generic_tracers/FMS_coupler_util.F90
@@ -87,8 +89,19 @@ target_sources(gtracers PRIVATE
87
89
generic_tracers/generic_WOMBATmid.F90
88
90
)
89
91
92
+ set_target_properties (gtracers PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} )
93
+
94
+ # "Creating CMake Libraries - That others can find and use."
95
+ # https://www.youtube.com/watch?v=08f5Dav72aE
96
+ target_include_directories (gtracers
97
+ PUBLIC
98
+ # Generic Tracers has no header files but creates modules
99
+ # "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/generic_tracers>"
100
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >"
101
+ )
102
+
90
103
target_link_libraries (gtracers PUBLIC
91
- PkgConfig::FMS
104
+ FMS::fms_r8
92
105
PkgConfig::MOCSY)
93
106
94
107
install (TARGETS gtracers
0 commit comments