CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_library(intermediate INTERFACE)
  18. target_link_libraries(intermediate INTERFACE iface_objlib)
  19. add_executable(InterfaceLibrary definetestexe.cpp)
  20. target_link_libraries(InterfaceLibrary iface_nodepends headeriface subiface intermediate)
  21. add_subdirectory(libsdir)
  22. add_executable(sharedlibtestexe sharedlibtestexe.cpp)
  23. target_link_libraries(sharedlibtestexe shared_iface imported::iface)
  24. add_library(broken EXCLUDE_FROM_ALL broken.cpp)
  25. add_library(iface_broken INTERFACE)
  26. # This is not a dependency, so broken will not be built (and the error in
  27. # it will not be hit)
  28. target_link_libraries(iface_broken INTERFACE broken)
  29. add_library(iface_whitelist INTERFACE)
  30. # The target property CUSTOM will never be evaluated on the INTERFACE library.
  31. target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>)
  32. add_executable(exec_whitelist dummy.cpp)
  33. target_link_libraries(exec_whitelist iface_whitelist)
  34. add_library(iface_imported INTERFACE IMPORTED)
  35. set_property(TARGET iface_imported PROPERTY
  36. INTERFACE_COMPILE_DEFINITIONS
  37. $<$<CONFIG:SPECIAL>:SPECIAL_MODE>
  38. $<$<CONFIG:Debug>:DEBUG_MODE>
  39. )
  40. set_property(TARGET iface_imported PROPERTY
  41. MAP_IMPORTED_CONFIG_DEBUG SPECIAL
  42. )
  43. add_executable(map_config map_config.cpp)
  44. target_link_libraries(map_config iface_imported)