Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt
3156 views
1
add_executable(SubDirB SubDirB.c)
2
3
# Link to a target imported in this directory that would not normally
4
# be visible to the directory in which TopDir is defined.
5
target_link_libraries(TopDir PUBLIC debug SameNameImported optimized SameNameImported)
6
# Do the same through an interface library in the top.
7
target_link_libraries(TopDirInterface INTERFACE debug SameNameImported2 optimized SameNameImported2)
8
9
# Link to a list of targets imported in this directory that would not
10
# normally be visible to the directory in which TopDir is defined.
11
target_link_libraries(TopDir PUBLIC "$<1:SameNameImported;SameNameImported>")
12
13
# Link SubDirA to a target imported in this directory that has the same
14
# name as a target imported in SubDirA's directory. We verify when
15
# compiling SubDirA that it sees our target and its own.
16
target_link_libraries(SubDirA PRIVATE SameNameImported)
17
18
# Import a target with the same name as a target imported in SubDirA.
19
# Distinguish this copy by having a unique usage requirement.
20
add_library(SameNameImported IMPORTED INTERFACE)
21
target_compile_definitions(SameNameImported INTERFACE DEF_SameNameImportedSubDirB)
22
add_library(SameNameImported2 INTERFACE IMPORTED)
23
target_compile_definitions(SameNameImported2 INTERFACE DEF_SameNameImported2SubDirB)
24
25