Skip to content

Commit 6c498cc

Browse files
committed
now works with cmake v3.20
1 parent 156048d commit 6c498cc

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

CMakeLists.txt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,42 @@
22
# GPUtils
33
# ====================================================================
44
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
5-
cmake_policy(SET CMP0135 NEW)
5+
6+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29")
7+
cmake_policy(SET CMP0135 NEW)
8+
endif()
9+
10+
# Set C++ version and SM architecture
11+
if (NOT DEFINED CPPVERSION)
12+
set(CPPVERSION 20) # A40: 20, Orin: 17
13+
endif()
14+
if (NOT DEFINED SM_ARCH)
15+
set(SM_ARCH 86)# A40: 86, Orin: 87
16+
endif()
17+
18+
619
project(GPUtils
720
DESCRIPTION "Easy use of vectors and matrices on GPGPU devices."
821
HOMEPAGE_URL "https://github.com/GPUEngineering/GPUtils"
922
LANGUAGES CXX
1023
)
11-
12-
13-
option(CPPVERSION "C++ version" 20) # A40: 20, Orin: 17
14-
option(SM_ARCH "SM architecture" 86) # A40: 86, Orin: 87
15-
16-
set (cppversion ${CPPVERSION})
17-
set (cppstd "c++${CPPVERSION}")
18-
set (cxxstd cxx_std_${CPPVERSION})
19-
2024
# ----
21-
2225
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON) # required for calling cuda kernels from cuda kernels
23-
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.4/bin/nvcc")
26+
set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
2427
set(CMAKE_CUDA_ARCHITECTURES ${SM_ARCH})
25-
set(CMAKE_CUDA_STANDARD ${cppversion})
26-
set(CMAKE_CXX_STANDARD ${cppversion})
27-
set(CMAKE_CUDA_FLAGS "-std=${cppstd}")
28-
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -std=${cppstd})
28+
set(CMAKE_CUDA_STANDARD ${CPPVERSION})
29+
set(CMAKE_CXX_STANDARD ${CPPVERSION})
30+
set(CMAKE_CUDA_FLAGS "-std=c++${CPPVERSION}")
31+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; "-std=c++${CPPVERSION}")
2932
enable_language(CUDA)
30-
3133
# ----
32-
3334
add_library(device_compiler_flags INTERFACE)
34-
target_compile_features(device_compiler_flags INTERFACE ${cxxstd})
35+
target_compile_features(device_compiler_flags INTERFACE cxx_std_${CPPVERSION})
3536
set(CMAKE_CXX_EXTENSIONS OFF)
36-
3737
# ----
38-
3938
add_library(developer_flags INTERFACE)
4039
set(cxx_flags -Wall)
41-
set(cuda_flags -arch=sm_${SM_ARCH} -std=${cppstd} -Xcompiler=-Wall -Xcudafe=--display_error_number -g)
40+
set(cuda_flags -arch=sm_${SM_ARCH} -std=c++${CPPVERSION} -Xcompiler=-Wall -Xcudafe=--display_error_number -g)
4241
target_compile_options(developer_flags
4342
INTERFACE
4443
# flags for CXX builds
@@ -47,7 +46,6 @@ target_compile_options(developer_flags
4746
$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags}>
4847
)
4948
target_link_libraries(device_compiler_flags INTERFACE $<BUILD_INTERFACE:developer_flags>)
50-
5149
# ----
5250

5351

0 commit comments

Comments
 (0)