如何修复CMake CMP0018警告?

时间:2014-04-11 08:09:49

标签: c++ cmake

我使用CMake 2.8.12.2构建我的项目(在Mac中),其中包含以下两个模块:

project
   |
   |____ module_a
   |
   |____ module_b

module_amodule_b构建为STATIC个库时,cmake project时没有警告。但如果我将模块更改为SHARED库,我会遇到警告:

  Variable CMAKE_SHARED_LIBRARY_C_FLAGS has been modified.  CMake will ignore
  the POSITION_INDEPENDENT_CODE target property for shared libraries and will
  use the CMAKE_SHARED_LIBRARY_C_FLAGS variable instead.  This may cause
  errors if the original content of CMAKE_SHARED_LIBRARY_C_FLAGS was removed.

  Policy CMP0018 is not set: Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS
  variable.  Run "cmake --help-policy CMP0018" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

这对我来说毫无意义,因为我从未处理过CMAKE_SHARED_LIBRARY_C_FLAGS

如何修复此警告?我不想忽略它。

1 个答案:

答案 0 :(得分:0)

您可以使用cmake_policy command选择所需的政策。