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

Improve CMake library dependencies #1536

Merged
merged 2 commits into from
Nov 14, 2024
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
8 changes: 4 additions & 4 deletions src/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ endif()
if (CERN_ROOT_FOUND)
target_include_directories(IO PRIVATE ${CERN_ROOT_INCLUDE_DIRS})
if (TARGET ROOT::Tree)
target_link_libraries(IO PUBLIC ROOT::Tree)
target_link_libraries(IO PRIVATE ROOT::Tree)
else()
target_link_libraries(IO PUBLIC ${CERN_ROOT_LIBRARIES})
target_link_libraries(IO PRIVATE ${CERN_ROOT_LIBRARIES})
endif()
endif()

Expand All @@ -94,12 +94,12 @@ if (HAVE_HDF5)
endif()

if (HAVE_ITK)
target_link_libraries(IO PUBLIC ITKCommon ${ITK_LIBRARIES})
target_link_libraries(IO PRIVATE ITKCommon ${ITK_LIBRARIES})
endif()

if (UPENN_FOUND)
target_include_directories(IO PUBLIC ${UPENN_INCLUDE_DIR})
target_link_libraries(IO PUBLIC ${UPENN_libsss_tof} ${UPENN_libfit} ${UPENN_libdist} ${UPENN_libgeom}
target_link_libraries(IO PRIVATE ${UPENN_libsss_tof} ${UPENN_libfit} ${UPENN_libdist} ${UPENN_libgeom}
${UPENN_liblor} ${UPENN_liblist} ${UPENN_libmhdr} ${JANSSON_LIBRARY} ${ZLIB_LIBRARY_RELEASE}
${UPENN_libimagio} ${UPENN_libimagio++})
endif()
Expand Down
10 changes: 9 additions & 1 deletion src/cmake/STIRConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,31 @@ else()
endif()

## find external packages
# Note that we generally need find_package even for those that are only
# PRIVATE dependencies (such as ITK, parallelproj etc). This is because
# otherwise their targets (such as parallelproj::parallelproj_c) don't exist,
# and the user will get CMake errors.
# See https://github.com/UCL/STIR/issues/1535

# we use a trick by Matt McCormick (kitware)
# to set ITK_DIR etc first before calling find_package
# to make sure we pick the same version of the external library

if (STIR_FIND_QUIETLY)
SET(STIR_FIND_TYPE "QUIET")
else()
SET(STIR_FIND_TYPE "REQUIRED")
endif()

find_package(Boost @Boost_VERSION@ REQUIRED)

if (@ITK_FOUND@)
message(STATUS "ITK support in STIR enabled.")
set(ITK_DIR "@ITK_DIR@")
find_package(ITK ${STIR_FIND_TYPE} CONFIG)
if(NOT ITK_FOUND)
SET(STIR_FOUND OFF)
endif()
include(${ITK_USE_FILE})
set(STIR_BUILT_WITH_ITK TRUE)
endif()

Expand Down
16 changes: 8 additions & 8 deletions src/recon_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ endif()
target_link_libraries(recon_buildblock PUBLIC modelling_buildblock display numerics_buildblock listmode_buildblock data_buildblock buildblock spatial_transformation_buildblock )

if (STIR_WITH_NiftyPET_PROJECTOR)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::petprj)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_auxe)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_lmproc)
target_link_libraries(recon_buildblock PUBLIC CUDA::cudart)
target_link_libraries(recon_buildblock PRIVATE NiftyPET::petprj)
target_link_libraries(recon_buildblock PRIVATE NiftyPET::mmr_auxe)
target_link_libraries(recon_buildblock PRIVATE NiftyPET::mmr_lmproc)
target_link_libraries(recon_buildblock PRIVATE CUDA::cudart)
endif()

if (STIR_WITH_Parallelproj_PROJECTOR)
target_link_libraries(recon_buildblock PUBLIC parallelproj::parallelproj_c)
target_link_libraries(recon_buildblock PRIVATE parallelproj::parallelproj_c)
if (parallelproj_built_with_CUDA)
target_link_libraries(recon_buildblock PUBLIC parallelproj::parallelproj_cuda)
target_link_libraries(recon_buildblock PRIVATE parallelproj::parallelproj_cuda)
endif()
endif()

if (STIR_WITH_CUDA)
target_link_libraries(recon_buildblock PUBLIC CUDA::cudart)
endif()
target_link_libraries(recon_buildblock PRIVATE CUDA::cudart)
endif()
Loading