Skip to content

Commit

Permalink
[PTI-SDK] Fix CMake Install and find_package (#48)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mschilling0 authored Jan 22, 2024
1 parent 5c44283 commit 67e5290
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
41 changes: 21 additions & 20 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ target_link_options(pti_view PRIVATE ${PTI_LINK_FLAGS_EXPR})

target_compile_definitions(
pti_view
PUBLIC
$<$<TARGET_EXISTS:LevelZero::level-zero>:PTI_LEVEL_ZERO=1>
$<$<TARGET_EXISTS:Xpti::xpti>:PTI_TRACE_SYCL>
PRIVATE
$<$<TARGET_EXISTS:Xpti::xpti>:PTI_TRACE_SYCL>
$<$<TARGET_EXISTS:LevelZero::level-zero>:PTI_LEVEL_ZERO=1>
${PTI_DEFINE_FLAGS_EXPR}
$<IF:$<BOOL:${PTI_ENABLE_LOGGING}>,
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE,
Expand All @@ -186,9 +185,10 @@ endif()
target_link_libraries(
pti_view
PUBLIC
Threads::Threads LevelZero::level-zero
$<TARGET_NAME_IF_EXISTS:Xpti::xpti>
Threads::Threads
PRIVATE
LevelZero::level-zero
$<TARGET_NAME_IF_EXISTS:Xpti::xpti>
spdlog::spdlog_header_only)

FindHeadersPath(
Expand All @@ -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)
Expand Down
11 changes: 1 addition & 10 deletions sdk/PtiConfig.cmake.in → sdk/PtiConfig.cmake
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 8 additions & 5 deletions sdk/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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(
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit 67e5290

Please sign in to comment.