CMakeLists.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. cmake_minimum_required(VERSION 3.24)
  2. project(cxx_modules_export_interfaces CXX)
  3. include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
  4. add_library(export_interfaces STATIC)
  5. target_sources(export_interfaces
  6. PRIVATE
  7. forward.cxx
  8. PRIVATE
  9. FILE_SET modules_private TYPE CXX_MODULES
  10. BASE_DIRS
  11. "${CMAKE_CURRENT_SOURCE_DIR}"
  12. FILES
  13. private.cxx
  14. PUBLIC
  15. FILE_SET modules TYPE CXX_MODULES
  16. BASE_DIRS
  17. "${CMAKE_CURRENT_SOURCE_DIR}"
  18. FILES
  19. importable.cxx)
  20. target_compile_features(export_interfaces PUBLIC cxx_std_20)
  21. install(TARGETS export_interfaces
  22. EXPORT CXXModules
  23. FILE_SET modules DESTINATION "lib/cxx/miu")
  24. install(EXPORT CXXModules
  25. NAMESPACE CXXModules::
  26. DESTINATION "lib/cmake/export_interfaces"
  27. FILE "export_interfaces-targets.cmake")
  28. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-config.cmake"
  29. "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_interfaces-targets.cmake\")
  30. set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
  31. ")
  32. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_interfaces-config.cmake"
  33. DESTINATION "lib/cmake/export_interfaces")
  34. set(generator
  35. -G "${CMAKE_GENERATOR}")
  36. if (CMAKE_GENERATOR_TOOLSET)
  37. list(APPEND generator
  38. -T "${CMAKE_GENERATOR_TOOLSET}")
  39. endif ()
  40. if (CMAKE_GENERATOR_PLATFORM)
  41. list(APPEND generator
  42. -A "${CMAKE_GENERATOR_PLATFORM}")
  43. endif ()
  44. add_test(NAME export_interfaces_build
  45. COMMAND
  46. "${CMAKE_COMMAND}"
  47. "-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
  48. "-Dexport_interfaces_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_interfaces"
  49. ${generator}
  50. -S "${CMAKE_CURRENT_SOURCE_DIR}/test"
  51. -B "${CMAKE_CURRENT_BINARY_DIR}/test")