211
211
# :command:`install` commands, otherwise <Name> is used.
212
212
#
213
213
# If the ``OVERRIDE_MODULE_PATH`` is set, the autogenerated ``<Name>Config.cmake``
214
- # file temporarily overrides the ``CMAKE_MODULE_PATH`` with the specified paths.
214
+ # file temporarily prepends the ``CMAKE_MODULE_PATH`` with the specified paths.
215
215
216
216
#=============================================================================
217
217
# Copyright 2013 Istituto Italiano di Tecnologia (IIT)
@@ -576,13 +576,11 @@ ${_compatibility_vars}
576
576
endif ()
577
577
578
578
unset (PACKAGE_DEPENDENCIES )
579
+ set (_overridden_module_path_list "" )
579
580
if (DEFINED _IBPF_DEPENDENCIES )
580
581
set (PACKAGE_DEPENDENCIES "#### Expanded from @PACKAGE_DEPENDENCIES@ by install_basic_package_files() ####\n\n include(CMakeFindDependencyMacro)\n " )
581
582
582
583
if (DEFINED _IBPF_OVERRIDE_MODULE_PATH )
583
-
584
- string (APPEND PACKAGE_DEPENDENCIES "set(CMAKE_MODULE_PATH_BK_${_IBPF_VARS_PREFIX} \$ {CMAKE_MODULE_PATH})\n " )
585
- set (_overridden_module_path "" )
586
584
foreach (_path ${_IBPF_OVERRIDE_MODULE_PATH} )
587
585
588
586
if (IS_ABSOLUTE ${_path} )
@@ -592,9 +590,12 @@ ${_compatibility_vars}
592
590
endif ()
593
591
594
592
file (RELATIVE_PATH _relative_path ${CMAKE_INSTALL_PREFIX} ${_absolute_module_path} )
595
- string (APPEND _overridden_module_path " \$ {PACKAGE_PREFIX_DIR}/${_relative_path} " )
593
+ string (APPEND _overridden_module_path_list "; \$ {PACKAGE_PREFIX_DIR}/${_relative_path} " )
596
594
endforeach ()
597
- string (APPEND PACKAGE_DEPENDENCIES "set(CMAKE_MODULE_PATH${_overridden_module_path} )\n " )
595
+ string (APPEND PACKAGE_DEPENDENCIES "foreach(overridden_module_path ${_overridden_module_path_list} )\n " )
596
+ string (APPEND PACKAGE_DEPENDENCIES " list(PREPEND CMAKE_MODULE_PATH \$ {overridden_module_path})\n " )
597
+ string (APPEND PACKAGE_DEPENDENCIES "endforeach()\n " )
598
+
598
599
# If OVERRIDE_MODULE_PATH is used, then if a dependency is not found find_dependency will
599
600
# halt the execution of the <package>config.cmake script, never restoring the original
600
601
# value of CMAKE_MODULE_PATH. For this reason, in this case we just use find_package
@@ -654,7 +655,9 @@ endif()
654
655
endif ()
655
656
656
657
if (DEFINED _IBPF_OVERRIDE_MODULE_PATH )
657
- string (APPEND PACKAGE_DEPENDENCIES "set(CMAKE_MODULE_PATH \$ {CMAKE_MODULE_PATH_BK_${_IBPF_VARS_PREFIX} })\n " )
658
+ string (APPEND PACKAGE_DEPENDENCIES "foreach(overridden_module_path ${_overridden_module_path_list} )\n " )
659
+ string (APPEND PACKAGE_DEPENDENCIES " list(REMOVE_ITEM CMAKE_MODULE_PATH \$ {overridden_module_path})\n " )
660
+ string (APPEND PACKAGE_DEPENDENCIES "endforeach()\n " )
658
661
endif ()
659
662
660
663
set (PACKAGE_DEPENDENCIES "${PACKAGE_DEPENDENCIES} \n ###############################################################################\n " )
@@ -709,3 +712,4 @@ endif()
709
712
FILE "${_targets_filename} "
710
713
COMPONENT ${_IBPF_COMPONENT} )
711
714
endfunction ()
715
+
0 commit comments