Skip to content

Building using Clang-cl and Ninja fails on Windows #927

@Sightem

Description

@Sightem

Description

Running CMake with Ninja as it's generator specified using the -G parameter seems to be broken, at least when used with fetch content.

Example/How to Reproduce

  1. Create a project with the following structure and run the following commands:
│   CMakeLists.txt
│
├───build
└───src
      main.cpp
cmake_minimum_required (VERSION 3.8)
project(testproj
		VERSION 1.0 DESCRIPTION "awesome"
		LANGUAGES C CXX
)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
                         GIT_TAG 2553fc41450301cd09a9271c8d2c3e0cf3546b73) # The commit hash for 1.10.x. Replace with the latest from: https://github.com/libcpr/cpr/releases
FetchContent_MakeAvailable(cpr)
file(GLOB_RECURSE SOURCES "src/*.cpp")

add_executable(testproj ${SOURCES})

target_include_directories(testproj PUBLIC include)
target_link_libraries(testproj PRIVATE cpr::cpr)
  1. Open x64 Native Tools Command Prompt for VS 2022
  2. cd build
  3. cmake -G "Ninja" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl ..
  4. ninja
  5. Observe the wall of errors

Possible Fix

No response

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Windows 10 22H2
  • Additional context: Clang-cl does seem to work without ninja, if you just run the command
    cmake -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl .. (this uses Visual Studio 17 2022)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions