Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot set CMAKE_WARN_DEPRECATED inside the CMakeLists.txt

Tags:

cmake

I'm building Googletest as a dependency of my code. Unfortunately Googletest requires very old versions of CMake, which triggers a lot of deprecation warning. I'd like to get rid of them.

I can successfully hide the warnings through command line flags like these:

cmake -Wno-deprecated ..
cmake -DCMAKE_WARN_DEPRECATED=OFF ..

However, I'd prefer to have that set inside the CMakeLists.txt. But I'm not sure how to specify that. The following two commands didn't help:

set(CMAKE_WARN_DEPRECATED OFF)
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL)

Any ideas? Also, is there maybe a way to have that setting for a limited scope, like e.g. one subdirectory?

like image 933
Georg P. Avatar asked May 03 '26 01:05

Georg P.


1 Answers

Found it out. A little extra flag did the trick:

set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)

Not sure though if that's the recommended way to go.

like image 177
Georg P. Avatar answered May 05 '26 09:05

Georg P.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!