mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 14:48:19 -05:00
4fe9f534f5
Architecture 30 was removed with CUDA 11, so most of the CUDA tests fail with it. Remove setting the architecture and bump the minimum version to 3.18, so CMP0104 takes effect and we can rely on the default architecture, which is guaranteed to be compilable. Use of __ldg() in ProperLinkFlags was removed as it only affects performance and is available only on sm_35 and above. Testing the functionality of CUDA_ARCHITECTURES is already covered by CudaOnly.Architecture and CudaOnly.CompileFlags.
39 lines
1.3 KiB
CMake
39 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project(WithDefs CUDA)
|
|
|
|
set(release_compile_defs DEFREL)
|
|
|
|
#Goal for this example:
|
|
#build a executable that needs to be passed a complex define through add_defintions
|
|
#this verifies we can pass things such as '_','(' to nvcc
|
|
add_definitions("-DPACKED_DEFINE=__attribute__((packed))")
|
|
|
|
add_executable(CudaOnlyWithDefs main.notcu)
|
|
set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA)
|
|
|
|
target_compile_options(CudaOnlyWithDefs
|
|
PRIVATE
|
|
-DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
|
|
-DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
|
|
$<$<CUDA_COMPILER_ID:NVIDIA>:--compiler-options=-DHOST_DEFINE> # Host-only defines are possible only on NVCC.
|
|
)
|
|
|
|
target_compile_definitions(CudaOnlyWithDefs
|
|
PRIVATE
|
|
$<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
|
|
-DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE>
|
|
-DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
|
|
-DDEF_CUDA_COMPILER=$<CUDA_COMPILER_ID>
|
|
-DDEF_CUDA_COMPILER_VERSION=$<CUDA_COMPILER_VERSION>
|
|
)
|
|
|
|
target_include_directories(CudaOnlyWithDefs
|
|
PRIVATE
|
|
$<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda>
|
|
)
|
|
|
|
if(APPLE)
|
|
# Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
|
|
set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
|
|
endif()
|