From 29a11f1952801e91af990f3b545a52336635e231 Mon Sep 17 00:00:00 2001 From: Landon Owen Date: Wed, 11 Sep 2024 13:49:25 -0700 Subject: [PATCH] Fix bug where ENABLE_SHARED was ignored, added guards for TPL exporting --- cmake/spheral/SpheralAddLibs.cmake | 4 ++-- cmake/spheral_cxx-config.cmake.in | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/spheral/SpheralAddLibs.cmake b/cmake/spheral/SpheralAddLibs.cmake index 701b1a06c..2d3fca6d7 100644 --- a/cmake/spheral/SpheralAddLibs.cmake +++ b/cmake/spheral/SpheralAddLibs.cmake @@ -91,12 +91,12 @@ function(spheral_add_cxx_library package_name _cxx_obj_list) add_library(Spheral_${package_name} INTERFACE) target_link_libraries(Spheral_${package_name} INTERFACE ${_cxx_obj_list}) else() - # Build static spheral C++ library + # Build static or shared spheral C++ library blt_add_library(NAME Spheral_${package_name} HEADERS ${${package_name}_headers} SOURCES ${${package_name}_sources} DEPENDS_ON ${_cxx_obj_list} ${SPHERAL_CXX_DEPENDS} ${SPHERAL_BLT_DEPENDS} - SHARED FALSE) + SHARED ${ENABLE_SHARED}) endif() target_include_directories(Spheral_${package_name} SYSTEM PRIVATE ${SPHERAL_SUBMOD_INCLUDES}) if(ENABLE_CUDA) diff --git a/cmake/spheral_cxx-config.cmake.in b/cmake/spheral_cxx-config.cmake.in index 229817de9..138270719 100644 --- a/cmake/spheral_cxx-config.cmake.in +++ b/cmake/spheral_cxx-config.cmake.in @@ -27,7 +27,9 @@ if(NOT SPHERAL_FOUND) set(SPHERAL_FP_TPLS "@SPHERAL_FP_TPLS@") set(SPHERAL_FP_DIRS "@SPHERAL_FP_DIRS@") foreach(tpl dir IN ZIP_LISTS SPHERAL_FP_TPLS SPHERAL_FP_DIRS) - find_package(${tpl} REQUIRED QUIET NO_DEFAULT_PATH PATHS ${dir}) + if(NOT TARGET ${tpl}) + find_package(${tpl} REQUIRED QUIET NO_DEFAULT_PATH PATHS ${dir}) + endif() endforeach() if(NOT TARGET chai) if (@USE_EXTERNAL_CHAI@)