Skip to content

Commit c34fb01

Browse files
committed
COMP: Simplify submodule loading logic
Simplify the ordered loading of submodules. Cleanup local variables names and scope.
1 parent 75a1b9a commit c34fb01

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

Wrapping/TypedefMacros.cmake

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -350,47 +350,32 @@ endmacro()
350350
################################################################################
351351

352352
macro(itk_auto_load_submodules)
353+
# Global vars used: WRAPPER_LIBRARY_SOURCE_DIR
354+
# Global vars modified: WRAPPER_SUBMODULE_ORDER
353355

354356
# Include the *.wrap files in WRAPPER_LIBRARY_SOURCE_DIR. This causes
355357
# corresponding wrap_*.cxx files to be generated WRAPPER_LIBRARY_OUTPUT_DIR,
356358
# and added to the WRAPPER_LIBRARY_SWIG_INPUTS list.
357359
# In addition, this causes the other required wrap_*.cxx files for the entire
358360
# library and each wrapper language to be created.
359-
# Finally, this macro causes the language support files for the templates and
361+
# This macro causes the language support files for the templates and
360362
# library here defined to be created.
361363

362-
# Next, include modules already in WRAPPER_SUBMODULE_ORDER, because those are
363-
# guaranteed to be processed first.
364-
foreach(module ${WRAPPER_SUBMODULE_ORDER})
365-
itk_load_submodule("${module}")
366-
endforeach()
367-
368364
# Now search for other *.wrap files to include
369-
file(GLOB wrap_cmake_files "${WRAPPER_LIBRARY_SOURCE_DIR}/*.wrap")
365+
file(GLOB _wrap_cmake_files "${WRAPPER_LIBRARY_SOURCE_DIR}/*.wrap")
370366
# sort the list of files so we are sure to always get the same order on all system
371367
# and for all builds. That's important for several reasons:
372368
# - the order is important for the order of creation of python template
373369
# - the typemaps files are always the same, and the rebuild can be avoided
374-
list(SORT wrap_cmake_files)
375-
foreach(_file ${wrap_cmake_files})
370+
list(SORT _wrap_cmake_files)
371+
foreach(_file ${_wrap_cmake_files})
376372
# get the module name from module.wrap
377-
get_filename_component(module "${_file}" NAME_WE)
378-
379-
# if the module is already in the list, it means that it is already included
380-
# ... and do not include excluded modules
381-
set(will_include 1)
382-
foreach(already_included ${WRAPPER_SUBMODULE_ORDER})
383-
if("${already_included}" STREQUAL "${module}")
384-
set(will_include 0)
385-
endif()
386-
endforeach()
387-
388-
if(${will_include})
389-
# Add the module name to the list. WRITE_MODULE_FILES uses this list
390-
# to create the master library wrapper file.
391-
list(APPEND WRAPPER_SUBMODULE_ORDER "${module}")
392-
itk_load_submodule("${module}")
393-
endif()
373+
get_filename_component(_module "${_file}" NAME_WE)
374+
list(APPEND WRAPPER_SUBMODULE_ORDER "${_module}")
375+
endforeach()
376+
list(REMOVE_DUPLICATES WRAPPER_SUBMODULE_ORDER)
377+
foreach(_module ${WRAPPER_SUBMODULE_ORDER})
378+
itk_load_submodule("${_module}")
394379
endforeach()
395380
endmacro()
396381

0 commit comments

Comments
 (0)