@@ -102,11 +102,10 @@ function(generate_castxml_commandline_flags)
102102 ## ============================
103103
104104 # create the files used to pass the file to include to castxml
105- get_directory_property (include_dir_list INCLUDE_DIRECTORIES)
106- list (APPEND include_dir_list ${ITK_INCLUDE_DIRS} )
105+ set (include_dir_list ${WRAPPER_LIBRARY_INCLUDE_DIRECTORIES} )
107106 list (REMOVE_DUPLICATES include_dir_list)
108107
109- # CONFIG_CASTXML_INC_CONTENTS - variable used for building contents to write with configure_file( )
108+ # CONFIG_CASTXML_INC_CONTENTS - variable used for building contents to write with file(GENERATE )
110109 unset (CONFIG_CASTXML_INC_CONTENTS)
111110 foreach (dir ${include_dir_list} )
112111 set (
@@ -116,6 +115,22 @@ function(generate_castxml_commandline_flags)
116115 endforeach ()
117116 unset (include_dir_list)
118117
118+ foreach (_depend IN LISTS WRAPPER_LIBRARY_LINK_LIBRARIES)
119+ if (TARGET ${_depend} )
120+ set (
121+ CONFIG_CASTXML_INC_CONTENTS
122+ "${CONFIG_CASTXML_INC_CONTENTS} $<LIST :JOIN ,$<LIST :TRANSFORM ,$<TARGET_PROPERTY :${_depend} ,INTERFACE_INCLUDE_DIRECTORIES >,REPLACE ,^(.+)$,\"-I \\1\">,\n >\n "
123+ )
124+ set (
125+ CONFIG_CASTXML_INC_CONTENTS
126+ "${CONFIG_CASTXML_INC_CONTENTS} $<LIST :JOIN ,$<LIST :TRANSFORM ,$<TARGET_PROPERTY :${_depend} ,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES >,REPLACE ,^(.+)$,\"-isystem \" \"\\1\">,\n >\n "
127+ )
128+ set (
129+ CONFIG_CASTXML_INC_CONTENTS
130+ "${CONFIG_CASTXML_INC_CONTENTS} $<LIST :JOIN ,$<LIST :TRANSFORM ,$<TARGET_PROPERTY :${_depend} ,INTERFACE_COMPILE_DEFINITIONS >,REPLACE ,^(.+)$,\"-D \\1\">,\n >\n "
131+ )
132+ endif ()
133+ endforeach ()
119134 set (
120135 CONFIG_CASTXML_INC_CONTENTS
121136 "${CONFIG_CASTXML_INC_CONTENTS} -Qunused-arguments\n "
@@ -129,29 +144,6 @@ function(generate_castxml_commandline_flags)
129144 "${CONFIG_CASTXML_INC_CONTENTS} -DITK_MANUAL_INSTANTIATION\n "
130145 )
131146
132- # Get the compile_definitions of the module added with add_compile_definitions
133- # From the wrapping folder (current)
134- get_directory_property (compile_definition_list COMPILE_DEFINITIONS )
135- # And from the top module folder
136- set (module_folder "${WRAPPER_LIBRARY_SOURCE_DIR } /.." )
137- get_directory_property (
138- compile_definition_list_at_module
139- DIRECTORY "${module_folder} "
140- COMPILE_DEFINITIONS
141- )
142- unset (module_folder)
143- # Merge and remove duplicates
144- list (APPEND compile_definition_list ${compile_definition_list_at_module} )
145- unset (compile_definition_list_at_module)
146- list (REMOVE_DUPLICATES compile_definition_list)
147-
148- foreach (def ${compile_definition_list} )
149- set (
150- CONFIG_CASTXML_INC_CONTENTS
151- "${CONFIG_CASTXML_INC_CONTENTS} \" -D${def} \"\n "
152- )
153- endforeach ()
154- unset (compile_definition_list)
155147 foreach (include_file ${WRAPPER_INCLUDE_FILES} )
156148 if ("${include_file} " MATCHES "<.*>" )
157149 string (APPEND CASTXML_INCLUDES "#include ${include_file} \n " )
@@ -160,15 +152,16 @@ function(generate_castxml_commandline_flags)
160152 endif ()
161153 endforeach ()
162154
163- #Write compile definitions and include paths to file. @CONFIG_CASTXML_INC_CONTENTS@ expanded in configure_file
155+ #Write compile definitions and include paths to file. Generator expressions evaluated at generation time.
164156 set (
165157 castxml_inc_file
166- "${WRAPPER_LIBRARY_OUTPUT_DIR} /castxml_inputs/${WRAPPER_LIBRARY_NAME } .castxml.inc"
158+ "${WRAPPER_LIBRARY_OUTPUT_DIR} /castxml_inputs/${_each_submodule_this_module } .castxml.inc"
167159 )
168- configure_file (
169- "${ITK_WRAP_CASTXML_SOURCE_DIR } /cast_xml.inc.in"
160+ file (
161+ GENERATE
162+ OUTPUT
170163 "${castxml_inc_file} "
171- @ONLY
164+ CONTENT " ${CONFIG_CASTXML_INC_CONTENTS} "
172165 )
173166 unset (CONFIG_CASTXML_INC_CONTENTS)
174167
0 commit comments