BabelStream/CUDA.cmake
Tom Lin 14aefecc57 Re-add all compile and arch dependent flags
Fix ACC not linking on CMake < 3.16
Fix CUDA warnings for CMP0104 and avoid repeated -O[n] flags
Fix ComputeCpp not picking up custom flags
[CI] Highlight compiler warnings
[CI] Don't skip remaining tests when one fails
[CI] Add CMake 3.13, 3.15, 3.18 checks
2021-03-11 15:46:23 +00:00

44 lines
1.5 KiB
CMake

register_flag_optional(CMAKE_CXX_COMPILER
"Any CXX compiler that is supported by CMake detection, this is used for host compilation"
"c++")
register_flag_optional(MEM "Device memory mode:
DEFAULT - allocate host and device memory pointers.
MANAGED - use CUDA Managed Memory.
PAGEFAULT - shared memory, only host pointers allocated."
"DEFAULT")
register_flag_required(CMAKE_CUDA_COMPILER
"Path to the CUDA nvcc compiler")
# XXX we may want to drop this eventually and use CMAKE_CUDA_ARCHITECTURES directly
register_flag_required(CUDA_ARCH
"Nvidia architecture, will be passed in via `-arch=` (e.g `sm_70`) for nvcc")
register_flag_optional(CUDA_EXTRA_FLAGS
"Additional CUDA flags passed to nvcc, this is appended after `CUDA_ARCH`"
"")
macro(setup)
# XXX CMake 3.18 supports CMAKE_CUDA_ARCHITECTURES/CUDA_ARCHITECTURES but we support older CMakes
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
endif()
enable_language(CUDA)
register_definitions(MEM=${MEM})
# add -forward-unknown-to-host-compiler for compatibility reasons
set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} "-forward-unknown-to-host-compiler -arch=${CUDA_ARCH}" ${CUDA_EXTRA_FLAGS})
# CMake defaults to -O2 for CUDA at Release, let's wipe that and use the global RELEASE_FLAG
# appended later
wipe_gcc_style_optimisation_flags(CMAKE_CUDA_FLAGS_${BUILD_TYPE})
message(STATUS "NVCC flags: ${CMAKE_CUDA_FLAGS} ${CMAKE_CUDA_FLAGS_${BUILD_TYPE}}")
endmacro()