diff --git a/Modules/Bridge/NumPy/wrapping/CMakeLists.txt b/Modules/Bridge/NumPy/wrapping/CMakeLists.txt index b9fedf2fc6c..ea10db3cab1 100644 --- a/Modules/Bridge/NumPy/wrapping/CMakeLists.txt +++ b/Modules/Bridge/NumPy/wrapping/CMakeLists.txt @@ -1,5 +1,6 @@ if(ITK_WRAP_PYTHON) itk_wrap_module(ITKBridgeNumPy) + list(APPEND WRAPPER_LIBRARY_INCLUDE_DIRECTORIES ${Python3_INCLUDE_DIRS}) set( WRAPPER_SUBMODULE_ORDER itkPyBuffer diff --git a/Modules/Core/Common/wrapping/CMakeLists.txt b/Modules/Core/Common/wrapping/CMakeLists.txt index 59a95e1e5ae..b72c818c322 100644 --- a/Modules/Core/Common/wrapping/CMakeLists.txt +++ b/Modules/Core/Common/wrapping/CMakeLists.txt @@ -1,5 +1,5 @@ itk_wrap_module(ITKCommon) - +list(APPEND WRAPPER_LIBRARY_INCLUDE_DIRECTORIES ${Python3_INCLUDE_DIRS}) set( WRAPPER_SUBMODULE_ORDER itkFixedArray diff --git a/Wrapping/TypedefMacros.cmake b/Wrapping/TypedefMacros.cmake index 1fcfb69fa5d..4d034eab42d 100644 --- a/Wrapping/TypedefMacros.cmake +++ b/Wrapping/TypedefMacros.cmake @@ -148,7 +148,6 @@ macro(itk_wrap_module library_name) # be linked to the wrapper library. set( WRAPPER_LIBRARY_LINK_LIBRARIES - ${ITK_LIBRARIES} ${ITK_LIBRARY_NAMESPACE}::${library_name}Module ) diff --git a/Wrapping/macro_files/itk_auto_load_submodules.cmake b/Wrapping/macro_files/itk_auto_load_submodules.cmake index 30008b0f24b..7eaad7d35a8 100644 --- a/Wrapping/macro_files/itk_auto_load_submodules.cmake +++ b/Wrapping/macro_files/itk_auto_load_submodules.cmake @@ -102,11 +102,10 @@ function(generate_castxml_commandline_flags) ## ============================ # create the files used to pass the file to include to castxml - get_directory_property(include_dir_list INCLUDE_DIRECTORIES) - list(APPEND include_dir_list ${ITK_INCLUDE_DIRS}) + set(include_dir_list ${WRAPPER_LIBRARY_INCLUDE_DIRECTORIES}) list(REMOVE_DUPLICATES include_dir_list) - # CONFIG_CASTXML_INC_CONTENTS - variable used for building contents to write with configure_file() + # CONFIG_CASTXML_INC_CONTENTS - variable used for building contents to write with file(GENERATE) unset(CONFIG_CASTXML_INC_CONTENTS) foreach(dir ${include_dir_list}) set( @@ -116,6 +115,22 @@ function(generate_castxml_commandline_flags) endforeach() unset(include_dir_list) + foreach(_depend IN LISTS WRAPPER_LIBRARY_LINK_LIBRARIES) + if(TARGET ${_depend}) + set( + CONFIG_CASTXML_INC_CONTENTS + "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-I\\1\">,\n>\n" + ) + set( + CONFIG_CASTXML_INC_CONTENTS + "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-isystem\" \"\\1\">,\n>\n" + ) + set( + CONFIG_CASTXML_INC_CONTENTS + "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-D\\1\">,\n>\n" + ) + endif() + endforeach() set( CONFIG_CASTXML_INC_CONTENTS "${CONFIG_CASTXML_INC_CONTENTS}-Qunused-arguments\n" @@ -129,29 +144,6 @@ function(generate_castxml_commandline_flags) "${CONFIG_CASTXML_INC_CONTENTS}-DITK_MANUAL_INSTANTIATION\n" ) - # Get the compile_definitions of the module added with add_compile_definitions - # From the wrapping folder (current) - get_directory_property(compile_definition_list COMPILE_DEFINITIONS) - # And from the top module folder - set(module_folder "${WRAPPER_LIBRARY_SOURCE_DIR}/..") - get_directory_property( - compile_definition_list_at_module - DIRECTORY "${module_folder}" - COMPILE_DEFINITIONS - ) - unset(module_folder) - # Merge and remove duplicates - list(APPEND compile_definition_list ${compile_definition_list_at_module}) - unset(compile_definition_list_at_module) - list(REMOVE_DUPLICATES compile_definition_list) - - foreach(def ${compile_definition_list}) - set( - CONFIG_CASTXML_INC_CONTENTS - "${CONFIG_CASTXML_INC_CONTENTS}\"-D${def}\"\n" - ) - endforeach() - unset(compile_definition_list) foreach(include_file ${WRAPPER_INCLUDE_FILES}) if("${include_file}" MATCHES "<.*>") string(APPEND CASTXML_INCLUDES "#include ${include_file}\n") @@ -160,15 +152,16 @@ function(generate_castxml_commandline_flags) endif() endforeach() - #Write compile definitions and include paths to file. @CONFIG_CASTXML_INC_CONTENTS@ expanded in configure_file + #Write compile definitions and include paths to file. Generator expressions evaluated at generation time. set( castxml_inc_file - "${WRAPPER_LIBRARY_OUTPUT_DIR}/castxml_inputs/${WRAPPER_LIBRARY_NAME}.castxml.inc" + "${WRAPPER_LIBRARY_OUTPUT_DIR}/castxml_inputs/${_each_submodule_this_module}.castxml.inc" ) - configure_file( - "${ITK_WRAP_CASTXML_SOURCE_DIR}/cast_xml.inc.in" + file( + GENERATE + OUTPUT "${castxml_inc_file}" - @ONLY + CONTENT "${CONFIG_CASTXML_INC_CONTENTS}" ) unset(CONFIG_CASTXML_INC_CONTENTS) diff --git a/Wrapping/macro_files/itk_end_wrap_module.cmake b/Wrapping/macro_files/itk_end_wrap_module.cmake index 83a24fc3a7b..bb7288d3760 100644 --- a/Wrapping/macro_files/itk_end_wrap_module.cmake +++ b/Wrapping/macro_files/itk_end_wrap_module.cmake @@ -392,19 +392,7 @@ PyModule_AddObject(m, \"_C_API\", cAPIObject); ${DO_NOT_WAIT_FOR_THREADS_CALLS} " ) - elseif( - "ITKCommon" - IN_LIST - WRAPPER_LIBRARY_LINK_LIBRARIES - OR - "${ITK_LIBRARY_NAMESPACE}::ITKCommon" - IN_LIST - WRAPPER_LIBRARY_LINK_LIBRARIES - OR - "${ITK_LIBRARY_NAMESPACE}::ITKCommonModule" - IN_LIST - WRAPPER_LIBRARY_LINK_LIBRARIES - ) + elseif(NOT WRAPPER_LIBRARY_NAME STREQUAL "ITKPyBase") set( ITK_WRAP_PYTHON_GLOBAL_TIMESTAMP_DECLS "