summaryrefslogtreecommitdiffstats
path: root/Modules/AddFileDependencies.cmake
diff options
context:
space:
mode:
authorAnakin Skywalker <hex7c3@gmail.com>2021-02-05 20:43:13 (GMT)
committerBrad King <brad.king@kitware.com>2021-02-08 17:21:43 (GMT)
commit0f6fc388ea0c539d783e8f74715b5049112a52f6 (patch)
tree004197a06bb9132d5863236e02f6d1ae094327ab /Modules/AddFileDependencies.cmake
parentacb33d0904121f10891cb3aa0622b11d4e527304 (diff)
downloadCMake-0f6fc388ea0c539d783e8f74715b5049112a52f6.zip
CMake-0f6fc388ea0c539d783e8f74715b5049112a52f6.tar.gz
CMake-0f6fc388ea0c539d783e8f74715b5049112a52f6.tar.bz2
AddFileDependencies: Avoid leaking temporary variable
Convert `add_file_dependencies` to a function. Simplify the implementation using `set_property` with `APPEND`.
Diffstat (limited to 'Modules/AddFileDependencies.cmake')
-rw-r--r--Modules/AddFileDependencies.cmake15
1 files changed, 4 insertions, 11 deletions
diff --git a/Modules/AddFileDependencies.cmake b/Modules/AddFileDependencies.cmake
index 598a52f..c038858 100644
--- a/Modules/AddFileDependencies.cmake
+++ b/Modules/AddFileDependencies.cmake
@@ -9,20 +9,13 @@ Add dependencies to a source file.
.. code-block:: cmake
- ADD_FILE_DEPENDENCIES(<source> <files>)
+ add_file_dependencies(<source> <files>)
Adds the given ``<files>`` to the dependencies of file ``<source>``.
#]=======================================================================]
-macro(ADD_FILE_DEPENDENCIES _file)
+function(add_file_dependencies _file)
- get_source_file_property(_deps ${_file} OBJECT_DEPENDS)
- if (_deps)
- set(_deps ${_deps} ${ARGN})
- else ()
- set(_deps ${ARGN})
- endif ()
+ set_property(SOURCE "${_file}" APPEND PROPERTY OBJECT_DEPENDS "${ARGN}")
- set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}")
-
-endmacro()
+endfunction()