CMakeLists.txt 754 B

123456789101112131415
  1. add_executable(SubDirA SubDirA.c)
  2. # Link to a target imported in this directory that would not normally
  3. # be visible to the directory in which TopDir is defined.
  4. target_link_libraries(TopDir PUBLIC SameNameImported)
  5. # Link SubDirA to a target imported in this directory that has the same
  6. # name as a target imported in SubDirB's directory. SubDirB will also
  7. # tell us to link its copy. At compile time we verify both are linked.
  8. target_link_libraries(SubDirA PRIVATE SameNameImported)
  9. # Import a target with the same name as a target imported in SubDirB.
  10. # Distinguish this copy by having a unique usage requirement.
  11. add_library(SameNameImported IMPORTED INTERFACE)
  12. target_compile_definitions(SameNameImported INTERFACE DEF_SameNameImportedSubDirA)