Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,801
    • Issues 3,801
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #23095

Closed
Open
Created Jan 11, 2022 by Mario Emmenlauer@emmenlau🌞Contributor

Compiling cmake with clang-cl: Why does it pick the MSVC compiler instead?

I'm using the clang-cl driver for Visual Studio with cmake for many projects. It generally works great. But recently I've found that when compiling cmake itself, it is still using the cl.exe compiler instead of clang-cl.exe.

For most projects, I just set CC="clang-cl.exe" and CXX="clang-cl.exe", then run cmake like before, and everything "magically" works. Since this seemed not to work for cmake, I've tried to add -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe, but also that does not help.

Here is the output I get:

#> C:\BDA\bld\XTJyb_7r\0\cmake \
    -DCMAKE_PREFIX_PATH=C:/data/ci-dst-C7Ha32c192930137c1300/Tools;C:/data/ci-dst-C7Ha32c192930137c1300/Tools/lib/cmake \
    -DCMAKE_INSTALL_PREFIX=C:\data\ci-dst-C7Ha32c192930137c1300\Tools \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -DCMAKE_CUDA_COMPILER=nvcc.exe \
    -DCMake_BUILD_DEVELOPER_REFERENCE=OFF \
    -DCMake_BUILD_LTO=ON \
    -DCMAKE_USE_SYSTEM_LIBARCHIVE=OFF \
    -DCMAKE_USE_SYSTEM_CURL=OFF \
    -DCMAKE_USE_SYSTEM_EXPAT=OFF \
    -DCMAKE_USE_SYSTEM_ZLIB=OFF \
    -DCMAKE_USE_SYSTEM_BZIP2=OFF \
    -DCMAKE_USE_SYSTEM_ZSTD=OFF \
    -DCMAKE_USE_SYSTEM_LIBLZMA=OFF \
    -DCMAKE_USE_SYSTEM_FORM=OFF \
    -DCMAKE_USE_SYSTEM_JSONCPP=OFF \
    -DCMAKE_USE_SYSTEM_LIBRHASH=OFF \
    -DCMAKE_USE_SYSTEM_LIBUV=OFF \
    -DCMAKE_USE_SYSTEM_KWIML=OFF \
    -DCMAKE_USE_OPENSSL=ON \
    -DBUILD_CursesDialog=OFF \
    -DCMAKE_C_COMPILER=clang-cl.exe \
    -DCMAKE_CXX_COMPILER=clang-cl.exe \
    -DCMAKE_CXX_STANDARD=17
Re-run cmake no build system arguments
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.29.30137.0
-- The CXX compiler identification is MSVC 19.29.30137.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
[...]

Why is the compiler selected as cl.exe? Am I doing something wrong?

I would like to use some clang-cl optimizations, so it would be nice if I could pick clang-cl. Or is it not supported for compiling cmake?

Edited Jan 11, 2022 by Mario Emmenlauer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking