Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Sightem opened this issue Jul 9, 2023 · 7 comments · Fixed by #937
Closed

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

Sightem opened this issue Jul 9, 2023 · 7 comments · Fixed by #937

Comments

@Sightem
Copy link

Sightem commented Jul 9, 2023

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)
@COM8
Copy link
Member

COM8 commented Jul 9, 2023

@Sightem thanks for reporting! Could you please provide a log so I can see if I actually can reproduce the same issue?

@Sightem
Copy link
Author

Sightem commented Jul 9, 2023

@Sightem thanks for reporting! Could you please provide a log so I can see if I actually can reproduce the same issue?

Definitely! Here is a complete paste of the process including running every command. I apologize in advance if I don't reply fast, I am writing this at 4 in the morning

@COM8
Copy link
Member

COM8 commented Jul 9, 2023

Thanks! Somehow it's trying to compile for cpp98 but cpr requires at least cpp11 (https://github.com/libcpr/cpr#supported-releases). I will spin up my Windows VM later today, to try reproducing it since you are setting cpp20 as standard via set(CMAKE_CXX_STANDARD 20).

@Sightem
Copy link
Author

Sightem commented Jul 9, 2023

Thanks! Somehow it's trying to compile for cpp98 but cpr requires at least cpp11 (https://github.com/libcpr/cpr#supported-releases). I will spin up my Windows VM later today, to try reproducing it since you are setting cpp20 as standard via set(CMAKE_CXX_STANDARD 20).

Thanks for your response! I appreciate this greatly

@COM8
Copy link
Member

COM8 commented Jul 9, 2023

Confirmed for the latest master commit and the example repo: https://github.com/libcpr/example-cmake-fetch-content

@COM8
Copy link
Member

COM8 commented Jul 10, 2023

I'm currently working on a branch to fix this: https://github.com/libcpr/cpr/tree/fix/clang-windows-warnings
The plan is to finish this in the next two days since I want to integrate this with a CI run in #837.

@COM8 COM8 added this to the CPR 1.9.x milestone Jul 11, 2023
@COM8
Copy link
Member

COM8 commented Jul 11, 2023

Should work now. Could you please validate this with the latest commit of the clang-windows-warnings branch.

@COM8 COM8 closed this as completed in #937 Aug 3, 2023
COM8 added a commit that referenced this issue Aug 3, 2023
COM8 added a commit that referenced this issue Aug 3, 2023
COM8 added a commit that referenced this issue Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants