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


[ROCm/ROCR-Runtime commit: f4bb51476d]
This commit is contained in:
Sean Keely
2020-06-04 21:03:03 -05:00
parent 7dfd2ee754
commit 91c27e70e2
@@ -83,7 +83,7 @@ set ( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
## Find external dependencies. ## Find external dependencies.
find_package(LibElf REQUIRED) 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. ## Create the rocr target.
add_library( ${CORE_RUNTIME_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} DESTINATION lib/cmake/${CORE_RUNTIME_TARGET}
COMPONENT dev) 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 ## Packaging directives
set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build") set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")