How to disable warning in CMake 3.1 about cygwin WIN32 not being defined?

cmake, cygwin

Solution

According to Nils Gladitz (is he on SO?) on the CMake mailing list:

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)`

And it seems to work.

Problem

I have never used CMake before, but I'm trying out an IDE (CLion) that doesn't support any other build system, so am giving it a try. I get the following warning at the start of every build: 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 I have tried both of the proposed solutions. Here are the first two lines of my CMakeLists.txt file: ``` cmake_minimum_required(VERSION 3.1) set(CMAKE_LEGACY_CYGWIN_WIN32 0) ``` yet I still get the warning. How do I get rid of it?

Original source