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,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)

View File

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

View File

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

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

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

View File

@@ -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

View File

@@ -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

View File

@@ -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})