Skip to content

Commit 11bf6b2

Browse files
authored
Merge pull request #13137 from dzhwinter/windows/cuda
cuda windows
2 parents ef628ab + e09bb31 commit 11bf6b2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cmake/cuda.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,19 @@ set(CUDA_PROPAGATE_HOST_FLAGS OFF)
169169

170170
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
171171
# So, don't set these flags here.
172+
if (NOT WIN32) # windows msvc2015 support c++11 natively.
173+
# -std=c++11 -fPIC not recoginize by msvc, -Xcompiler will be added by cmake.
172174
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
173-
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math")
174175
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler -fPIC")
176+
endif(NOT WIN32)
177+
178+
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math")
175179
# in cuda9, suppress cuda warning on eigen
176180
list(APPEND CUDA_NVCC_FLAGS "-w")
177181
# Set :expt-relaxed-constexpr to suppress Eigen warnings
178182
list(APPEND CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
179183

184+
if (NOT WIN32)
180185
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
181186
list(APPEND CUDA_NVCC_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
182187
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
@@ -187,6 +192,13 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
187192
# nvcc 9 does not support -Os. Use Release flags instead
188193
list(APPEND CUDA_NVCC_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
189194
endif()
195+
else(NOT WIN32)
196+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
197+
list(APPEND CUDA_NVCC_FLAGS "-O3 -DNDEBUG")
198+
else()
199+
message(FATAL "Windows only support Release build now. Please set visual studio build type to Release, x64 build.")
200+
endif()
201+
endif(NOT WIN32)
190202

191203
mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD)
192204
mark_as_advanced(CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION)

0 commit comments

Comments
 (0)