Merge topic 'FindPatch-script-mode'

04c5492cb0 FindPatch: Define imported target only for PROJECT CMAKE_ROLE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10164
This commit is contained in:
Brad King
2025-01-15 14:32:20 +00:00
committed by Kitware Robot
2 changed files with 16 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
FindPatch
---------
* The :module:`FindPatch` module now supports running in script mode by skipping
the creation of the imported target.
+11 -1
View File
@@ -19,6 +19,9 @@ The following :prop_tgt:`IMPORTED` targets are also defined:
``Patch::patch``
The command-line executable.
.. versionchanged:: 3.32
Imported target is defined only when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``.
Example usage:
.. code-block:: cmake
@@ -60,12 +63,19 @@ endif()
mark_as_advanced(Patch_EXECUTABLE)
if(Patch_EXECUTABLE AND NOT TARGET Patch::patch)
get_property(_patch_role GLOBAL PROPERTY CMAKE_ROLE)
if(
_patch_role STREQUAL "PROJECT"
AND Patch_EXECUTABLE
AND NOT TARGET Patch::patch
)
add_executable(Patch::patch IMPORTED)
set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${Patch_EXECUTABLE})
endif()
unset(_patch_path)
unset(_patch_role)
unset(_doc)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)