From c07ecc5b93b32f2ddcf0837507f28c0fb64d35a8 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 2 Oct 2023 20:18:41 -0400 Subject: [PATCH] Dependency cleanups for downstream consumers. If we're building shared libraries (eg HSPlasma.dll and HSPlasmaNet.dll), then downstream users don't need to link against or even know about libraries used internally, such as zlib, png, etc. This fixes our CMake package config files to only search for those dependencies if the downstream user needs to link against them due to building HSPlasma as a static library. Further, add a missing search for the string_theory library config module. --- Tools/CMakeLists.txt | 2 +- core/CMakeLists.txt | 10 ++++++++-- core/HSPlasmaConfig.cmake.in | 9 ++++++--- net/CMakeLists.txt | 8 +++++--- net/HSPlasmaNetConfig.cmake.in | 4 +++- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt index b90852064..71931e7f6 100644 --- a/Tools/CMakeLists.txt +++ b/Tools/CMakeLists.txt @@ -7,7 +7,7 @@ endif() macro(plasma_tool NAME) add_executable(${NAME} src/${NAME}.cpp) - target_link_libraries(${NAME} HSPlasma ${STRING_THEORY_LIBRARIES}) + target_link_libraries(${NAME} PRIVATE HSPlasma) install(TARGETS ${NAME} RUNTIME DESTINATION bin) endmacro(plasma_tool) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 49d2c1654..dfb481bb8 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -802,8 +802,14 @@ add_library(HSPlasma ${SQUISH_SOURCES} ) target_link_libraries(HSPlasma - JPEG::JPEG PNG::PNG string_theory Threads::Threads ZLIB::ZLIB - $<$,$>:${PHYSX_COOKING_LIBRARY}> + PUBLIC + string_theory + Threads::Threads + PRIVATE + JPEG::JPEG + PNG::PNG + ZLIB::ZLIB + $<$,$>:${PHYSX_COOKING_LIBRARY}> ) target_include_directories(HSPlasma PUBLIC diff --git a/core/HSPlasmaConfig.cmake.in b/core/HSPlasmaConfig.cmake.in index f92483a46..e795b918e 100644 --- a/core/HSPlasmaConfig.cmake.in +++ b/core/HSPlasmaConfig.cmake.in @@ -1,9 +1,12 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(ZLIB) -find_dependency(JPEG) -find_dependency(PNG) +if(NOT "@BUILD_SHARED_LIBS@") + find_dependency(ZLIB) + find_dependency(JPEG) + find_dependency(PNG) +endif() +find_dependency(string_theory CONFIG) find_dependency(Threads) include(${CMAKE_CURRENT_LIST_DIR}/HSPlasma-targets.cmake) diff --git a/net/CMakeLists.txt b/net/CMakeLists.txt index 66639d50e..a905470ee 100644 --- a/net/CMakeLists.txt +++ b/net/CMakeLists.txt @@ -94,9 +94,11 @@ add_library(HSPlasmaNet ${PN_SOURCES} ${PN_HEADERS} ) target_link_libraries(HSPlasmaNet - HSPlasma string_theory - $<$>:OpenSSL::Crypto> - $<$:ws2_32> + PUBLIC + HSPlasma + PRIVATE + $<$>:OpenSSL::Crypto> + $<$:ws2_32> ) target_include_directories(HSPlasmaNet PUBLIC diff --git a/net/HSPlasmaNetConfig.cmake.in b/net/HSPlasmaNetConfig.cmake.in index fbb2c6d7a..4ba511e19 100644 --- a/net/HSPlasmaNetConfig.cmake.in +++ b/net/HSPlasmaNetConfig.cmake.in @@ -2,7 +2,9 @@ include(CMakeFindDependencyMacro) find_dependency(HSPlasma CONFIG) -find_dependency(OpenSSL) +if(NOT "@BUILD_SHARED_LIBS@") + find_dependency(OpenSSL) +endif() include(${CMAKE_CURRENT_LIST_DIR}/HSPlasmaNet-targets.cmake)