Get rid of the CMake warning "Manually specified variables were not used by the project"

What is the preferred way to just touch the variable inside CMakeLists.txt ?

I have a bunch of similar external objects that are called in a loop with the same variables. Some of the projects do not need specific variables.

+5
source share
1 answer

You can simply disable this warning together by passing --no-warn-unused-cli to CMake. See: https://cmake.org/cmake/help/v3.5/manual/cmake.1.html

Touching a variable is clearly not required according to one of the authors of CMake: https://cmake.org/pipermail/cmake/2011-February/042908.html

However, for variables passed in -DFOO=bar -DBAR=3 -DBAZ=true , you can add a line

 set(ignoreMe "${FOO}${BAZ}${BAR}") 

to one of your CMakeLists.txt , which should be sufficient to suppress the warning.

+11
source

Source: https://habr.com/ru/post/1246552/


All Articles