libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.58k stars 937 forks source link

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

Closed Sightem closed 1 year ago

Sightem commented 1 year ago

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

COM8 commented 1 year ago

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

Sightem commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

COM8 commented 1 year ago

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 commented 1 year ago

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