From 7f35aa97394a5dbd424a89758528a9be9845240b Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 4 Jun 2020 20:57:56 -0500 Subject: [PATCH] Add optional support for the cmake per user package registry. Default is OFF to conform to latest cmake standard (3.15) and because this feature can cause some confusion for unaware developers. Change-Id: I6fdbd5ab76c90b73ac6451a383334a83cabef438 Signed-off-by: Sean Keely [ROCm/ROCR-Runtime commit: f0b05559961b1a857d4cbf0479b9f3b8a2b6904a] --- projects/rocr-runtime/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/rocr-runtime/CMakeLists.txt b/projects/rocr-runtime/CMakeLists.txt index cced60f616..56292ed135 100644 --- a/projects/rocr-runtime/CMakeLists.txt +++ b/projects/rocr-runtime/CMakeLists.txt @@ -198,6 +198,20 @@ install(FILES ${CMAKE_INSTALL_LIBDIR}/cmake/${HSAKMT_TARGET} COMPONENT devel) +# Optionally record the package's find module in the user's package cache. +if ( NOT DEFINED EXPORT_TO_USER_PACKAGE_REGISTRY ) + set ( EXPORT_TO_USER_PACKAGE_REGISTRY "off" ) +endif() +set ( EXPORT_TO_USER_PACKAGE_REGISTRY ${EXPORT_TO_USER_PACKAGE_REGISTRY} CACHE BOOL "Add cmake package config location to the user's cmake package registry.") +if(${EXPORT_TO_USER_PACKAGE_REGISTRY}) + # Enable writing to the registry + set(CMAKE_EXPORT_PACKAGE_REGISTRY ON) + # Generate a target file for the build + export(TARGETS ${HSAKMT_TARGET} NAMESPACE ${HSAKMT_TARGET}:: FILE ${HSAKMT_TARGET}Targets.cmake) + # Record the package in the user's cache. + export(PACKAGE ${HSAKMT_TARGET}) +endif() + # CPACK_PACKAGING_INSTALL_PREFIX is needed in libhsakmt.pc.in # TODO: Add support for relocatable packages. configure_file ( libhsakmt.pc.in libhsakmt.pc @ONLY )