From aaaeae8edc1e2da478a199c829820094dab4119c Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Mon, 30 Jan 2023 08:49:29 +0100 Subject: [PATCH] [PATCH] Add support for find_package + Config mode Also prepend target names with hwy:: namespace for better CMake user experience. Gbp-Pq: Name bf4eef67e8f1864aa55aafc3cf125bf38db20d12.patch --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a47f39b..0cf9478 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ if(POLICY CMP0111) endif() project(hwy VERSION 1.0.3) # Keep in sync with highway.h version +# `hwy` is lowercase to handle find_package() in Config mode: +set(namespace "${PROJECT_NAME}::") # Directly define the ABI version from the cmake project() version values: set(LIBRARY_VERSION "${hwy_VERSION}") @@ -572,8 +574,8 @@ target_sources(skeleton_test PRIVATE hwy/examples/skeleton.cc) endif() # BUILD_TESTING -# write HWYConfig file: +# write hwy-config file to handle `Config` mode include(CMakePackageConfigHelpers) -write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/HWYConfigVersion.cmake" COMPATIBILITY SameMajorVersion) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/HWYConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hwy") -install(EXPORT hwy_targets FILE HWYConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hwy") +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/hwy-config-version.cmake" COMPATIBILITY SameMajorVersion) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hwy-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hwy") +install(EXPORT hwy_targets NAMESPACE "${namespace}" FILE hwy-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hwy") -- 2.30.2