Merge pull request #4 from XSShawnZeng/tegra_samples_nboby_opengles

Update the CMakeLists.txt for 3 Tegra samples
This commit is contained in:
Rob Armstrong 2025-01-06 09:38:21 -08:00 committed by GitHub
commit 5409227cf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 112 additions and 36 deletions

View File

@ -0,0 +1,3 @@
add_subdirectory(fluidsGLES)
add_subdirectory(nbody_opengles)
add_subdirectory(simpleGLES)

View File

@ -11,34 +11,48 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
endif() endif()
# Include directories and libraries
include_directories(../../../../Common)
find_package(EGL)
find_package(X11)
find_package(OpenGL)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package (OpenGL COMPONENTS EGL GLES2) # Source file
if(${OpenGL_EGL_FOUND}) if(${OpenGL_FOUND})
# Source file if(${EGL_FOUND})
# Add target for fluidsGLES if(${X11_FOUND})
add_executable(fluidsGLES # Add target for fluidsGLES
fluidsGLES.cpp add_executable(fluidsGLES fluidsGLES.cpp fluidsGLES_kernels.cu)
fluidsGLES_kernels.cu
)
target_compile_options(fluidsGLES PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>) target_compile_options(fluidsGLES PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
target_compile_features(fluidsGLES PRIVATE cxx_std_17 cuda_std_17) target_compile_features(fluidsGLES PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(fluidsGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(fluidsGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(fluidsGLES PUBLIC target_include_directories(fluidsGLES PUBLIC
${OPENGL_INCLUDE_DIRS} ${EGL_INCLUDE_DIR}
${CUDAToolkit_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR}
../../../Common ${CUDAToolkit_INCLUDE_DIRS}
) )
target_link_libraries(fluidsGLES target_link_libraries(fluidsGLES
${OPENGL_LIBRARIES} CUDA::cuda_driver
CUDA::cuda_driver CUDA::cufft
) ${EGL_LIBRARY}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
)
else()
message(STATUS "X11 libraries not found - will not build sample 'fluidsGLES'")
endif()
else()
message(STATUS "EGL not found - will not build sample 'fluidsGLES'")
endif()
else() else()
message(STATUS "EGL not found - will not build sample 'fluidsGLES'") message(STATUS "OpenGL not found - will not build sample 'fluidsGLES'")
endif() endif()
else() else()
message(STATUS "Will not build sample fluidsGLES - requires Linux OS") message(STATUS "Will not build sample fluidsGLES - requires Linux OS")

View File

@ -6,24 +6,52 @@ project(nbody_opengles LANGUAGES C CXX CUDA)
find_package(CUDAToolkit REQUIRED) find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 75 80 86 89 90) set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 72 75 80 86 87 89 90)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
endif() endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../../Common)
find_package(EGL)
find_package(X11)
find_package(OpenGL)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Source file # Source file
# Add target for nbody_opengles if(${OpenGL_FOUND})
add_executable(nbody_opengles nbody_opengles.cu) if(${EGL_FOUND})
if(${X11_FOUND})
# Add target for nbody_opengles
add_executable(nbody_opengles bodysystemcuda.cu render_particles.cpp nbody_opengles.cpp)
target_compile_options(nbody_opengles PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>) target_compile_options(nbody_opengles PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
target_compile_features(nbody_opengles PRIVATE cxx_std_17 cuda_std_17) target_compile_features(nbody_opengles PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(nbody_opengles PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(nbody_opengles PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(nbody_opengles PUBLIC
${EGL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${CUDAToolkit_INCLUDE_DIRS}
)
target_link_libraries(nbody_opengles
${EGL_LIBRARY}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
)
else()
message(STATUS "X11 libraries not found - will not build sample 'nbody_opengles'")
endif()
else()
message(STATUS "EGL not found - will not build sample 'nbody_opengles'")
endif()
else()
message(STATUS "OpenGL not found - will not build sample 'nbody_opengles'")
endif()
else() else()
message(STATUS "Will not build sample nbody_opengles - requires Linux OS") message(STATUS "Will not build sample nbody_opengles - requires Linux OS")
endif() endif()

View File

@ -6,24 +6,52 @@ project(simpleGLES LANGUAGES C CXX CUDA)
find_package(CUDAToolkit REQUIRED) find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_ARCHITECTURES 50 52 60 61 70 75 80 86 89 90) set(CMAKE_CUDA_ARCHITECTURES 53 61 70 72 75 80 86 87 90)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive) # set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -G") # enable cuda-gdb (expensive)
endif() endif()
# Include directories and libraries # Include directories and libraries
include_directories(../../../Common) include_directories(../../../../Common)
find_package(EGL)
find_package(X11)
find_package(OpenGL)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Source file # Source file
# Add target for simpleGLES if(${OpenGL_FOUND})
add_executable(simpleGLES simpleGLES.cu) if(${EGL_FOUND})
if(${X11_FOUND})
# Add target for simpleGLES
add_executable(simpleGLES simpleGLES.cu)
target_compile_options(simpleGLES PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>) target_compile_options(simpleGLES PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
target_compile_features(simpleGLES PRIVATE cxx_std_17 cuda_std_17) target_compile_features(simpleGLES PRIVATE cxx_std_17 cuda_std_17)
set_target_properties(simpleGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON) set_target_properties(simpleGLES PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(simpleGLES PUBLIC
${EGL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${CUDAToolkit_INCLUDE_DIRS}
)
target_link_libraries(simpleGLES
${EGL_LIBRARY}
${X11_LIBRARIES}
${OPENGL_LIBRARIES}
)
else()
message(STATUS "X11 libraries not found - will not build sample 'simpleGLES'")
endif()
else()
message(STATUS "EGL not found - will not build sample 'simpleGLES'")
endif()
else()
message(STATUS "OpenGL not found - will not build sample 'simpleGLES'")
endif()
else() else()
message(STATUS "Will not build sample simpleGLES - requires Linux OS") message(STATUS "Will not build sample simpleGLES - requires Linux OS")
endif() endif()

View File

@ -6,3 +6,6 @@ add_subdirectory(4_CUDA_Libraries)
add_subdirectory(5_Domain_Specific) add_subdirectory(5_Domain_Specific)
add_subdirectory(6_Performance) add_subdirectory(6_Performance)
add_subdirectory(7_libNVVM) add_subdirectory(7_libNVVM)
if(BUILD_TEGRA)
add_subdirectory(8_Platform_Specific/Tegra)
endif()