CMakeLists.txt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. add_library(headeronly INTERFACE)
  2. set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES
  3. "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headeronly>"
  4. "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/headeronly>"
  5. )
  6. set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE")
  7. include(GenerateExportHeader)
  8. add_library(sharedlib SHARED sharedlib.cpp)
  9. generate_export_header(sharedlib)
  10. set_property(TARGET sharedlib PROPERTY INCLUDE_DIRECTORIES
  11. "${CMAKE_CURRENT_SOURCE_DIR}/sharedlib"
  12. "${CMAKE_CURRENT_BINARY_DIR}"
  13. )
  14. set_property(TARGET sharedlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES
  15. "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/sharedlib;${CMAKE_CURRENT_BINARY_DIR}>"
  16. "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/sharedlib>"
  17. )
  18. set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_DEFINE")
  19. add_library(sharediface INTERFACE)
  20. target_link_libraries(sharediface INTERFACE sharedlib)
  21. export(TARGETS sharediface sharedlib headeronly
  22. NAMESPACE bld::
  23. FILE ../ExportInterfaceBuildTree.cmake
  24. )
  25. install(TARGETS headeronly sharediface sharedlib
  26. EXPORT expInterface
  27. RUNTIME DESTINATION bin
  28. LIBRARY DESTINATION lib NAMELINK_SKIP
  29. ARCHIVE DESTINATION lib
  30. FRAMEWORK DESTINATION Frameworks
  31. BUNDLE DESTINATION Applications
  32. )
  33. install(FILES
  34. headeronly/headeronly.h
  35. DESTINATION include/headeronly
  36. )
  37. install(FILES
  38. sharedlib/sharedlib.h
  39. "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h"
  40. DESTINATION include/sharedlib
  41. )
  42. install(EXPORT expInterface NAMESPACE exp:: DESTINATION lib/exp)