I have a linker script (link1.ld
) in depL
that I need to use in depA
.
Please could someone explain to me how make depL
make the link1.ld
script available to depA
so that the following works:
target_link_options(depA PRIVATE -T#[[Valid reference to]]link1.ld)
The full directory structure and file content for my example is below.
Directory Structure
.
│ CMakeLists.txt
│
├───depA
│ │ CMakeLists.txt
│ │
│ └───src
│ depA.c
│
└───depL
│ CMakeLists.txt
│
├───src
│ link1.ld
│
└───include
mem_map.h
Top-Level CMakeLists.txt
cmake_minimum_required(VERSION 3.29)
project(proj_cmake1 C)
add_subdirectory(depA)
add_subdirectory(depL)
depL CMakeLists.txt
cmake_minimum_required(VERSION 3.29)
project(proj_depL C)
add_library(depL INTERFACE)
target_sources(depL INTERFACE src/link1.ld)
target_include_directories(depL INTERFACE include)
depA CMakeLists.txt
cmake_minimum_required(VERSION 3.29)
project(proj_depA C)
add_executable(depA src/depA.c)
target_link_libraries (depA depL)
target_link_options(depA PRIVATE -T#[[Valid reference to]]link1.ld)