PublicSources.cmake 635 B

1234567891011121314151617181920
  1. cmake_policy(SET CMP0076 NEW)
  2. enable_language(C)
  3. # Test that an interface library can have PUBLIC sources.
  4. # This causes the target to appear in the build system
  5. # *and* causes consumers to use the source.
  6. add_library(iface INTERFACE)
  7. target_sources(iface
  8. PUBLIC iface.c
  9. # Private sources do not compile here or propagate.
  10. PRIVATE iface_broken.c
  11. )
  12. # Test that an intermediate interface library does not get the
  13. # sources and does not appear in the build system.
  14. add_library(iface2 INTERFACE)
  15. target_link_libraries(iface2 INTERFACE iface)
  16. add_executable(use_iface use_iface.c)
  17. target_link_libraries(use_iface PRIVATE iface2)