From 67e5290ae7d0f6b2ad0af3de786d06164358919c Mon Sep 17 00:00:00 2001 From: Matthew Schilling Date: Mon, 22 Jan 2024 14:29:15 -0500 Subject: [PATCH] [PTI-SDK] Fix CMake Install and `find_package` (#48) * Mark custom Find* targets private so the user does not need to include these targets in their build. * Mark components for each install artifact to separate artifacts required for build versus run. * Remove useless Config.cmake.in and replace with Config.cmake. Signed-off-by: Schilling, Matthew --- sdk/CMakeLists.txt | 41 +++++++++++---------- sdk/{PtiConfig.cmake.in => PtiConfig.cmake} | 11 +----- sdk/test/CMakeLists.txt | 13 ++++--- 3 files changed, 30 insertions(+), 35 deletions(-) rename sdk/{PtiConfig.cmake.in => PtiConfig.cmake} (56%) diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 66e7543..be63489 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -169,10 +169,9 @@ target_link_options(pti_view PRIVATE ${PTI_LINK_FLAGS_EXPR}) target_compile_definitions( pti_view - PUBLIC - $<$:PTI_LEVEL_ZERO=1> - $<$:PTI_TRACE_SYCL> PRIVATE + $<$:PTI_TRACE_SYCL> + $<$:PTI_LEVEL_ZERO=1> ${PTI_DEFINE_FLAGS_EXPR} $, SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE, @@ -186,9 +185,10 @@ endif() target_link_libraries( pti_view PUBLIC - Threads::Threads LevelZero::level-zero - $ + Threads::Threads PRIVATE + LevelZero::level-zero + $ spdlog::spdlog_header_only) FindHeadersPath( @@ -213,47 +213,48 @@ export( if(PTI_INSTALL) include(CMakePackageConfigHelpers) - configure_package_config_file( - "${PROJECT_SOURCE_DIR}/PtiConfig.cmake.in" - "${PROJECT_BINARY_DIR}/PtiConfig.cmake" - INSTALL_DESTINATION "${PTI_INSTALL_CMAKE_DIR}") - write_basic_package_version_file( "${PROJECT_BINARY_DIR}/PtiConfigVersion.cmake" VERSION "${PROJECT_VERSION}" COMPATIBILITY SameMinorVersion) - install(FILES "${PROJECT_BINARY_DIR}/PtiConfig.cmake" + install(FILES "${PROJECT_SOURCE_DIR}/PtiConfig.cmake" "${PROJECT_BINARY_DIR}/PtiConfigVersion.cmake" - DESTINATION "${PTI_INSTALL_CMAKE_DIR}") - - install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindXpti.cmake" + COMPONENT Pti_Development DESTINATION "${PTI_INSTALL_CMAKE_DIR}") install( TARGETS pti pti_view EXPORT PtiTargets LIBRARY DESTINATION ${PTI_INSTALL_LIB_DIR} + COMPONENT Pti_Runtime + NAMELINK_COMPONENT Pti_Development ARCHIVE DESTINATION ${PTI_INSTALL_LIB_DIR} + COMPONENT Pti_Development RUNTIME DESTINATION ${PTI_INSTALL_BIN_DIR} - INCLUDES - DESTINATION "${PTI_INSTALL_INCLUDE_DIR}") + COMPONENT Pti_Runtime + ) install(FILES "${PROJECT_BINARY_DIR}/pti_export.h" - DESTINATION "${PTI_INSTALL_INCLUDE_DIR}") + DESTINATION "${PTI_INSTALL_INCLUDE_DIR}" + COMPONENT Pti_Development) install(FILES "${PROJECT_BINARY_DIR}/include/pti_version.h" - DESTINATION "${PTI_INSTALL_INCLUDE_DIR}") + DESTINATION "${PTI_INSTALL_INCLUDE_DIR}" + COMPONENT Pti_Development) install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION "${PTI_INSTALL_INCLUDE_DIR}" - FILES_MATCHING PATTERN "*.h") + COMPONENT Pti_Development + FILES_MATCHING PATTERN "*.h" + ) install( EXPORT PtiTargets FILE PtiTargets.cmake NAMESPACE Pti:: - DESTINATION "${PTI_INSTALL_CMAKE_DIR}") + DESTINATION "${PTI_INSTALL_CMAKE_DIR}" + COMPONENT Pti_Development) endif() if(PTI_BUILD_SAMPLES) diff --git a/sdk/PtiConfig.cmake.in b/sdk/PtiConfig.cmake similarity index 56% rename from sdk/PtiConfig.cmake.in rename to sdk/PtiConfig.cmake index ed4876e..2c7f422 100644 --- a/sdk/PtiConfig.cmake.in +++ b/sdk/PtiConfig.cmake @@ -1,14 +1,5 @@ -@PACKAGE_INIT@ - # https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html include("${CMAKE_CURRENT_LIST_DIR}/PtiTargets.cmake") -include(CMakeFindDependencyMacro) +include(CMakeFindDependencyMacro) find_dependency(Threads) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} - "${CMAKE_CURRENT_LIST_DIR}") - -find_dependency(Xpti) - -check_required_components(Pti) diff --git a/sdk/test/CMakeLists.txt b/sdk/test/CMakeLists.txt index 209bf41..e2f19cb 100644 --- a/sdk/test/CMakeLists.txt +++ b/sdk/test/CMakeLists.txt @@ -50,7 +50,7 @@ if(HAVE_SYCL) target_include_directories( mem_ops_test PUBLIC "${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/include" - "${PROJECT_SOURCE_DIR}/src" + "${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}/samples/samples_utilities" "${PROJECT_SOURCE_DIR}/src/syclpi" "${PROJECT_SOURCE_DIR}/src/utils") @@ -59,8 +59,9 @@ if(HAVE_SYCL) target_link_options(mem_ops_test PRIVATE -fsycl -gline-tables-only ${PTI_LINK_FLAGS_EXPR}) target_compile_definitions(mem_ops_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR}) - - target_link_libraries(mem_ops_test PUBLIC Pti::pti_view GTest::gtest_main) + + target_link_libraries(mem_ops_test PUBLIC Pti::pti_view GTest::gtest_main + LevelZero::level-zero) gtest_discover_tests(dpcgemm_suite PROPERTIES LABELS "unit") gtest_discover_tests( @@ -112,7 +113,8 @@ target_link_options(view_record_test PRIVATE ${PTI_LINK_FLAGS_EXPR}) target_compile_definitions(view_record_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR}) target_link_libraries(view_record_test PUBLIC Pti::pti_view GTest::gtest_main - spdlog::spdlog_header_only) + spdlog::spdlog_header_only + LevelZero::level-zero) add_executable(assert_exception_test assert_exception_test.cc) @@ -127,7 +129,8 @@ target_link_options(assert_exception_test PRIVATE ${PTI_LINK_FLAGS_EXPR}) target_compile_definitions(assert_exception_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR}) target_link_libraries(assert_exception_test PUBLIC Pti::pti_view GTest::gtest_main - spdlog::spdlog_header_only) + spdlog::spdlog_header_only + LevelZero::level-zero) gtest_discover_tests( zegemm_suite