mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2025-07-01 20:20:29 +08:00
Merge branch 'shawnz_tegra_crossbuild_toolchain' into 'master'
Bug 5133197: Add cmake toolchain and and update the CMakeList of some sample... See merge request cuda-samples/cuda-samples!94
This commit is contained in:
commit
06d72496c2
@ -1,5 +1,8 @@
|
||||
## Changelog
|
||||
|
||||
### CUDA 12.9
|
||||
* Updated toolchain for cross-compilation for Tegra Linux platforms.
|
||||
|
||||
### CUDA 12.8
|
||||
* Updated build system across the repository to CMake. Removed Visual Studio project files and Makefiles.
|
||||
* Removed the following outdated samples:
|
||||
|
@ -94,9 +94,9 @@ Navigate to the root of the cloned repository and create a build directory:
|
||||
```
|
||||
mkdir build && cd build
|
||||
```
|
||||
Configure the project with CMake, specifying the Tegra toolchain file:
|
||||
Configure the project with CMake, specifying the Tegra toolchain file. And you can use -DTARGET_FS to point to the target file system root path for necessary include and library files:
|
||||
```
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/tegra/toolchain.cmake
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-linux.cmake -DTARGET_FS=/path/to/target/system/file/system
|
||||
```
|
||||
Build the samples:
|
||||
```
|
||||
|
@ -18,31 +18,10 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../Common)
|
||||
|
||||
find_package(NVSCI)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# Find the NVSCI libraries
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib" ${CMAKE_LIBRARY_PATH})
|
||||
foreach(LIBRARY_PATH ${CMAKE_LIBRARY_PATH})
|
||||
file(GLOB_RECURSE NVSCIBUF_LIB
|
||||
${LIBRARY_PATH}/libnvscibuf.so
|
||||
${LIBRARY_PATH}/*/libnvscibuf.so
|
||||
)
|
||||
file(GLOB_RECURSE NVSCISYNC_LIB
|
||||
${LIBRARY_PATH}/libnvscisync.so
|
||||
${LIBRARY_PATH}/*/libnvscisync.so
|
||||
)
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Find the NVSCI header files
|
||||
# use CMAKE_INCLUDE_PATH so that users can also specify the NVSCI include path in cmake command
|
||||
set(CMAKE_INCLUDE_PATH "/usr/include" ${CMAKE_LIBRARY_PATH})
|
||||
find_path(NVSCIBUF_INCLUDE_DIR nvscibuf.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVSCISYNC_INCLUDE_DIR nvscisync.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVSCIBUF_INCLUDE_DIR AND NVSCISYNC_INCLUDE_DIR)
|
||||
if(NVSCI_FOUND)
|
||||
message(STATUS "FOUND NVSCI libs: ${NVSCIBUF_LIB} ${NVSCISYNC_LIB}")
|
||||
message(STATUS "Using NVSCI headers path: ${NVSCIBUF_INCLUDE_DIR} ${NVSCIBUF_INCLUDE_DIR}")
|
||||
# Source file
|
||||
@ -57,14 +36,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
target_include_directories(cudaNvSci PUBLIC
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
${NVSCIBUF_INCLUDE_DIR}
|
||||
${NVSCISYNC_INCLUDE_DIR}
|
||||
${NVSCI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(cudaNvSci
|
||||
CUDA::cuda_driver
|
||||
${NVSCIBUF_LIB}
|
||||
${NVSCISYNC_LIB}
|
||||
${NVSCI_LIBRARIES}
|
||||
)
|
||||
# Copy teapot1024.ppm to the output directory
|
||||
add_custom_command(TARGET cudaNvSci POST_BUILD
|
||||
|
@ -27,25 +27,16 @@ target_compile_features(jitLto PRIVATE cxx_std_17 cuda_std_17)
|
||||
|
||||
set_target_properties(jitLto PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
|
||||
find_library(NVJITLINK_LIB
|
||||
NAME nvJitLink
|
||||
PATHS "${CUDAToolkit_LIBRARY_DIR}" "${CMAKE_LIBRARY_PATH}")
|
||||
|
||||
target_include_directories(jitLto PRIVATE
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
|
||||
target_link_libraries(jitLto PRIVATE
|
||||
target_link_libraries(jitLto PRIVATE
|
||||
CUDA::cuda_driver
|
||||
CUDA::nvrtc
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(jitLto PRIVATE
|
||||
${CUDAToolkit_LIBRARY_DIR}/libnvJitLink.so
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(jitLto PRIVATE
|
||||
${CUDAToolkit_LIBRARY_DIR}/nvJitLink.lib
|
||||
)
|
||||
endif()
|
||||
${NVJITLINK_LIB}
|
||||
)
|
||||
|
@ -17,34 +17,28 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../Common)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|
||||
message(STATUS "Will not build sample nvJPEG - not supported on aarch64")
|
||||
else()
|
||||
# Source file
|
||||
# Add target for nvJPEG
|
||||
add_executable(nvJPEG nvJPEG.cpp)
|
||||
|
||||
# Source file
|
||||
# Add target for nvJPEG
|
||||
add_executable(nvJPEG nvJPEG.cpp)
|
||||
target_compile_options(nvJPEG PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
||||
|
||||
target_compile_options(nvJPEG PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
||||
target_compile_features(nvJPEG PRIVATE cxx_std_17 cuda_std_17)
|
||||
|
||||
target_compile_features(nvJPEG PRIVATE cxx_std_17 cuda_std_17)
|
||||
set_target_properties(nvJPEG PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
|
||||
set_target_properties(nvJPEG PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
|
||||
target_include_directories(nvJPEG PRIVATE
|
||||
target_include_directories(nvJPEG PRIVATE
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(nvJPEG PRIVATE
|
||||
target_link_libraries(nvJPEG PRIVATE
|
||||
CUDA::cudart
|
||||
CUDA::nvjpeg
|
||||
)
|
||||
)
|
||||
|
||||
# Copy data to the output directory
|
||||
add_custom_command(TARGET nvJPEG POST_BUILD
|
||||
# Copy data to the output directory
|
||||
add_custom_command(TARGET nvJPEG POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/images
|
||||
${CMAKE_CURRENT_BINARY_DIR}/images
|
||||
)
|
||||
|
||||
endif()
|
||||
)
|
||||
|
@ -17,40 +17,34 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../Common)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|
||||
message(STATUS "Will not build sample nvJPEG_encoder - not supported on aarch64")
|
||||
else()
|
||||
# Source file
|
||||
# Add target for nvJPEG_encoder
|
||||
add_executable(nvJPEG_encoder nvJPEG_encoder.cpp)
|
||||
|
||||
# Source file
|
||||
# Add target for nvJPEG_encoder
|
||||
add_executable(nvJPEG_encoder nvJPEG_encoder.cpp)
|
||||
target_compile_options(nvJPEG_encoder PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
||||
|
||||
target_compile_options(nvJPEG_encoder PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
|
||||
target_compile_features(nvJPEG_encoder PRIVATE cxx_std_17 cuda_std_17)
|
||||
|
||||
target_compile_features(nvJPEG_encoder PRIVATE cxx_std_17 cuda_std_17)
|
||||
set_target_properties(nvJPEG_encoder PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
|
||||
set_target_properties(nvJPEG_encoder PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
|
||||
target_include_directories(nvJPEG_encoder PRIVATE
|
||||
target_include_directories(nvJPEG_encoder PRIVATE
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(nvJPEG_encoder PRIVATE
|
||||
target_link_libraries(nvJPEG_encoder PRIVATE
|
||||
CUDA::cudart
|
||||
CUDA::nvjpeg
|
||||
)
|
||||
)
|
||||
|
||||
# Copy data to the output directory
|
||||
add_custom_command(TARGET nvJPEG_encoder POST_BUILD
|
||||
# Copy data to the output directory
|
||||
add_custom_command(TARGET nvJPEG_encoder POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/images
|
||||
${CMAKE_CURRENT_BINARY_DIR}/images
|
||||
)
|
||||
)
|
||||
|
||||
add_custom_command(TARGET nvJPEG_encoder POST_BUILD
|
||||
add_custom_command(TARGET nvJPEG_encoder POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/encode_output
|
||||
${CMAKE_CURRENT_BINARY_DIR}/encode_output
|
||||
)
|
||||
|
||||
endif()
|
||||
)
|
||||
|
@ -28,9 +28,13 @@ include(CheckIncludeFile)
|
||||
check_include_file("GLFW/glfw3.h" HAVE_GLFW3_H)
|
||||
|
||||
# Find GLFW header and lib for Windows
|
||||
if(WIN32)
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATH "${GLFW_INCLUDE_DIR}")
|
||||
find_library(GLFW3_LIB "glfw3" PATH "${GLFW_LIB_DIR}")
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
set(GLFW_INCLUDE_DIRS "${GLFW_INCLUDE_DIR}" "${CMAKE_INCLUDE_PATH}")
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATHS ${GLFW_INCLUDE_DIRS})
|
||||
find_library(GLFW3_LIB
|
||||
NAMES glfw3 glfw
|
||||
PATHS "${GLFW_LIB_DIR}"
|
||||
PATH_SUFFIXES lib lib64)
|
||||
if(GLFW3_H AND GLFW3_LIB)
|
||||
message(STATUS "Found GLFW/glfw3.h and GLFW library.")
|
||||
set(HAVE_GLFW3_H 1)
|
||||
@ -58,9 +62,9 @@ if(${Vulkan_FOUND})
|
||||
${Vulkan_LIBRARIES}
|
||||
OpenGL::GL
|
||||
)
|
||||
if(WIN32)
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
target_include_directories(simpleVulkan PUBLIC
|
||||
${GLFW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries(simpleVulkan
|
||||
${GLFW3_LIB}
|
||||
|
@ -27,9 +27,13 @@ include(CheckIncludeFile)
|
||||
check_include_file("GLFW/glfw3.h" HAVE_GLFW3_H)
|
||||
|
||||
# Find GLFW header and lib for Windows
|
||||
if(WIN32)
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATH "${GLFW_INCLUDE_DIR}")
|
||||
find_library(GLFW3_LIB "glfw3" PATH "${GLFW_LIB_DIR}")
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
set(GLFW_INCLUDE_DIRS "${GLFW_INCLUDE_DIR}" "${CMAKE_INCLUDE_PATH}")
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATHS ${GLFW_INCLUDE_DIRS})
|
||||
find_library(GLFW3_LIB
|
||||
NAMES glfw3 glfw
|
||||
PATHS "${GLFW_LIB_DIR}"
|
||||
PATH_SUFFIXES lib lib64)
|
||||
if(GLFW3_H AND GLFW3_LIB)
|
||||
message(STATUS "Found GLFW/glfw3.h and GLFW library.")
|
||||
set(HAVE_GLFW3_H 1)
|
||||
@ -58,9 +62,9 @@ if(${Vulkan_FOUND})
|
||||
OpenGL::GL
|
||||
CUDA::cuda_driver
|
||||
)
|
||||
if(WIN32)
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
target_include_directories(simpleVulkanMMAP PUBLIC
|
||||
${GLFW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries(simpleVulkanMMAP
|
||||
${GLFW3_LIB}
|
||||
|
@ -27,9 +27,13 @@ include(CheckIncludeFile)
|
||||
check_include_file("GLFW/glfw3.h" HAVE_GLFW3_H)
|
||||
|
||||
# Find GLFW header and lib for Windows
|
||||
if(WIN32)
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATH "${GLFW_INCLUDE_DIR}")
|
||||
find_file(GLFW3_LIB "glfw3" PATH "${GLFW_LIB_DIR}")
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
set(GLFW_INCLUDE_DIRS "${GLFW_INCLUDE_DIR}" "${CMAKE_INCLUDE_PATH}")
|
||||
find_file(GLFW3_H "GLFW/glfw3.h" PATHS ${GLFW_INCLUDE_DIRS})
|
||||
find_library(GLFW3_LIB
|
||||
NAMES glfw3 glfw
|
||||
PATHS "${GLFW_LIB_DIR}"
|
||||
PATH_SUFFIXES lib lib64)
|
||||
if(GLFW3_H AND GLFW3_LIB)
|
||||
message(STATUS "Found GLFW/glfw3.h and GLFW library.")
|
||||
set(HAVE_GLFW3_H 1)
|
||||
@ -57,9 +61,9 @@ if(${Vulkan_FOUND})
|
||||
${Vulkan_LIBRARIES}
|
||||
OpenGL::GL
|
||||
)
|
||||
if(WIN32)
|
||||
if(WIN32 OR CMAKE_CROSSCOMPILING)
|
||||
target_include_directories(vulkanImageCUDA PUBLIC
|
||||
${GLFW_INCLUDE_DIR}
|
||||
${GLFW_INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries(vulkanImageCUDA
|
||||
${GLFW3_LIB}
|
||||
|
@ -82,7 +82,12 @@ message(STATUS "Using libnvvm library: ${NVVM_LIB}")
|
||||
|
||||
# Set the rpath to libnvvm.
|
||||
find_path(LIBNVVM_RPATH lib lib64 PATHS "$ENV{LIBNVVM_HOME}" "${CUDA_HOME}")
|
||||
get_filename_component(LIBNVVM_RPATH ${NVVM_LIB} DIRECTORY)
|
||||
if(DEFINED RUNTIME_LIBNVVM_PATH)
|
||||
message(STATUS "Using RUNTIME_LIBNVVM_PATH: ${RUNTIME_LIBNVVM_PATH}")
|
||||
set(LIBNVVM_RPATH ${RUNTIME_LIBNVVM_PATH})
|
||||
else()
|
||||
get_filename_component(LIBNVVM_RPATH ${NVVM_LIB} DIRECTORY)
|
||||
endif()
|
||||
set(CMAKE_INSTALL_RPATH "${LIBNVVM_RPATH}")
|
||||
message(STATUS "Using rpath: ${CMAKE_INSTALL_RPATH}")
|
||||
|
||||
|
@ -33,12 +33,18 @@ set_tests_properties(ptxgenTest PROPERTIES FIXTURES_SETUP PTXGENTEST)
|
||||
|
||||
target_link_libraries(ptxgen ${NVVM_LIB})
|
||||
|
||||
if (DEFINED RUNTIME_LIBNVVM_PATH)
|
||||
get_filename_component(_LIBNVVM_HOME "${RUNTIME_LIBNVVM_PATH}" DIRECTORY)
|
||||
else ()
|
||||
set(_LIBNVVM_HOME "${LIBNVVM_HOME}")
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
set_target_properties(ptxgen PROPERTIES
|
||||
COMPILE_FLAGS "/wd4996 -DLIBNVVM_HOME=\"${LIBNVVM_HOME}\"")
|
||||
else (WIN32)
|
||||
set_target_properties(ptxgen PROPERTIES
|
||||
COMPILE_FLAGS "-DLIBNVVM_HOME=\"${LIBNVVM_HOME}\""
|
||||
COMPILE_FLAGS "-DLIBNVVM_HOME=\"${_LIBNVVM_HOME}\""
|
||||
LINK_FLAGS "-Wl,-rpath,${LIBNVVM_RPATH}")
|
||||
endif (WIN32)
|
||||
|
||||
|
@ -18,7 +18,7 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR})
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CUDLA_LIB)
|
||||
|
@ -18,7 +18,7 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR})
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CUDLA_LIB)
|
||||
|
@ -18,7 +18,7 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR})
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CUDLA_LIB)
|
||||
|
@ -18,34 +18,12 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR})
|
||||
find_package(NVSCI)
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CUDLA_LIB)
|
||||
# Find the NVSCI libraries
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib" ${CMAKE_LIBRARY_PATH})
|
||||
foreach(LIBRARY_PATH ${CMAKE_LIBRARY_PATH})
|
||||
file(GLOB_RECURSE NVSCIBUF_LIB
|
||||
${LIBRARY_PATH}/libnvscibuf.so
|
||||
${LIBRARY_PATH}/*/libnvscibuf.so
|
||||
)
|
||||
file(GLOB_RECURSE NVSCISYNC_LIB
|
||||
${LIBRARY_PATH}/libnvscisync.so
|
||||
${LIBRARY_PATH}/*/libnvscisync.so
|
||||
)
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Find the NVSCI header files
|
||||
# use CMAKE_INCLUDE_PATH so that users can also specify the NVSCI include path in cmake command
|
||||
set(CMAKE_INCLUDE_PATH "/usr/include" ${CMAKE_LIBRARY_PATH})
|
||||
find_path(NVSCIBUF_INCLUDE_DIR nvscibuf.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVSCISYNC_INCLUDE_DIR nvscisync.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVSCIBUF_INCLUDE_DIR AND NVSCISYNC_INCLUDE_DIR)
|
||||
if(NVSCI_FOUND)
|
||||
# Source file
|
||||
# Add target for cuDLALayerwiseStatsStandalone
|
||||
add_executable(cuDLALayerwiseStatsStandalone main.cpp)
|
||||
@ -58,14 +36,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
target_include_directories(cuDLALayerwiseStatsStandalone PUBLIC
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
${NVSCIBUF_INCLUDE_DIR}
|
||||
${NVSCISYNC_INCLUDE_DIR}
|
||||
${NVSCI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(cuDLALayerwiseStatsStandalone
|
||||
${CUDLA_LIB}
|
||||
${NVSCIBUF_LIB}
|
||||
${NVSCISYNC_LIB}
|
||||
${NVSCI_LIBRARIES}
|
||||
)
|
||||
else()
|
||||
message(STATUS "NvSCI not found - will not build sample 'cuDLALayerwiseStatsStandalone'")
|
||||
|
@ -18,34 +18,12 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR})
|
||||
find_package(NVSCI)
|
||||
find_library(CUDLA_LIB cudla PATHS ${CUDAToolkit_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(CUDLA_LIB)
|
||||
# Find the NVSCI libraries
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib" ${CMAKE_LIBRARY_PATH})
|
||||
foreach(LIBRARY_PATH ${CMAKE_LIBRARY_PATH})
|
||||
file(GLOB_RECURSE NVSCIBUF_LIB
|
||||
${LIBRARY_PATH}/libnvscibuf.so
|
||||
${LIBRARY_PATH}/*/libnvscibuf.so
|
||||
)
|
||||
file(GLOB_RECURSE NVSCISYNC_LIB
|
||||
${LIBRARY_PATH}/libnvscisync.so
|
||||
${LIBRARY_PATH}/*/libnvscisync.so
|
||||
)
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Find the NVSCI header files
|
||||
# use CMAKE_INCLUDE_PATH so that users can also specify the NVSCI include path in cmake command
|
||||
set(CMAKE_INCLUDE_PATH "/usr/include" ${CMAKE_LIBRARY_PATH})
|
||||
find_path(NVSCIBUF_INCLUDE_DIR nvscibuf.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVSCISYNC_INCLUDE_DIR nvscisync.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVSCIBUF_INCLUDE_DIR AND NVSCISYNC_INCLUDE_DIR)
|
||||
if(NVSCI_FOUND)
|
||||
# Source file
|
||||
# Add target for cuDLAStandaloneMode
|
||||
add_executable(cuDLAStandaloneMode main.cpp)
|
||||
@ -58,14 +36,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
target_include_directories(cuDLAStandaloneMode PUBLIC
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
${NVSCIBUF_INCLUDE_DIR}
|
||||
${NVSCISYNC_INCLUDE_DIR}
|
||||
${NVSCI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(cuDLAStandaloneMode
|
||||
${CUDLA_LIB}
|
||||
${NVSCIBUF_LIB}
|
||||
${NVSCISYNC_LIB}
|
||||
${NVSCI_LIBRARIES}
|
||||
)
|
||||
else()
|
||||
message(STATUS "NvSCI not found - will not build sample 'cuDLAStandaloneMode'")
|
||||
|
@ -18,33 +18,10 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_package(NVSCI)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# Find the NVSCI libraries
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib" ${CMAKE_LIBRARY_PATH})
|
||||
foreach(LIBRARY_PATH ${CMAKE_LIBRARY_PATH})
|
||||
file(GLOB_RECURSE NVSCIBUF_LIB
|
||||
${LIBRARY_PATH}/libnvscibuf.so
|
||||
${LIBRARY_PATH}/*/libnvscibuf.so
|
||||
)
|
||||
file(GLOB_RECURSE NVSCISYNC_LIB
|
||||
${LIBRARY_PATH}/libnvscisync.so
|
||||
${LIBRARY_PATH}/*/libnvscisync.so
|
||||
)
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Find the NVSCI header files
|
||||
# use CMAKE_INCLUDE_PATH so that users can also specify the NVSCI include path in cmake command
|
||||
set(CMAKE_INCLUDE_PATH "/usr/include" ${CMAKE_LIBRARY_PATH})
|
||||
find_path(NVSCIBUF_INCLUDE_DIR nvscibuf.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVSCISYNC_INCLUDE_DIR nvscisync.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVSCIBUF_INCLUDE_DIR AND NVSCISYNC_INCLUDE_DIR)
|
||||
message(STATUS "FOUND NVSCI libs: ${NVSCIBUF_LIB} ${NVSCISYNC_LIB}")
|
||||
message(STATUS "Using NVSCI headers path: ${NVSCIBUF_INCLUDE_DIR} ${NVSCIBUF_INCLUDE_DIR}")
|
||||
if(NVSCI_FOUND)
|
||||
# Source file
|
||||
# Add target for cudaNvSciBufMultiplanar
|
||||
add_executable(cudaNvSciBufMultiplanar imageKernels.cu cudaNvSciBufMultiplanar.cpp main.cpp)
|
||||
@ -57,14 +34,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
target_include_directories(cudaNvSciBufMultiplanar PUBLIC
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
${NVSCIBUF_INCLUDE_DIR}
|
||||
${NVSCISYNC_INCLUDE_DIR}
|
||||
${NVSCI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(cudaNvSciBufMultiplanar
|
||||
CUDA::cuda_driver
|
||||
${NVSCIBUF_LIB}
|
||||
${NVSCISYNC_LIB}
|
||||
${NVSCI_LIBRARIES}
|
||||
)
|
||||
# Copy yuv_planar_img1.yuv to the output directory
|
||||
add_custom_command(TARGET cudaNvSciBufMultiplanar POST_BUILD
|
||||
|
@ -18,24 +18,18 @@ endif()
|
||||
# Include directories and libraries
|
||||
include_directories(../../../../Common)
|
||||
|
||||
find_package(NVSCI)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# Find the NVSCI/NVMEDIA libraries
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib" ${CMAKE_LIBRARY_PATH})
|
||||
foreach(LIBRARY_PATH ${CMAKE_LIBRARY_PATH})
|
||||
file(GLOB_RECURSE NVSCIBUF_LIB
|
||||
${LIBRARY_PATH}/libnvscibuf.so
|
||||
${LIBRARY_PATH}/*/libnvscibuf.so
|
||||
)
|
||||
file(GLOB_RECURSE NVSCISYNC_LIB
|
||||
${LIBRARY_PATH}/libnvscisync.so
|
||||
${LIBRARY_PATH}/*/libnvscisync.so
|
||||
)
|
||||
file(GLOB_RECURSE NVMEDIA_LIB
|
||||
${LIBRARY_PATH}/libnvmedia.so
|
||||
${LIBRARY_PATH}/*/libnvmedia.so
|
||||
)
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVMEDIA_LIB)
|
||||
if(NVMEDIA_LIB)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
@ -47,13 +41,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
"/usr/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/include"
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
)
|
||||
find_path(NVSCIBUF_INCLUDE_DIR nvscibuf.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVSCISYNC_INCLUDE_DIR nvscisync.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
find_path(NVMEDIA_INCLUDE_DIR nvmedia_core.h PATHS ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
if(NVSCIBUF_LIB AND NVSCISYNC_LIB AND NVSCIBUF_INCLUDE_DIR AND NVSCISYNC_INCLUDE_DIR)
|
||||
message(STATUS "FOUND NVSCI libs: ${NVSCIBUF_LIB} ${NVSCISYNC_LIB}")
|
||||
message(STATUS "Using NVSCI headers path: ${NVSCIBUF_INCLUDE_DIR} ${NVSCIBUF_INCLUDE_DIR}")
|
||||
if(NVSCI_FOUND)
|
||||
if(NVMEDIA_LIB AND NVMEDIA_INCLUDE_DIR)
|
||||
message(STATUS "FOUND NVMEDIA libs: ${NVMEDIA_LIB}")
|
||||
message(STATUS "Using NVMEDIA headers path: ${NVMEDIA_INCLUDE_DIR}")
|
||||
@ -69,15 +59,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
||||
target_include_directories(cudaNvSciNvMedia PUBLIC
|
||||
${CUDAToolkit_INCLUDE_DIRS}
|
||||
${NVSCIBUF_INCLUDE_DIR}
|
||||
${NVSCISYNC_INCLUDE_DIR}
|
||||
${NVSCI_INCLUDE_DIRS}
|
||||
${NVMEDIA_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(cudaNvSciNvMedia
|
||||
CUDA::cuda_driver
|
||||
${NVSCIBUF_LIB}
|
||||
${NVSCISYNC_LIB}
|
||||
${NVSCI_LIBRARIES}
|
||||
${NVMEDIA_LIB}
|
||||
)
|
||||
# Copy teapot.rgba to the output directory
|
||||
|
@ -26,7 +26,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if(${OpenGL_FOUND})
|
||||
if(${EGL_FOUND})
|
||||
if(${X11_FOUND})
|
||||
set(DRM_INCLUDE_PATH "/usr/include/drm" "/usr/include/libdrm")
|
||||
set(DRM_INCLUDE_PATH "/usr/include/drm" "/usr/include/libdrm" ${CMAKE_INCLUDE_PATH})
|
||||
|
||||
# use CMAKE_LIBRARY_PATH so that users can also specify the NVSCI lib path in cmake command
|
||||
set(CMAKE_LIBRARY_PATH "/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu" ${CMAKE_LIBRARY_PATH})
|
||||
|
@ -4,7 +4,7 @@ find_path(FreeImage_INCLUDE_DIR
|
||||
)
|
||||
|
||||
find_library(FreeImage_LIBRARY
|
||||
NAMES freeimage
|
||||
NAMES freeimage FreeImage
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
|
||||
|
61
cmake/Modules/FindNVSCI.cmake
Normal file
61
cmake/Modules/FindNVSCI.cmake
Normal file
@ -0,0 +1,61 @@
|
||||
# Find the NVSCI libraries and headers
|
||||
#
|
||||
# This module defines the following variables:
|
||||
# NVSCI_FOUND - True if NVSCI was found
|
||||
# NVSCI_INCLUDE_DIRS - NVSCI include directories
|
||||
# NVSCI_LIBRARIES - NVSCI libraries
|
||||
# NVSCIBUF_LIBRARY - NVSCI buffer library
|
||||
# NVSCISYNC_LIBRARY - NVSCI sync library
|
||||
|
||||
# Find the libraries
|
||||
find_library(NVSCIBUF_LIBRARY
|
||||
NAMES nvscibuf libnvscibuf
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu
|
||||
PATH_SUFFIXES nvidia
|
||||
)
|
||||
|
||||
find_library(NVSCISYNC_LIBRARY
|
||||
NAMES nvscisync libnvscisync
|
||||
PATHS
|
||||
$/usr/lib
|
||||
$/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu
|
||||
PATH_SUFFIXES nvidia
|
||||
)
|
||||
|
||||
# Find the header files
|
||||
find_path(NVSCIBUF_INCLUDE_DIR
|
||||
NAMES nvscibuf.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
find_path(NVSCISYNC_INCLUDE_DIR
|
||||
NAMES nvscisync.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(NVSCI
|
||||
REQUIRED_VARS
|
||||
NVSCIBUF_LIBRARY
|
||||
NVSCISYNC_LIBRARY
|
||||
NVSCIBUF_INCLUDE_DIR
|
||||
NVSCISYNC_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(NVSCI_FOUND)
|
||||
set(NVSCI_LIBRARIES ${NVSCIBUF_LIBRARY} ${NVSCISYNC_LIBRARY})
|
||||
set(NVSCI_INCLUDE_DIRS ${NVSCIBUF_INCLUDE_DIR} ${NVSCISYNC_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
NVSCIBUF_LIBRARY
|
||||
NVSCISYNC_LIBRARY
|
||||
NVSCIBUF_INCLUDE_DIR
|
||||
NVSCISYNC_INCLUDE_DIR
|
||||
)
|
59
cmake/toolchains/toolchain-aarch64-linux.cmake
Normal file
59
cmake/toolchains/toolchain-aarch64-linux.cmake
Normal file
@ -0,0 +1,59 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
# Specify the cross-compilers
|
||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||
set(CMAKE_AR aarch64-linux-gnu-ar)
|
||||
set(CMAKE_RANLIB aarch64-linux-gnu-ranlib)
|
||||
|
||||
# Indicate cross-compiling.
|
||||
set(CMAKE_CROSSCOMPILING TRUE)
|
||||
|
||||
# Set CUDA compiler flags
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -ccbin ${CMAKE_CXX_COMPILER}" CACHE STRING "" FORCE)
|
||||
|
||||
# Use a local sysroot copy
|
||||
if(DEFINED TARGET_FS)
|
||||
set(CMAKE_SYSROOT "${TARGET_FS}")
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH
|
||||
"/usr/local/cuda/targets/aarch64-linux"
|
||||
)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler --sysroot=${TARGET_FS}")
|
||||
|
||||
set(LIB_PATHS
|
||||
"${TARGET_FS}/usr/lib/"
|
||||
"${TARGET_FS}/usr/lib/aarch64-linux-gnu"
|
||||
"${TARGET_FS}/usr/lib/aarch64-linux-gnu/nvidia"
|
||||
)
|
||||
# Add rpath-link flags for all library paths
|
||||
foreach(lib_path ${LIB_PATHS})
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,${lib_path}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath-link,${lib_path}")
|
||||
endforeach()
|
||||
|
||||
# Add the real path of CUDA installation on TARGET_FS for nvvm
|
||||
find_program(TARGET_CUDA_NVCC_PATH nvcc
|
||||
PATH "${TARGET_FS}/usr/local/cuda/bin"
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_PATH
|
||||
)
|
||||
if(TARGET_CUDA_NVCC_PATH)
|
||||
# Get the real path of CUDA installation on TARGET_FS
|
||||
get_filename_component(TARGET_CUDA_PATH "${TARGET_CUDA_NVCC_PATH}" REALPATH)
|
||||
get_filename_component(TARGET_CUDA_ROOT "${TARGET_CUDA_PATH}" DIRECTORY)
|
||||
get_filename_component(TARGET_CUDA_ROOT "${TARGET_CUDA_ROOT}" DIRECTORY)
|
||||
endif()
|
||||
|
||||
if (DEFINED TARGET_CUDA_ROOT)
|
||||
list(APPEND CMAKE_LIBRARY_PATH "${TARGET_CUDA_ROOT}/targets/aarch64-linux/lib")
|
||||
# Define NVVM paths for build and runtime
|
||||
set(ENV{LIBNVVM_HOME} "${TARGET_CUDA_ROOT}")
|
||||
set(RUNTIME_LIBNVVM_PATH "${TARGET_CUDA_ROOT}/nvvm/lib64")
|
||||
endif()
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user