mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 21:30:01 -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.
58 lines
2.0 KiB
CMake
58 lines
2.0 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project(Complex CXX CUDA)
|
|
#Goal for this example:
|
|
|
|
#build a cpp dynamic library base
|
|
#build a cuda static library base that uses separable compilation
|
|
|
|
#build a cuda dynamic library that uses the first dynamic library
|
|
#build a mixed cpp & cuda dynamic library uses all 3 previous libraries
|
|
|
|
#lastly build a cpp executable that uses this last cuda dynamic library
|
|
|
|
#this tests that we can properly handle linking cuda and cpp together
|
|
#and also building cpp targets that need cuda implicit libraries
|
|
|
|
set(CMAKE_CUDA_STANDARD 11)
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
|
|
|
add_library(CudaComplexCppBase SHARED dynamic.cpp)
|
|
add_library(CudaComplexSharedLib SHARED dynamic.cu)
|
|
target_link_libraries(CudaComplexSharedLib PUBLIC CudaComplexCppBase)
|
|
|
|
add_library(CudaComplexSeperableLib STATIC file1.cu file2.cu file3.cu)
|
|
add_library(CudaComplexMixedLib SHARED mixed.cpp mixed.cu)
|
|
target_link_libraries(CudaComplexMixedLib
|
|
PUBLIC CudaComplexSharedLib
|
|
PRIVATE CudaComplexSeperableLib)
|
|
|
|
add_executable(CudaComplex main.cpp)
|
|
target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib)
|
|
|
|
|
|
set_target_properties(CudaComplexMixedLib
|
|
CudaComplexSeperableLib
|
|
PROPERTIES
|
|
POSITION_INDEPENDENT_CODE ON
|
|
CUDA_SEPARABLE_COMPILATION ON
|
|
)
|
|
set_target_properties(CudaComplexMixedLib
|
|
CudaComplexSharedLib
|
|
PROPERTIES
|
|
CUDA_RUNTIME_LIBRARY shared
|
|
)
|
|
|
|
|
|
if(APPLE)
|
|
# Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
|
|
set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
|
|
endif()
|
|
|
|
if(UNIX)
|
|
# Help the shared cuda runtime find libcudart as it is not located
|
|
# in a default system searched location
|
|
set_property(TARGET CudaComplexMixedLib PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
|
|
endif()
|