Skip to content

Instantly share code, notes, and snippets.

@jcfr
Last active December 18, 2023 20:58
Show Gist options
  • Save jcfr/007225a0bdd89588708b45f4951b97d3 to your computer and use it in GitHub Desktop.
Save jcfr/007225a0bdd89588708b45f4951b97d3 to your computer and use it in GitHub Desktop.
Sandbox project to help understand issue discussed at https://github.com/BrownBiomechanics/Autoscoper/pull/238
cmake_minimum_required(VERSION 3.17.5)
message(STATUS "ENV{CUDA_PATH} [$ENV{CUDA_PATH}]")
message(STATUS "---- CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
project(Sandbox)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
option(ENABLE_CUDA_LANGUAGE_FIRST "Enable CUDA first" ON)
message(STATUS "ENABLE_CUDA_LANGUAGE_FIRST: ${ENABLE_CUDA_LANGUAGE_FIRST}")
if(ENABLE_CUDA_LANGUAGE_FIRST)
enable_language(CUDA)
message(STATUS "----")
message(STATUS "---- (after enable_language) CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
message(STATUS "----")
find_package(CUDAToolkit REQUIRED)
message(STATUS "----")
message(STATUS "---- (after find_package) CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
message(STATUS "----")
else()
find_package(CUDAToolkit REQUIRED)
message(STATUS "----")
message(STATUS "---- (after find_package) CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
message(STATUS "----")
#set(CMAKE_CUDA_COMPILER ${CUDAToolkit_NVCC_EXECUTABLE})
#message(STATUS "----")
#message(STATUS "---- (expicitly setting) CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
#message(STATUS "----")
# See https://cmake.org/cmake/help/latest/envvar/CUDACXX.html#cudacxx
set(ENV{CUDACXX} ${CUDAToolkit_NVCC_EXECUTABLE})
message(STATUS "----")
message(STATUS "---- (expicitly setting) ENV{CUDACXX} [$ENV{CUDACXX}]")
message(STATUS "----")
enable_language(CUDA)
message(STATUS "----")
message(STATUS "---- (after enable_language) CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
message(STATUS "----")
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment