I have a CMake script where the final executable is linked with my own linker script:
cmake_minimum_required(VERSION 3.1)
project(test_app)
set(LINKER_SCRIPT "linker.ld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${LINKER_SCRIPT}")
add_executable(${PROJECT_NAME}.elf
main.cpp
startup.cpp
)
How do I make an executable dependent also on the linker script file (trigger linking if linker.ld was changed)?
add_custom_target()?add_custom_target(OUTPUT ${PROJECT_NAME}.elf DEPENDS ${LINKER_SCRIPT})but without success.makefilegenerators except - until now - for Ninja (will be fixed with CMake 3.4, see 0014796: LINK_DEPENDS should work with Ninja backend)