diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-11-01 12:12:05 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-12-10 22:56:48 (GMT) |
commit | 2467a2b3184595a87e93db510408fc14ddbaf3b9 (patch) | |
tree | 37e35f4a3c821634cc18c6cd8df8acf2391d4f5c /Tests/CudaOnly | |
parent | f62c674202045f877eaed9da0f9cbe2046452b40 (diff) | |
download | CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.zip CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.tar.gz CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.tar.bz2 |
CUDA: Add cuda meta-features (e.g. ``cuda_std_11``) support
Diffstat (limited to 'Tests/CudaOnly')
-rw-r--r-- | Tests/CudaOnly/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CudaOnly/EnableStandard/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/CudaOnly/SeparateCompilation/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/CudaOnly/Standard98/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/CudaOnly/Standard98/main.cu | 8 |
6 files changed, 33 insertions, 6 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index f1fd344..0dd3309 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -5,6 +5,7 @@ ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) +ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt index 54e2c14..dfcb8da 100644 --- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -11,8 +11,9 @@ add_library(CUDADynamic11 SHARED shared.cu) add_executable(CudaOnlyEnableStandard main.cu) target_link_libraries(CudaOnlyEnableStandard PRIVATE CUDAStatic11 CUDADynamic11) -set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD 11) -set_target_properties(CUDAStatic11 CUDADynamic11 PROPERTIES CUDA_STANDARD_REQUIRED TRUE) +target_compile_features(CUDADynamic11 PRIVATE cuda_std_11) +set_target_properties(CUDAStatic11 PROPERTIES CUDA_STANDARD 11) +set_target_properties(CUDAStatic11 PROPERTIES CUDA_STANDARD_REQUIRED TRUE) #Verify CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES foreach(dir ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 64845c5..57aa0b9 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -22,11 +22,11 @@ endif() # 3. Verify that we can't use those device symbols from anything that links # to the static library string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CUDA_STANDARD 11) add_library(CUDAResolveDeviceDepsA STATIC file1.cu) add_library(CUDAResolveDeviceDepsB STATIC file2.cu) +target_compile_features(CUDAResolveDeviceDepsA PUBLIC cuda_std_11) +target_compile_features(CUDAResolveDeviceDepsB PUBLIC cuda_std_11) set_target_properties(CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB PROPERTIES CUDA_SEPARABLE_COMPILATION ON diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 1e574d6..c1bd64a 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -11,11 +11,10 @@ project (SeparateCompilation CUDA) #all containing cuda separable compilation code links properly string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"") string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]") -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu) +target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11) get_property(sep_comp TARGET CUDASeparateLibA PROPERTY CUDA_SEPARABLE_COMPILATION) if(NOT sep_comp) message(FATAL_ERROR "CUDA_SEPARABLE_COMPILATION not initialized") @@ -36,11 +35,14 @@ endif() #cause a segv when trying to run the executable # add_library(CUDASeparateLibB STATIC file4.cu file5.cu) +target_compile_features(CUDASeparateLibB PRIVATE cuda_std_11) target_link_libraries(CUDASeparateLibB PRIVATE CUDASeparateLibA) add_executable(CudaOnlySeparateCompilation main.cu) target_link_libraries(CudaOnlySeparateCompilation PRIVATE CUDASeparateLibB) +set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD 11) +set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD_REQUIRED TRUE) set_target_properties(CUDASeparateLibA CUDASeparateLibB diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt new file mode 100644 index 0000000..ef9a685 --- /dev/null +++ b/Tests/CudaOnly/Standard98/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.7) +project(CudaOnlyStandard98 CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") + +# Support setting CUDA Standard to 98 which internally gets transformed to +# CUDA03 +set(CMAKE_CUDA_STANDARD 98) + +add_executable(CudaOnlyStandard98 main.cu) + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlyStandard98 PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/Standard98/main.cu b/Tests/CudaOnly/Standard98/main.cu new file mode 100644 index 0000000..c79afd6 --- /dev/null +++ b/Tests/CudaOnly/Standard98/main.cu @@ -0,0 +1,8 @@ + +#if __cplusplus >= 201103L +# error "invalid standard value" +#endif +int main(int argc, char** argv) +{ + return 0; +} |