[CMake] Specifying path of nvcc for CUDA projects using project command

Jeffrey Perez jperez at accuray.com
Mon Sep 10 14:25:19 EDT 2018


Hello,

I have a project which uses the CMake 3.10.1 and CUDA nvcc compiler and I am using the new project(projectName LANGUAGES CUDA) instead of find_package(CUDA) to do so. I want CMake to use a different (explicitly defined) path for nvcc compiler than the installed version. Before calling project(projectName LANGUAGES CUDA), I declare CUDA_TOOLKIT_ROOT_DIR via an include of a file which defines our third party library variables, but it always finds the installed version. I know that CUDA_TOOLKIT_ROOT_DIR  was meant for the find_package(CUDA) script, but the documentation doesn't seem to specify how to use the new project method of including nvcc.

Is there a way to specify a different nvcc location using the new format?

Excerpt from CMakeLists.txt:
...
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../build/thirdparty_versions.cmake) #defines CUDA_TOOLKIT_ROOT_DIR to specified CUDA root with bin/nvcc below it.
message(---------------CUDA_TOOLKIT_ROOT_DIR:${ CUDA_TOOLKIT_ROOT_DIR})
project(projectName LANGUAGES CUDA)
...

Below is a portion of my output:
...
---------------CUDA_TOOLKIT_ROOT_DIR:C:/thirdparty/CUDA/v8.0
-- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17134.
-- The CUDA compiler identification is NVIDIA 8.0.44
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/nvcc.exe

You can see that the CUDA compiler found was the intalled version, not C:/thirdparty/CUDA/v8.0

Thanks,
Jeff Perez

-- WARNING - CONFIDENTIAL INFORMATION: The information contained in the e-mail may contain confidential and privileged information and is intended solely for the use of the intended recipient(s). Access for any review, re-transmission, dissemination or other use of, or taking of any action in regard and reliance upon this e-mail by persons or entities other than the intended recipient(s) is unauthorized and prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180910/de87feb2/attachment.html>


More information about the CMake mailing list