【发布时间】:2017-06-01 10:46:12
【问题描述】:
我正在使用CMake GUI(无版本)和CMake 3.6.1。我正在使用带有add_subdirectory 的外部模块,它向我显示了一些我不喜欢的警告(因为恼人的污染):
CMake Warning (dev) at D:/Sources/.../external/g3log/latest/Build.cmake:11 (IF):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
D:/Sources/.../external/g3log/latest/CMakeLists.txt:72 (INCLUDE)
This warning is for project developers. Use -Wno-dev to suppress it.
我想隐藏这些警告而不接触外部文件。 -Wno-dev 如果只影响外部模块(g3log)就可以了。
我尝试使用cmake_policy,如下所示,但没有效果:
cmake_policy(PUSH)
cmake_policy(SET CMP0054 OLD)
add_subdirectory(${g3log_DIR} ${CMAKE_BINARY_DIR}/../g3log)
cmake_policy(POP)
【问题讨论】:
-
听起来你的外部模块确实有一个
project()命令。这将重置此子模块及以下的策略。您可以尝试设置CMAKE_POLICY_DEFAULT_CMP0054而不是调用cmake_policy()。 -
确实有一个
project (g3log)。所以你说是不可能的:(?如果你愿意,你可以制定一个答案。 -
没有。我试图说
cmake_policy(SET CMP0054 ...)不起作用,但CMAKE_POLICY_DEFAULT_CMP0054应该。只是还没有设置测试来验证它。 -
原谅我的无知,但是如何呢?
set(CMAKE_POLICY_DEFAULT_CMP0054, OLD)?
标签: cmake suppress-warnings cmake-gui