Skip to content

Commit

Permalink
ENH: Add support for OPTIONAL_COMPONENTS
Browse files Browse the repository at this point in the history
Add support for find_package(ITK... OPTIONAL_COMPONENTS ITKModule).
  • Loading branch information
blowekamp committed Oct 11, 2023
1 parent 80446b1 commit ee84d1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions CMake/ITKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# to load ITK's settings for an external project.
#
# ITK components can be specified when using the CMake function `find_package()`
# E.g. find_package(ITK COMPONENTS ITKCommon ITKIOImageBase ITKIONRRD ITKImageGradient)
# E.g. find_package(ITK COMPONENTS ITKCommon ITKIOImageBase OPTIONAL_COMPONENTS ITKIONRRD )
#
# The components listed in this call must be ITK module names or factories
# (e.g. ITKImageIO, ITKTransformIO). Factories allow the user to load all the
Expand Down Expand Up @@ -83,8 +83,13 @@ itk_module_config(ITK ${ITK_MODULES_ENABLED})

# Compute set of requested modules.
if(ITK_FIND_COMPONENTS)
set(ITK_MODULES_REQUESTED ${ITK_FIND_COMPONENTS})
# Specific modules requested by find_package(ITK).
# Specific modules required by find_package(ITK) or optional and available.
set(ITK_MODULES_REQUESTED "")
foreach(M ${ITK_FIND_COMPONENTS})
if(ITK_FIND_REQUIRED_${M} OR M IN_LIST ITK_MODULES_ENABLED)
LIST(APPEND ITK_MODULES_REQUESTED "${M}")
endif()
endforeach()
itk_module_config(ITK ${ITK_MODULES_REQUESTED})
else()
set(ITK_MODULES_REQUESTED ${ITK_MODULES_ENABLED})
Expand Down
9 changes: 7 additions & 2 deletions CMake/ITKInternalConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@

# Compute set of requested modules.
if(ITK_FIND_COMPONENTS)
# Specific modules requested by find_package(ITK).
set(ITK_MODULES_REQUESTED "${ITK_FIND_COMPONENTS}")
# Specific modules required by find_package(ITK) or optional and available.
set(ITK_MODULES_REQUESTED "")
foreach(M ${ITK_FIND_COMPONENTS})
if(ITK_FIND_REQUIRED_${M} OR M IN_LIST ITK_MODULES_ENABLED)
LIST(APPEND ITK_MODULES_REQUESTED "${M}")
endif()
endforeach()
else()
# No specific modules requested. Use all of them.
set(ITK_MODULES_REQUESTED "")
Expand Down

0 comments on commit ee84d1e

Please sign in to comment.