Bug 5133197: Add cmake toolchain and and update the CMakeList of some sample for tegra linux cross build

This commit is contained in:
shawnz
2025-03-19 18:17:17 +08:00
parent ab9166a6b2
commit bd0f630bf4
20 changed files with 205 additions and 176 deletions

View File

@@ -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'")