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}) # 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()