Skip to content
Open
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
3 changes: 3 additions & 0 deletions CMake/ITKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ set(ITK_BUILD_DOCUMENTATION "@ITK_BUILD_DOCUMENTATION@")
# List of available ITK modules.
set(ITK_MODULES_ENABLED "@ITK_CONFIG_MODULES_ENABLED@")

# Define the ITK library namespace for CMake targets, without the trailing ::.
set(ITK_LIBRARY_NAMESPACE "@ITK_LIBRARY_NAMESPACE@")

# Import ITK targets.
set(ITK_CONFIG_TARGETS_FILE "@ITK_CONFIG_TARGETS_FILE@")
if(NOT ITK_TARGETS_IMPORTED@ITK_CONFIG_TARGETS_CONDITION@)
Expand Down
28 changes: 24 additions & 4 deletions CMake/ITKFactoryRegistration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@
# Caveats
# -------
#
# Since the both include directory containing the registration manager headers
# and the `ITK_IO_FACTORY_REGISTER_MANAGER` COMPILE_DEFINITIONS are set as
# directory properties, including external project (themselves including ITK)
# after including ITK can have unintended side effects.
# The include directory containing the registration manager headers and the
# `ITK_<FACTORY_NAME>_FACTORY_REGISTER_MANAGER` COMPILE_DEFINITIONS are set as
# target interface properties on the factory meta-module targets (ITKImageIO,
# ITKMeshIO, ITKTransformIO, ITKFFTImageFilterInit). This ensures proper propagation
# to dependent targets through modern CMake usage requirements.
#

# _itk_configure_FactoryRegisterManager(<factory_type> <formats>)
Expand All @@ -148,6 +149,8 @@
# `<CMAKE_CURRENT_BINARY_DIR>/ITKFactoryRegistration/`.
#
# Header is named using the template `itk<factory_type>FactoryRegisterManager.h`
# The include directory and compile definitions are added to the corresponding
# factory meta-module target's INTERFACE properties.
#
function(_itk_configure_FactoryRegisterManager factory_type formats)
set(LIST_OF_FACTORIES_REGISTRATION "")
Expand All @@ -169,6 +172,23 @@ function(_itk_configure_FactoryRegisterManager factory_type formats)
"${CMAKE_CURRENT_BINARY_DIR}/ITKFactoryRegistration/itk${factory_type}FactoryRegisterManager.h"
@ONLY
)

# These functions may be called in the ITK source ( or a fetch content sub-project ),
# so support is needed when the namespaced meta-module target is an alias to the real target.
set(_meta_module ${ITK_LIBRARY_NAMESPACE}::ITK${factory_type})
get_property(
aliased_target_name
TARGET ${_meta_module}
PROPERTY ALIASED_TARGET
)
if(aliased_target_name)
set(_meta_module ${aliased_target_name})
endif()
target_include_directories(
${_meta_module}
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/ITKFactoryRegistration>"
)
endfunction()

# _itk_ADD_FACTORY_REGISTRATION(<registration_list_var> <names_list_var> <module_name> <factory_name>)
Expand Down
8 changes: 7 additions & 1 deletion CMake/ITKModuleAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ macro(_itk_module_config_recurse ns mod)
list(APPEND _${ns}_USED_MODULES ${mod})
itk_module_load("${mod}")
list(APPEND ${ns}_LIBRARIES ${${mod}_LIBRARIES})
list(APPEND ${ns}_INTERFACE_LIBRARIES ${${mod}_INTERFACE_LIBRARY})
list(APPEND ${ns}_INCLUDE_DIRS ${${mod}_INCLUDE_DIRS})
list(APPEND ${ns}_LIBRARY_DIRS ${${mod}_LIBRARY_DIRS})
list(APPEND ${ns}_RUNTIME_LIBRARY_DIRS ${${mod}_RUNTIME_LIBRARY_DIRS})
Expand Down Expand Up @@ -75,6 +76,7 @@ endmacro()
# <module>_TRANSITIVE_DEPENDS = List of dependencies on other modules (public link, compile)
# <module>_PRIVATE_DEPENDS = List of dependencies on other modules (private link)
# <module>_LIBRARIES = Libraries to link
# <module>_INTERFACE_LIBRARY = Interface library for module
# <module>_INCLUDE_DIRS = Header search path
# <module>_LIBRARY_DIRS = Library search path (for outside dependencies)
# <module>_RUNTIME_LIBRARY_DIRS = Runtime linker search path
Expand All @@ -97,7 +99,8 @@ endmacro()
# itk_module_config(<namespace> [modules...])
#
# Configures variables describing the given modules and their dependencies:
# <namespace>_LIBRARIES = Libraries to link
# <namespace>_LIBRARIES = Libraries
# <namespace>_INTERFACE_LIBRARIES = Interface libraries to link with public interfaces
# <namespace>_INCLUDE_DIRS = Header search path
# <namespace>_LIBRARY_DIRS = Library search path (for outside dependencies)
# <namespace>_RUNTIME_LIBRARY_DIRS = Runtime linker search path
Expand All @@ -123,6 +126,7 @@ endmacro()
# future. For more details, read documentation in CMake/UseITK.cmake.
macro(itk_module_config ns)
set(${ns}_LIBRARIES "")
set(${ns}_INTERFACE_LIBRARIES "")
set(${ns}_INCLUDE_DIRS "")
set(${ns}_LIBRARY_DIRS "")
set(${ns}_RUNTIME_LIBRARY_DIRS "")
Expand All @@ -143,6 +147,7 @@ macro(itk_module_config ns)
foreach(
v
${ns}_LIBRARIES
${ns}_INTERFACE_LIBRARIES
${ns}_INCLUDE_DIRS
${ns}_LIBRARY_DIRS
${ns}_RUNTIME_LIBRARY_DIRS
Expand All @@ -153,6 +158,7 @@ macro(itk_module_config ns)
list(REMOVE_DUPLICATES ${v})
endif()
endforeach()

foreach(_factory ${${ns}_FACTORY_LIST})
list(SORT ${ns}_${_factory}) # Sort to ensure a deterministic order
endforeach()
Expand Down
37 changes: 37 additions & 0 deletions CMake/ITKModuleEnablement.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,45 @@ macro(init_module_vars)
"${ITK_INSTALL_PACKAGE_DIR}/ITKTargets.cmake"
)
set(${itk-module}-targets-build "${ITK_BINARY_DIR}/ITKTargets.cmake")

set(${itk-module}-targets-namespace "")
if(ITK_LIBRARY_NAMESPACE)
set(${itk-module}-targets-namespace "${ITK_LIBRARY_NAMESPACE}::")
endif()
endmacro()

#----------------------------------------------------------------------
# Create factory meta-module interface libraries
# These are created for ITKImageIO, ITKMeshIO, ITKTransformIO and FFTImageFilterInit factories
foreach(_factory_name IN ITEMS ImageIO MeshIO TransformIO FFTImageFilterInit)
set(itk-module ITK${_factory_name})
if(NOT TARGET ${itk-module})
add_library(${itk-module} INTERFACE)

init_module_vars(${itk-module})
set(ITK_MODULE_${itk-module}_DECLARED 1)

# Factory modules will be added as dependencies to this meta-module.
# When itk_generate_factory_registration() is called, it adds the include
# directory containing the generated FactoryRegisterManager header file.
#
# Note: Compilation errors like "itkImageIOFactoryRegisterManager.h: No such file or directory"
# indicate that itk_generate_factory_registration() has not been called to generate the header files.

# Add factory registration compile definition
string(TOUPPER ${_factory_name} _factory_uc)
target_compile_definitions(
${itk-module}
INTERFACE
ITK_${_factory_uc}_FACTORY_REGISTER_MANAGER
)

# Export and install the factory interface library
itk_module_target_export(${itk-module})
itk_module_target_install(${itk-module})
endif()
endforeach()

# Build all modules.
foreach(itk-module ${ITK_MODULES_ENABLED})
if(NOT ${itk-module}_IS_TEST)
Expand Down
17 changes: 16 additions & 1 deletion CMake/ITKModuleHeaderTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,24 @@ macro(itk_module_headertest _name)
target_link_libraries(
${_test_name}
PUBLIC
${${_name}_LIBRARIES}
ITK::${_name}Module
itksys
)

# Add module include directories to target
target_include_directories(
${_test_name}
PRIVATE
${${_name}_GENEX_INCLUDE_DIRS}
)

# Add module system include directories to target
target_include_directories(
${_test_name}
PRIVATE
${${_name}_GENEX_SYSTEM_INCLUDE_DIRS}
)

target_link_options(
${_test_name}
PRIVATE
Expand Down
8 changes: 8 additions & 0 deletions CMake/ITKModuleInfo.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ set(@itk-module@_DEPENDS "@itk-module-DEPENDS@")
set(@itk-module@_PUBLIC_DEPENDS "@itk-module-PUBLIC_DEPENDS@")
set(@itk-module@_TRANSITIVE_DEPENDS "@itk-module-TRANSITIVE_DEPENDS@")
set(@itk-module@_PRIVATE_DEPENDS "@itk-module-PRIVATE_DEPENDS@")
set(@itk-module@_LIBRARIES_DEPRECATED "@itk-module-LIBRARIES_DEPRECATED@")
set(@itk-module@_LIBRARIES "@itk-module-LIBRARIES@")
set(@itk-module@_INTERFACE_LIBRARY "@itk-module-INTERFACE_LIBRARY@")
set(@itk-module@_INCLUDE_DIRS "@itk-module-INCLUDE_DIRS@")
set(@itk-module@_LIBRARY_DIRS "@itk-module-LIBRARY_DIRS@")
set(@itk-module@_RUNTIME_LIBRARY_DIRS "@itk-module-RUNTIME_LIBRARY_DIRS@")
set(@itk-module@_TARGETS_FILE "@itk-module-TARGETS_FILE@")
set(@itk-module@_FACTORY_NAMES "@itk-module-FACTORY_NAMES@")

# Create deprecated library interface wrappers
# TODO



@itk-module-EXPORT_CODE@
Loading
Loading