cmake: linker: Use depfile for Makefile generators

Since CMake 3.20 DEPFILE has been supported by Makefile generators.

Simplify the CMake code by using DEPFILE for both Ninja and Makefile
generators.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-01-07 11:20:37 +01:00 committed by Maureen Helm
commit 34c79072c5

View file

@ -50,13 +50,10 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
set(template_script_defines ${linker_pass_define})
list(TRANSFORM template_script_defines PREPEND "-D")
# Different generators deal with depfiles differently.
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
# Note that the IMPLICIT_DEPENDS option is currently supported only
# for Makefile generators and will be ignored by other generators.
set(linker_script_dep IMPLICIT_DEPENDS C ${LINKER_SCRIPT})
elseif(CMAKE_GENERATOR STREQUAL "Ninja")
# Using DEPFILE with other generators than Ninja is an error.
# Only Ninja and Makefile generators support DEPFILE.
if((CMAKE_GENERATOR STREQUAL "Ninja")
OR (CMAKE_GENERATOR MATCHES "Makefiles")
)
set(linker_script_dep DEPFILE ${PROJECT_BINARY_DIR}/${linker_script_gen}.dep)
else()
# TODO: How would the linker script dependencies work for non-linker