Skip to content

Commit

Permalink
Dependency cleanups for downstream consumers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hoikas committed Oct 3, 2023
1 parent 29229fd commit c07ecc5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 8 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,14 @@ add_library(HSPlasma
${SQUISH_SOURCES}
)
target_link_libraries(HSPlasma
JPEG::JPEG PNG::PNG string_theory Threads::Threads ZLIB::ZLIB
$<$<AND:$<BOOL:${ENABLE_PHYSX}>,$<BOOL:${PHYSX_FOUND}>>:${PHYSX_COOKING_LIBRARY}>
PUBLIC
string_theory
Threads::Threads
PRIVATE
JPEG::JPEG
PNG::PNG
ZLIB::ZLIB
$<$<AND:$<BOOL:${ENABLE_PHYSX}>,$<BOOL:${PHYSX_FOUND}>>:${PHYSX_COOKING_LIBRARY}>
)

target_include_directories(HSPlasma PUBLIC
Expand Down
9 changes: 6 additions & 3 deletions core/HSPlasmaConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 5 additions & 3 deletions net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ add_library(HSPlasmaNet
${PN_SOURCES} ${PN_HEADERS}
)
target_link_libraries(HSPlasmaNet
HSPlasma string_theory
$<$<NOT:$<PLATFORM_ID:SunOS>>:OpenSSL::Crypto>
$<$<PLATFORM_ID:Windows>:ws2_32>
PUBLIC
HSPlasma
PRIVATE
$<$<NOT:$<PLATFORM_ID:SunOS>>:OpenSSL::Crypto>
$<$<PLATFORM_ID:Windows>:ws2_32>
)

target_include_directories(HSPlasmaNet PUBLIC
Expand Down
4 changes: 3 additions & 1 deletion net/HSPlasmaNetConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c07ecc5

Please sign in to comment.