如何在 CMake 3.1 中禁用有关未定义 cygwin WIN32 的警告?
How to disable warning in CMake 3.1 about cygwin WIN32 not being defined?
我以前从未使用过 CMake,但我正在尝试不支持任何其他构建系统的 IDE (CLion),所以我试一试。我在每次构建开始时收到以下警告:
CMake Warning at
/cygdrive/c/Users/admin/.clion10/system/cygwin_cmake/share/cmake-3.1.2/Modules/Platform/CYGWIN.cmake:15
(message): CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this
warning or quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your
environment or in the CMake cache. If later configuration or build
errors occur then this project may have been written under the
assumption that Cygwin is WIN32. In that case, set
CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project
to build on Cygwin without WIN32
我已经尝试了两种建议的解决方案。这是我的 CMakeLists.txt 文件的前两行:
cmake_minimum_required(VERSION 3.1)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
但我仍然收到警告。我该如何摆脱它?
将 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
移动到 CMakeLists 文件的顶部。必须在 cmake_minimum_required
之前对其进行评估才能在此上下文中正常工作。
根据 CMake 邮件列表中的 Nils Gladitz(他在 SO 上吗?):
The code that emits the warning is run by "project()".
Since you do not have an explicit project() call in your top-level CMakeLists.txt CMake adds one to the top implicitly. [1]
A project file that explicitly calls project() after requiring CMake >= 2.8.4 should make the warning go away:
cmake_minimum_required(VERSION 2.8.8)
project(Foo)
它似乎有效。
Cygwin 和 Linux 都使用了我的 cmake 文件。所以对我来说,最简单的解决方案是编辑我的 Cygwin .bashrc 并添加行
export CMAKE_LEGACY_CYGWIN_WIN32=0
现在我不必在我的跨平台 cmake 文件中保留 Cygwin 特定语法。
我以前从未使用过 CMake,但我正在尝试不支持任何其他构建系统的 IDE (CLion),所以我试一试。我在每次构建开始时收到以下警告:
CMake Warning at /cygdrive/c/Users/admin/.clion10/system/cygwin_cmake/share/cmake-3.1.2/Modules/Platform/CYGWIN.cmake:15 (message): CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in the CMake cache. If later configuration or build errors occur then this project may have been written under the assumption that Cygwin is WIN32. In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum required version of CMake to 2.8.4 or higher. Then teach your project to build on Cygwin without WIN32
我已经尝试了两种建议的解决方案。这是我的 CMakeLists.txt 文件的前两行:
cmake_minimum_required(VERSION 3.1)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
但我仍然收到警告。我该如何摆脱它?
将 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
移动到 CMakeLists 文件的顶部。必须在 cmake_minimum_required
之前对其进行评估才能在此上下文中正常工作。
根据 CMake 邮件列表中的 Nils Gladitz(他在 SO 上吗?):
The code that emits the warning is run by "project()". Since you do not have an explicit project() call in your top-level CMakeLists.txt CMake adds one to the top implicitly. [1]
A project file that explicitly calls project() after requiring CMake >= 2.8.4 should make the warning go away:
cmake_minimum_required(VERSION 2.8.8)
project(Foo)
它似乎有效。
Cygwin 和 Linux 都使用了我的 cmake 文件。所以对我来说,最简单的解决方案是编辑我的 Cygwin .bashrc 并添加行
export CMAKE_LEGACY_CYGWIN_WIN32=0
现在我不必在我的跨平台 cmake 文件中保留 Cygwin 特定语法。