Bug 5591814: Support "make install" in single sample folder

This commit is contained in:
Shawn Zeng
2025-11-04 16:21:23 +08:00
parent d759a16c4b
commit 4eae2ccc04
203 changed files with 894 additions and 81 deletions

View File

@@ -128,3 +128,8 @@ add_subdirectory(simple)
add_subdirectory(syscalls)
add_subdirectory(ptxgen)
add_subdirectory(uvmlite)
# Include InstallSamples to set CUDA_SAMPLES_INSTALL_DIR
# libNVVM samples will use this variable for installation
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
include(InstallSamples)

View File

@@ -80,7 +80,13 @@ add_library(mathfuncs64 STATIC math-funcs.cu)
set_target_properties(mathfuncs64 PROPERTIES PREFIX "lib"
OUTPUT_NAME "mathfuncs64"
SUFFIX ".a" CUDA_SEPERABLE_COMPILATION ON)
install(TARGETS cuda-c-linking mathfuncs64 DESTINATION bin)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(TARGETS cuda-c-linking mathfuncs64 DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
else()
install(TARGETS cuda-c-linking mathfuncs64 DESTINATION bin)
endif()
if (WIN32)
add_custom_command(

View File

@@ -39,9 +39,15 @@ set_tests_properties(test-cuda-shared-memory-shared_memory
test-cuda-shared-memory-extern_shared_memory
PROPERTIES FIXTURES_REQUIRED PTXGENTEST)
# Install the .ll files to the install/ folder
install(FILES shared_memory.ll DESTINATION bin/cuda-shared-memory)
install(FILES extern_shared_memory.ll DESTINATION bin/cuda-shared-memory)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin/cuda-shared-memory (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(FILES shared_memory.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR}/cuda-shared-memory)
install(FILES extern_shared_memory.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR}/cuda-shared-memory)
else()
install(FILES shared_memory.ll DESTINATION bin/cuda-shared-memory)
install(FILES extern_shared_memory.ll DESTINATION bin/cuda-shared-memory)
endif()
file(COPY shared_memory.ll DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY extern_shared_memory.ll DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

View File

@@ -41,8 +41,15 @@ else (WIN32)
set_target_properties(dsl PROPERTIES LINK_FLAGS "-Wl,-rpath,${LIBNVVM_RPATH}")
endif (WIN32)
install(TARGETS dsl DESTINATION bin)
install(FILES dsl-gpu64.ll DESTINATION bin)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(TARGETS dsl DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
install(FILES dsl-gpu64.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
else()
install(TARGETS dsl DESTINATION bin)
install(FILES dsl-gpu64.ll DESTINATION bin)
endif()
# 'dsl' will load dsl-gpu64.ll from the current working directory. That
# .ll file should be present where tests are executed (the build directory).

View File

@@ -48,8 +48,15 @@ else (WIN32)
LINK_FLAGS "-Wl,-rpath,${LIBNVVM_RPATH}")
endif (WIN32)
install(TARGETS ptxgen DESTINATION bin)
install(FILES test.ll DESTINATION bin)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(TARGETS ptxgen DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
install(FILES test.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
else()
install(TARGETS ptxgen DESTINATION bin)
install(FILES test.ll DESTINATION bin)
endif()
add_custom_command(
TARGET ptxgen

View File

@@ -40,8 +40,15 @@ else (WIN32)
LINK_FLAGS "-Wl,-rpath,${LIBNVVM_RPATH}")
endif (WIN32)
install(TARGETS simple DESTINATION bin)
install(FILES simple-gpu64.ll DESTINATION bin)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(TARGETS simple DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
install(FILES simple-gpu64.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
else()
install(TARGETS simple DESTINATION bin)
install(FILES simple-gpu64.ll DESTINATION bin)
endif()
# 'simple' will load simple-gpu64.ll from the current working directory. That
# .ll file should be present where tests are executed (the build directory).

View File

@@ -36,8 +36,15 @@ add_test(NAME test-syscalls-vprintf
set_tests_properties(test-syscalls-vprintf test-syscalls-malloc-free
PROPERTIES FIXTURES_REQUIRED PTXGENTEST)
install(FILES malloc-free.ll DESTINATION bin/syscalls)
install(FILES vprintf.ll DESTINATION bin/syscalls)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin/syscalls (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(FILES malloc-free.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR}/syscalls)
install(FILES vprintf.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR}/syscalls)
else()
install(FILES malloc-free.ll DESTINATION bin/syscalls)
install(FILES vprintf.ll DESTINATION bin/syscalls)
endif()
file(COPY malloc-free.ll DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY vprintf.ll DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")

View File

@@ -44,8 +44,15 @@ else (WIN32)
LINK_FLAGS "-Wl,-rpath,${LIBNVVM_RPATH}")
endif ()
install(TARGETS uvmlite DESTINATION bin)
install(FILES uvmlite64.ll DESTINATION bin)
# Install to CUDA_SAMPLES_INSTALL_DIR if defined (for unified installation),
# otherwise install to bin (for standalone libNVVM build)
if(DEFINED CUDA_SAMPLES_INSTALL_DIR)
install(TARGETS uvmlite DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
install(FILES uvmlite64.ll DESTINATION ${CUDA_SAMPLES_INSTALL_DIR})
else()
install(TARGETS uvmlite DESTINATION bin)
install(FILES uvmlite64.ll DESTINATION bin)
endif()
# 'uvmlite' will load uvmlite64.ll from the current working directory. That
# .ll file should be present where tests are executed (the build directory).