0

I'm trying to add a library to my CMake project, but I don't want the compiler to give me warning for this project so that I can enable -werror.

For this I tried using the SYSTEM flag in FetchContent, with no success :

FetchContent_Declare(
        raylib
        GIT_REPOSITORY https://github.com/raysan5/raylib.git
        GIT_TAG 4.2.0
        SYSTEM
)
FetchContent_MakeAvailable(raylib)

This is the case for raylib and Google Test. Is there something to be done the the library side ? Or can I do something about it ?

TOOL
  • 70
  • 1
  • 10
  • If you can't control/configure this using raylib CMake options, why not just try disabling the warnings on the `raylib` target? `target_compile_options(raylib PRIVATE )` – thomas_f Jan 31 '23 at 11:01
  • It could work, but then I would need to add them for every compiler and every dependency. It's not ideal but I guess I could do that for now. – TOOL Jan 31 '23 at 11:03
  • 1
    CMake has no cross-platform notion about compiler options which enable/disable compiler warnings. The most CMake can is to add some include directories as SYSTEM ones, so a compiler won't emit some warnings for *headers* placed in that directory. But this cannot suppress warnings in the *source* files. So you need to explicitly set/unset compiler options which affects the warnings. See [duplicate question](https://stackoverflow.com/questions/68708076/how-to-add-compile-options-to-a-cmake-fetchcontent-dependency) about how to do that in case of FetchContent. – Tsyvarev Jan 31 '23 at 12:18

0 Answers0