这是我的CMakeLists.txt。更改链接器命令文件后如何让cmake重新链接。有两个文件,flash_addr.icf和linker.icf
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
set(MODULE_NAME "TEST")
# Linker commmand files
set(FLASHER_SCRIPT "${CMAKE_SOURCE_DIR}/flash_addr.icf")
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/linker.icf")
# compiler and linker options
include(${CMAKE_SOURCE_DIR}/s32k14x_iar_config.cmake)
# source and header files
include(${CMAKE_SOURCE_DIR}/include_list.cmake)
include(${CMAKE_SOURCE_DIR}/source_list.cmake)
project("${MODULE_NAME}")
include_directories(${INCLUDE_DIRS})
add_executable(${MODULE_NAME} ${INCLUDE_DIRS} ${SOURCE_DIRS})
在CMAKE: How to add dependency on linker script for executable
中找到了解决方案set_target_properties($ {MODULE_NAME} PROPERTIES LINK_DEPENDS $ {LINKER_SCRIPT}) set_target_properties($ {MODULE_NAME} PROPERTIES LINK_DEPENDS $ {FLASHER_SCRIPT})