CMakeLists.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. cmake_minimum_required(VERSION 2.8)
  2. project(InterfaceLibrary)
  3. add_library(iface_nodepends INTERFACE)
  4. target_compile_definitions(iface_nodepends INTERFACE IFACE_DEFINE)
  5. add_subdirectory(headerdir)
  6. # Add an interface target in a subdirectory that uses an imported interface.
  7. add_subdirectory(ifacedir)
  8. # Poison an imported interface with the same name as that in the subdir
  9. # to ensure that the transitive lookup occurs in the subdir.
  10. add_library(imp::iface INTERFACE IMPORTED)
  11. set_property(TARGET imp::iface APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP)
  12. set_property(TARGET imp::iface PROPERTY INTERFACE_SOMEPROP OFF)
  13. set_property(TARGET imp::iface PROPERTY INTERFACE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp)
  14. add_library(objlib OBJECT obj.cpp)
  15. add_library(iface_objlib INTERFACE)
  16. target_sources(iface_objlib INTERFACE $<TARGET_OBJECTS:objlib>)
  17. add_executable(InterfaceLibrary definetestexe.cpp)
  18. target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface iface_objlib)
  19. add_subdirectory(libsdir)
  20. add_executable(sharedlibtestexe sharedlibtestexe.cpp)
  21. target_link_libraries(sharedlibtestexe shared_iface imported::iface)
  22. add_library(broken EXCLUDE_FROM_ALL broken.cpp)
  23. add_library(iface_broken INTERFACE)
  24. # This is not a dependency, so broken will not be built (and the error in
  25. # it will not be hit)
  26. target_link_libraries(iface_broken INTERFACE broken)
  27. add_library(iface_whitelist INTERFACE)
  28. # The target property CUSTOM will never be evaluated on the INTERFACE library.
  29. target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>)
  30. add_executable(exec_whitelist dummy.cpp)
  31. target_link_libraries(exec_whitelist iface_whitelist)
  32. add_library(iface_imported INTERFACE IMPORTED)
  33. set_property(TARGET iface_imported PROPERTY
  34. INTERFACE_COMPILE_DEFINITIONS
  35. $<$<CONFIG:SPECIAL>:SPECIAL_MODE>
  36. $<$<CONFIG:Debug>:DEBUG_MODE>
  37. )
  38. set_property(TARGET iface_imported PROPERTY
  39. MAP_IMPORTED_CONFIG_DEBUG SPECIAL
  40. )
  41. add_executable(map_config map_config.cpp)
  42. target_link_libraries(map_config iface_imported)