Skip to content

Commit 1b8fb86

Browse files
committed
refactor: Replace find_package(ITK) with FetchContent integration
- Replace direct find_package(ITK) with CMake/ITKFetchContent.cmake - FetchContent intelligently finds pre-built ITK via ITK_DIR or downloads - Fix itk_module_impl condition: use itk-module variable instead of COMMAND to properly distinguish between superbuild/module context vs standalone
1 parent 6684a68 commit 1b8fb86

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ endif()
7979
#Optional if we are building as an ITK module, these variables will be pre-defined
8080
if(NOT ITK_VERSION)
8181
# To get the ITK version information from external package when building
82-
# stand alone, ITK is required.
83-
find_package(ITK 5.4.2 REQUIRED)
82+
# stand alone, ITK is required. ITK can be provided via ITK_DIR or fetched
83+
# from source using FetchContent.
84+
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/ITKFetchContent.cmake)
8485
endif()
8586
set(ITKSphinxExamples_VERSION_MAJOR ${ITK_VERSION_MAJOR})
8687
set(ITKSphinxExamples_VERSION_MINOR ${ITK_VERSION_MINOR})
@@ -308,7 +309,8 @@ configure_file("${ITKSphinxExamples_SOURCE_DIR}/Utilities/CreateNewExample.py.in
308309

309310
# Build the example executables?
310311
option(BUILD_EXECUTABLES "Build the example executables." ON)
311-
if(COMMAND itk_module_impl)
312+
# Use itk-module (set by ITK's module system) to detect if we are building as an ITK module or stand alone.
313+
if(itk-module)
312314
itk_module_impl()
313315
else()
314316
if(BUILD_EXECUTABLES)

0 commit comments

Comments
 (0)