Skip to content

Commit 67e5290

Browse files
authored
[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 <[email protected]>
1 parent 5c44283 commit 67e5290

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

sdk/CMakeLists.txt

+21-20
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,9 @@ target_link_options(pti_view PRIVATE ${PTI_LINK_FLAGS_EXPR})
169169

170170
target_compile_definitions(
171171
pti_view
172-
PUBLIC
173-
$<$<TARGET_EXISTS:LevelZero::level-zero>:PTI_LEVEL_ZERO=1>
174-
$<$<TARGET_EXISTS:Xpti::xpti>:PTI_TRACE_SYCL>
175172
PRIVATE
173+
$<$<TARGET_EXISTS:Xpti::xpti>:PTI_TRACE_SYCL>
174+
$<$<TARGET_EXISTS:LevelZero::level-zero>:PTI_LEVEL_ZERO=1>
176175
${PTI_DEFINE_FLAGS_EXPR}
177176
$<IF:$<BOOL:${PTI_ENABLE_LOGGING}>,
178177
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE,
@@ -186,9 +185,10 @@ endif()
186185
target_link_libraries(
187186
pti_view
188187
PUBLIC
189-
Threads::Threads LevelZero::level-zero
190-
$<TARGET_NAME_IF_EXISTS:Xpti::xpti>
188+
Threads::Threads
191189
PRIVATE
190+
LevelZero::level-zero
191+
$<TARGET_NAME_IF_EXISTS:Xpti::xpti>
192192
spdlog::spdlog_header_only)
193193

194194
FindHeadersPath(
@@ -213,47 +213,48 @@ export(
213213
if(PTI_INSTALL)
214214
include(CMakePackageConfigHelpers)
215215

216-
configure_package_config_file(
217-
"${PROJECT_SOURCE_DIR}/PtiConfig.cmake.in"
218-
"${PROJECT_BINARY_DIR}/PtiConfig.cmake"
219-
INSTALL_DESTINATION "${PTI_INSTALL_CMAKE_DIR}")
220-
221216
write_basic_package_version_file(
222217
"${PROJECT_BINARY_DIR}/PtiConfigVersion.cmake"
223218
VERSION "${PROJECT_VERSION}"
224219
COMPATIBILITY SameMinorVersion)
225220

226-
install(FILES "${PROJECT_BINARY_DIR}/PtiConfig.cmake"
221+
install(FILES "${PROJECT_SOURCE_DIR}/PtiConfig.cmake"
227222
"${PROJECT_BINARY_DIR}/PtiConfigVersion.cmake"
228-
DESTINATION "${PTI_INSTALL_CMAKE_DIR}")
229-
230-
install(FILES "${PROJECT_SOURCE_DIR}/cmake/Modules/FindXpti.cmake"
223+
COMPONENT Pti_Development
231224
DESTINATION "${PTI_INSTALL_CMAKE_DIR}")
232225

233226
install(
234227
TARGETS pti pti_view
235228
EXPORT PtiTargets
236229
LIBRARY DESTINATION ${PTI_INSTALL_LIB_DIR}
230+
COMPONENT Pti_Runtime
231+
NAMELINK_COMPONENT Pti_Development
237232
ARCHIVE DESTINATION ${PTI_INSTALL_LIB_DIR}
233+
COMPONENT Pti_Development
238234
RUNTIME DESTINATION ${PTI_INSTALL_BIN_DIR}
239-
INCLUDES
240-
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}")
235+
COMPONENT Pti_Runtime
236+
)
241237

242238
install(FILES "${PROJECT_BINARY_DIR}/pti_export.h"
243-
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}")
239+
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}"
240+
COMPONENT Pti_Development)
244241

245242
install(FILES "${PROJECT_BINARY_DIR}/include/pti_version.h"
246-
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}")
243+
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}"
244+
COMPONENT Pti_Development)
247245

248246
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
249247
DESTINATION "${PTI_INSTALL_INCLUDE_DIR}"
250-
FILES_MATCHING PATTERN "*.h")
248+
COMPONENT Pti_Development
249+
FILES_MATCHING PATTERN "*.h"
250+
)
251251

252252
install(
253253
EXPORT PtiTargets
254254
FILE PtiTargets.cmake
255255
NAMESPACE Pti::
256-
DESTINATION "${PTI_INSTALL_CMAKE_DIR}")
256+
DESTINATION "${PTI_INSTALL_CMAKE_DIR}"
257+
COMPONENT Pti_Development)
257258
endif()
258259

259260
if(PTI_BUILD_SAMPLES)
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
@PACKAGE_INIT@
2-
31
# https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html
42
include("${CMAKE_CURRENT_LIST_DIR}/PtiTargets.cmake")
5-
include(CMakeFindDependencyMacro)
63

4+
include(CMakeFindDependencyMacro)
75
find_dependency(Threads)
8-
9-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
10-
"${CMAKE_CURRENT_LIST_DIR}")
11-
12-
find_dependency(Xpti)
13-
14-
check_required_components(Pti)

sdk/test/CMakeLists.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if(HAVE_SYCL)
5050
target_include_directories(
5151
mem_ops_test
5252
PUBLIC "${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/include"
53-
"${PROJECT_SOURCE_DIR}/src"
53+
"${PROJECT_SOURCE_DIR}/src"
5454
"${PROJECT_SOURCE_DIR}/samples/samples_utilities"
5555
"${PROJECT_SOURCE_DIR}/src/syclpi" "${PROJECT_SOURCE_DIR}/src/utils")
5656

@@ -59,8 +59,9 @@ if(HAVE_SYCL)
5959
target_link_options(mem_ops_test PRIVATE -fsycl -gline-tables-only
6060
${PTI_LINK_FLAGS_EXPR})
6161
target_compile_definitions(mem_ops_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR})
62-
63-
target_link_libraries(mem_ops_test PUBLIC Pti::pti_view GTest::gtest_main)
62+
63+
target_link_libraries(mem_ops_test PUBLIC Pti::pti_view GTest::gtest_main
64+
LevelZero::level-zero)
6465

6566
gtest_discover_tests(dpcgemm_suite PROPERTIES LABELS "unit")
6667
gtest_discover_tests(
@@ -112,7 +113,8 @@ target_link_options(view_record_test PRIVATE ${PTI_LINK_FLAGS_EXPR})
112113
target_compile_definitions(view_record_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR})
113114

114115
target_link_libraries(view_record_test PUBLIC Pti::pti_view GTest::gtest_main
115-
spdlog::spdlog_header_only)
116+
spdlog::spdlog_header_only
117+
LevelZero::level-zero)
116118

117119
add_executable(assert_exception_test assert_exception_test.cc)
118120

@@ -127,7 +129,8 @@ target_link_options(assert_exception_test PRIVATE ${PTI_LINK_FLAGS_EXPR})
127129
target_compile_definitions(assert_exception_test PRIVATE ${PTI_DEFINE_FLAGS_EXPR})
128130

129131
target_link_libraries(assert_exception_test PUBLIC Pti::pti_view GTest::gtest_main
130-
spdlog::spdlog_header_only)
132+
spdlog::spdlog_header_only
133+
LevelZero::level-zero)
131134

132135
gtest_discover_tests(
133136
zegemm_suite

0 commit comments

Comments
 (0)