From f4bb51476d3ccfdf1ee52ef4669745c0d70f6dae Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Thu, 4 Jun 2020 21:03:03 -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: I00f9ec2185c27d2f6a8d2c7f294512a268a4e3f5 --- runtime/hsa-runtime/CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index 65ec7aed37..7fc0d37d51 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -83,7 +83,7 @@ set ( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} ## Find external dependencies. find_package(LibElf REQUIRED) -find_package(hsakmt 1.0 REQUIRED) +find_package(hsakmt 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) ## Create the rocr target. add_library( ${CORE_RUNTIME_TARGET} "" ) @@ -309,6 +309,20 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_TARGET}-config.cmake ${ DESTINATION lib/cmake/${CORE_RUNTIME_TARGET} COMPONENT dev) +# 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 ${CORE_RUNTIME_TARGET} NAMESPACE ${CORE_RUNTIME_TARGET}:: FILE ${CORE_RUNTIME_TARGET}Targets.cmake) + # Record the package in the user's cache. + export(PACKAGE ${CORE_RUNTIME_TARGET}) +endif() + ## Packaging directives set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")