Skip to content

Remove warnings as errors compile flag from project CMakeLists.txtΒ #1294

@midget214

Description

@midget214

Description

Deciding to treat warnings as errors should be left to the consumer compiling the library rather than being enforced by the compile flags set inside the CMakeLists.txt file. Producing no compiler warnings is a goal every developer should strive for, it is impossible to check every possible configuration that consumers of a library may have.

Currently on our environment the following warnings are being produced causing the build to fail

libCPR\src\cpr\error.cpp(167,19): error: no newline at end of file [-Werror,-Wnewline-eof]

[build]   167 | } // namespace cpr

 

libCPR\src\include\cpr/threadpool.h(85,70): error: declaration shadows a local variable [-Werror,-Wshadow-uncaptured-local]

[build]    85 |         auto task = std::make_shared<std::packaged_task<RetType()>>([fn = std::forward<Fn>(fn), args...]() mutable { return std::invoke(fn, args...); });

Example/How to Reproduce

  1. Setup an environment as described in additional context section
  2. Attempt to compile

Possible Fix

Follow modern CMake best practices by not turning warnings into errors inside the CMakeLists.txt file. Users / CI builds can turn this on by either setting COMPILE_WARNING_AS_ERROR variable on the command line or by setting the 'CMAKE_COMPILE_WARNING_AS_ERROR' cache variable if using presets

For info on this setting can be found here

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Windows 10
  • Compiler: Clang for windows version 17.0.3
  • Build System: Ninja
  • libCPR Version: 1.11.1

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