Skip to content

CMake build enables all compiler warnings when building with clang-cl #2448

Closed

Description

@nickhutchinson

Describe the bug
When building zstd using clang-cl, the LLVM MSVC-compatible driver, zstd's CMake build emits a very large number of compiler warnings, because zstd's build incorrectly passes -Wall to the compiler. [Source]

For compatibility with MSVC, when -Wall is passed to clang-cl, it's translated to -Weverything.

Note that when using clang-cl, CMake sets CMAKE_C_COMPILER_ID to "Clang" and MSVC to TRUE.

To Reproduce
In a MSVC developer prompt with cmake, ninja and clang-cl available on PATH:

cmake \path\to\zstd\build\cmake -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -GNinja
cmake --build .

Expected behavior
A (mostly?) warning-free build.

Screenshots and charts
If applicable, add screenshots and charts to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version [e.g. 22] 20H2
  • Compiler MSVC 14.28 / LLVM 11.0.0
  • Flags [e.g O2]
  • Other relevant hardware specs [e.g. Dual-core]
  • Build system: CMake 3.19.2

Additional context
Add any other context about the problem here.

Activity

  1. terrelln commented on Apr 30, 2021

    @terrelln
    Contributor

    We don't have the setup to test this, but we would be happy to accept a PR that fixes this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions