I am trying to build the following project https://github.com/whoshuu/cpr#cmake into my project by following their instructions for CMake reproduced below:
include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG c8d33915dbd88ad6c92b258869b03aba06587ff9) # the commit hash for 1.5.0
FetchContent_MakeAvailable(cpr)
My project already had some other libraries linked with the main target so I included this new library as follows:
target_link_libraries(my_target PRIVATE cpr::cpr PUBLIC other_libraries)
The problem with this is that the warnings from building the cpr
library are preventing the project from building. I would like to suppress these warnings. I have tried adding the SYSTEM
keyword as recommended here: How to suppress GCC warnings from library headers? so the code would look as follows:
target_link_libraries(my_target PRIVATE SYSTEM cpr::cpr PUBLIC other_libraries)
but this did not help. Are there other methods to suppress warnings from external libraries in CMake? If it helps, I am using C++-17
g++-11
and Ninja.