vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Doesn't work with clang on windows

Open helviett opened this issue 4 years ago • 2 comments

Brief Issue Summary

I have installed Clang Compiler and Clang-cl via Visual Studio Intaller. VSCode detects [Clang 12.0.0 (MSVC CLI) for MSVC 16.11.31613.86 (Visual Studio Community 2019 Release - amd64)] kit. I use conan package manager and have Eigen package installed (example project Morpho.zip). Build fails in VSCode but Visual Studio can build this project successfully.

CMake Tools Log

Cmake tools log:

[main] Building folder: Morpho 
[main] Configuring folder: Morpho 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_C_COMPILER:FILEPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin\clang-cl.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin\clang-cl.exe" -Hd:/GIT/Morpho -Bd:/GIT/Morpho/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is Clang 12.0.0 with MSVC-like command-line
[cmake] -- The CXX compiler identification is Clang 12.0.0 with MSVC-like command-line
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Conan: Adjusting output directories
[cmake] -- Conan: Using cmake global configuration
[cmake] -- Conan: Adjusting default RPATHs Conan policies
[cmake] -- Conan: Adjusting language standard
[cmake] -- Current conanbuildinfo.cmake directory: D:/GIT/Morpho/build
[cmake] CMake Error at build/conanbuildinfo.cmake:680 (message):
[cmake]   Incorrect 'Visual Studio'.  Toolset specifies compiler as 'MSVC' but CMake
[cmake]   detected 'Clang'
[cmake] Call Stack (most recent call first):
[cmake]   build/conanbuildinfo.cmake:251 (conan_check_compiler)
[cmake]   Morpho/CMakeLists.txt:8 (conan_basic_setup)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "D:/GIT/Morpho/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "D:/GIT/Morpho/build/CMakeFiles/CMakeError.log".

CMakeError.log:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe 
Build flags: 
Id flags:  

The output was:
1
clang-cl: error: unable to execute command: program not executable
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)


Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe 
Build flags: 
Id flags:  

The output was:
1
clang-cl: error: unable to execute command: program not executable
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.18.3
  • VSCode Version: 1.59,1
  • CMake Tools Extension Version: 1.8.0
  • Compiler/Toolchain: clang-cl

helviett avatar Aug 30 '21 15:08 helviett

It would appear to have something to do with the Conan rules. We'll need to try this out. clang-cl works for me in a non-Conan project.

bobbrow avatar Aug 31 '21 00:08 bobbrow

[cmake] Incorrect 'Visual Studio'. Toolset specifies compiler as 'MSVC' but CMake [cmake] detected 'Clang'

This error very likely stems from the fact that the Conan profile you used with conan install specifies compiler=Visual Studio while you're invoking CMake with -DCMAKE_C_COMPILER and -DCMAKE_CXX_COMPILER pointing to Clang. The fix would be to either change your default Conan profile to specify Clang or to create a separate profile for Clang and specify that one instead of the default profile when you run conan install. See https://docs.conan.io/en/latest/reference/profiles.html.

chausner avatar May 14 '22 22:05 chausner