@@ -238,8 +238,48 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
238238endif ()
239239
240240install (
241- TARGETS openxr_loader
241+ TARGETS openxr_loader EXPORT openxr_loader_export
242242 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
243243 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
244244 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
245245)
246+ # openxr-all-supported is a dependency of openxr_loader so it should be added to the export set
247+ install (TARGETS openxr-all -supported EXPORT openxr_loader_export)
248+
249+ export (
250+ EXPORT openxr_loader_export
251+ FILE ${CMAKE_CURRENT_BINARY_DIR} /OpenXRTargets.cmake
252+ NAMESPACE xr::
253+ )
254+
255+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
256+ set (TARGET_DESTINATION cmake)
257+ elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
258+ set (TARGET_DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/openxr/)
259+ endif ()
260+
261+ install (
262+ EXPORT openxr_loader_export
263+ FILE OpenXRTargets.cmake
264+ NAMESPACE xr::
265+ DESTINATION ${TARGET_DESTINATION}
266+ )
267+
268+ include (CMakePackageConfigHelpers)
269+ set (INCLUDE_INSTALL_DIR include /)
270+ configure_package_config_file(
271+ OpenXRConfig.cmake.in
272+ ${CMAKE_CURRENT_BINARY_DIR} /OpenXRConfig.cmake
273+ INSTALL_DESTINATION ${TARGET_DESTINATION}
274+ PATH_VARS INCLUDE_INSTALL_DIR
275+ )
276+ write_basic_package_version_file(
277+ ${CMAKE_CURRENT_BINARY_DIR} /OpenXRConfigVersion.cmake
278+ VERSION "${MAJOR} .${MINOR} .${PATCH} "
279+ COMPATIBILITY SameMajorVersion
280+ )
281+ install (
282+ FILES ${CMAKE_CURRENT_BINARY_DIR} /OpenXRConfig.cmake
283+ ${CMAKE_CURRENT_BINARY_DIR} /OpenXRConfigVersion.cmake
284+ DESTINATION ${TARGET_DESTINATION}
285+ )
0 commit comments