Misformatted CMake invocation when kit passes setting with semi-colons
Brief Issue Summary
I'm using CMake for CUDA development, and something changed in the past few weeks, as my setup used to work. My kit instructs CMake to override the default CMAKE_CUDA_ARCHITECTURES value to the GPUs in my system (as recommended by CMake in the docs):
Users are encouraged to override this, as the default varies across compilers and compiler versions.
However CMake tools inserts backslashes into the setting value. (Note the two configuration invocations which only differ in said value.) This very same kit used to work not long ago.
The kits entry in question looks like:
{
"name": "GCC 8.3.0 & CUDA 10.2",
"compilers": {
"C": "/usr/bin/gcc-8",
"CXX": "/usr/bin/g++-8",
"CUDA": "/usr/local/cuda-10.2/bin/nvcc"
},
"cmakeSettings": {
"HIP_PLATFORM": "nvcc",
"CMAKE_CUDA_ARCHITECTURES": "70;61;52"
},
"environmentVariables": {
"LD_LIBRARY_PATH": "/usr/local/cuda-10.2/lib64:${env:LD_LIBRARY_PATH}",
"NVVMIR_LIBRARY_DIR": "/usr/local/cuda-10.2/nvvm/libdevice",
"PATH": "/usr/local/cuda-10.2/nvvm/bin:/usr/local/cuda-10.2/bin:${env:PATH}",
"INCLUDES": "-I/usr/local/cuda-10.2/include ${env:INCLUDES} ",
"LIBRARIES": "-L/usr/local/cuda-10.2/lib64/stubs -L/usr/local/cuda-10.2/lib64 ${env:LIBRARIES} ",
"HIP_PLATFORM": "nvcc",
"CUDA_PATH": "/usr/local/cuda-10.2"
}
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.8) # CUDA language support
project(CMakeToolsBugRepro LANGUAGES CUDA)
add_executable(${PROJECT_NAME} Main.cu)
Main.cu
int main() {}
Expected:
/snap/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=/home/mate/Source/CMakeToolsBugRepro/.vscode/install -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-8 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-8 -DCMAKE_CUDA_COMPILER:FILEPATH=/usr/local/cuda-10.2/bin/nvcc -DHIP_PLATFORM:STRING=nvcc "-DCMAKE_CUDA_ARCHITECTURES:STRING=70;61;52" -H/home/mate/Source/CMakeToolsBugRepro -B/home/mate/Source/CMakeToolsBugRepro/.vscode/build -G "Ninja Multi-Config"
Not searching for unused variables given on the command line.
-- The CUDA compiler identification is NVIDIA 10.2.89
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-10.2/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mate/Source/CMakeToolsBugRepro/.vscode/build
Apparent Behavior:
/snap/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:STRING=/home/mate/Source/CMakeToolsBugRepro/.vscode/install -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-8 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-8 -DCMAKE_CUDA_COMPILER:FILEPATH=/usr/local/cuda-10.2/bin/nvcc -DHIP_PLATFORM:STRING=nvcc "-DCMAKE_CUDA_ARCHITECTURES:STRING=70\;61\;52" -H/home/mate/Source/CMakeToolsBugRepro -B/home/mate/Source/CMakeToolsBugRepro/.vscode/build -G "Ninja Multi-Config"
Not searching for unused variables given on the command line.
-- The CUDA compiler identification is NVIDIA 10.2.89
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - failed
-- Check for working CUDA compiler: /usr/local/cuda-10.2/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda-10.2/bin/nvcc - broken
CMake Error at /snap/cmake/918/share/cmake-3.21/Modules/CMakeTestCUDACompiler.cmake:56 (message):
The CUDA compiler
"/usr/local/cuda-10.2/bin/nvcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/mate/Source/CMakeToolsBugRepro/CMakeFiles/CMakeTmp
Run Build Command(s):/home/mate/.local/bin/ninja cmTC_d0339 && [1/2] Building CUDA object CMakeFiles/cmTC_d0339.dir/Debug/main.cu.o
FAILED: CMakeFiles/cmTC_d0339.dir/Debug/main.cu.o
/usr/local/cuda-10.2/bin/nvcc -forward-unknown-to-host-compiler -DCMAKE_INTDIR=\"Debug\" -g --generate-code=arch=compute_70;61;52,code=[compute_70;61;52,sm_70;61;52] -MD -MT CMakeFiles/cmTC_d0339.dir/Debug/main.cu.o -MF CMakeFiles/cmTC_d0339.dir/Debug/main.cu.o.d -x cu -c /home/mate/Source/CMakeToolsBugRepro/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_d0339.dir/Debug/main.cu.o
nvcc fatal : Option '--generate-code arch=compute_70', missing code
/bin/sh: 1: 61: not found
/bin/sh: 1: 52,code=[compute_70: not found
/bin/sh: 1: 61: not found
/bin/sh: 1: 52,sm_70: not found
/bin/sh: 1: 61: not found
/bin/sh: 1: 52]: not found
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
Platform and Versions
- Operating System: Ubuntu 18.04
- CMake Version: 3.21.1
- VSCode Version: 1.58.2
- CMake Tools Extension Version: 1.7.3
- Compiler/Toolchain: nvcc 10.2
@MathiasMagnus, thank you for opening this issue. I reproduce the insertion of the backslash and it appears to be from old source code that does escaping intentionally(util.ts, cmakeify). Until we analyze what that is for and if it still applies somewhere, you can use as a workaround "cmake.configureArgs" as a general (not kit) setting in your .vscode/settings.json.
+1 settings.json "cmake.configureSettings" also has the same issue.
This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.