From c465015e2f63d984b8086d60335a8fd6caf27b33 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Sat, 2 May 2026 08:37:25 -0500 Subject: [PATCH] COMP: Backport wrapping castxml genexes to CMake 3.22.1 (issue #6191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #5842 introduced $> generator expressions in itk_auto_load_submodules.cmake. Those operators landed in CMake 3.27 (2023-07) but ITK's cmake_minimum_required is 3.22.1; on older CMake they silently expand to empty at file(GENERATE) time, producing castxml.inc files with no -I/-isystem/-D flags and breaking Python wrapping. Rewrite the three affected sites with $ (CMake 3.0+), carrying the per-element wrapping in the glue string and guarded by $<$:…> so an empty property emits nothing. Generated castxml.inc bytes are byte-identical to the 3.27+ form for both populated and empty target properties. Revert when ITK's CMake floor reaches 3.27 (block comment marks the lines). --- Wrapping/macro_files/itk_auto_load_submodules.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Wrapping/macro_files/itk_auto_load_submodules.cmake b/Wrapping/macro_files/itk_auto_load_submodules.cmake index 527669a6368..4ca246ebc1e 100644 --- a/Wrapping/macro_files/itk_auto_load_submodules.cmake +++ b/Wrapping/macro_files/itk_auto_load_submodules.cmake @@ -119,17 +119,20 @@ function(generate_castxml_commandline_flags) foreach(_depend IN LISTS WRAPPER_LIBRARY_LINK_LIBRARIES) if(TARGET ${_depend}) + # $ (CMake 3.0+) carries the per-element prefix in + # the glue string; $<$:…> guards against empty-property + # output of a stray "-I" / "-D" / "-isystem". set( CONFIG_CASTXML_INC_CONTENTS - "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-I\\1\">,\n>\n" + "${CONFIG_CASTXML_INC_CONTENTS}$<$>:\"-I$,\"\n\"-I>\">\n" ) set( CONFIG_CASTXML_INC_CONTENTS - "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-isystem\" \"\\1\">,\n>\n" + "${CONFIG_CASTXML_INC_CONTENTS}$<$>:\"-isystem\" \"$,\"\n\"-isystem\" \">\">\n" ) set( CONFIG_CASTXML_INC_CONTENTS - "${CONFIG_CASTXML_INC_CONTENTS}$,REPLACE,^(.+)$,\"-D\\1\">,\n>\n" + "${CONFIG_CASTXML_INC_CONTENTS}$<$>:\"-D$,\"\n\"-D>\">\n" ) endif() endforeach()