Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally produce shared libraries #335

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(
LANGUAGES Fortran
)

option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(BUILD_TESTING "Build tests" OFF)

option(RTE_ENABLE_SP "Enable single-precision floating-point model" OFF)
Expand Down
10 changes: 8 additions & 2 deletions rrtmgp-frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(gas_optics_source_dir ${PROJECT_SOURCE_DIR}/gas-optics)

add_library(
rrtmgp STATIC # cmake-format: sort
rrtmgp # cmake-format: sort
$<TARGET_OBJECTS:rrtmgpkernels>
${gas_optics_source_dir}/mo_gas_concentrations.F90
${gas_optics_source_dir}/mo_gas_optics.F90
Expand All @@ -14,7 +14,13 @@ add_library(

add_library(rte-rrtmgp::rrtmgp ALIAS rrtmgp)

set_target_properties(rrtmgp PROPERTIES EXPORT_NAME rte-rrtmgp::rrtmgp)
set_target_properties(
rrtmgp
PROPERTIES EXPORT_NAME rte-rrtmgp::rrtmgp
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}"
)

target_include_directories(
rrtmgp
Expand Down
4 changes: 4 additions & 0 deletions rrtmgp-kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ else()
endif()
endif()

if(BUILD_SHARED_LIBS)
set_target_properties(rrtmgpkernels PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

target_include_directories(
rrtmgpkernels PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}
)
Expand Down
9 changes: 7 additions & 2 deletions rte-frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_library(
rte STATIC # cmake-format: sort
rte # cmake-format: sort
$<TARGET_OBJECTS:rtekernels>
mo_fluxes.F90
mo_optical_props.F90
Expand All @@ -12,7 +12,12 @@ add_library(

add_library(rte-rrtmgp::rte ALIAS rte)

set_target_properties(rte PROPERTIES EXPORT_NAME rte-rrtmgp::rte)
set_target_properties(
rte
PROPERTIES EXPORT_NAME rte-rrtmgp::rte
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)

target_include_directories(
rte
Expand Down
4 changes: 4 additions & 0 deletions rte-kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ else()
endif()
endif()

if(BUILD_SHARED_LIBS)
set_target_properties(rtekernels PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

target_compile_definitions(
rtekernels PRIVATE $<$<BOOL:${RTE_ENABLE_SP}>:RTE_USE_SP>
)
Expand Down
Loading