I am working on a c++/cuda program using a Linux CentOS 7.9.2009 Server via VS Code SSH-Remote. The default compiler on the Linux machine is g++ (GCC) 4.8.5
but to use the cuda libraries I need a higher version (supporting std=c++14) which is provided on the machine by the devtoolset-8. To build my project I am using the Cmake extention of VS Code which works fine with the native compiler 4.8.5 but I can't find a way to integrate the devtoolset into Cmake or VS Code settings to work properly.
In the VS Code Cmake extention I already integrated a new Kit with the path to the devtoolset. Cmake finds the path to the new compiler version when creating the project but when I hit the build button of the Cmake extention in VS Code, it still uses the old version for the build (I get a build error that -std=c++14 is not supported by the compiler). My workaround is to compile the project manually in the console with scl enable devtoolset-8 'cmake3 ../src && make all'
but then I dont't have Intellisense Code highlighting for errors and warnings in VS Code which I would like to have (I am a beginner by the way). Does anyone know if and how I can make VS Code with Cmake extention and the devtoolset work together to have Intellisense Code highlighting?
This is my cmake-tools-kits.json and the CMAKE Output:
{
"name": "GCC 4.8.5 x86_64-redhat-linux",
"compilers": {
"C": "/usr/bin/gcc",
"CXX": "/usr/bin/g++"
}
},
{
"name": "GCC 8.3.1 x86_64-redhat-linux",
"compilers": {
"C": "/opt/rh/devtoolset-8/root/usr/bin/gcc",
"CXX": "/opt/rh/devtoolset-8/root/usr/bin/g++"
}
}
]
--------------------------------------------------------------
[cmake] -- The CXX compiler identification is GNU 8.3.1
[cmake] -- The CUDA compiler identification is NVIDIA 11.2.67
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++
[cmake] -- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/g++ - works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done