Skip to content

Commit

Permalink
[CMake] improve exported config
Browse files Browse the repository at this point in the history
- find_package Boost REQUIRED as its include files are needed
- remove ITK_USE_FILE as not needed

Fixes UCL#432
  • Loading branch information
KrisThielemans committed Nov 14, 2024
1 parent de7e48a commit dc2640f
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit dc2640f

Please sign in to comment.