CMAKE没有定义CYGWIN变量

时间:2016-03-01 16:27:05

标签: cmake cygwin

我在Windows 7 64位下的cygwin控制台上使用cmake。但是,cmake变量 CYGWIN https://cmake.org/cmake/help/v3.3/variable/CYGWIN.html)未定义。我错过了什么吗?

例如,这是我的CMakeLists.txt:

message("CYGWIN: ${CYGWIN}")
message("CMAKE SYSTEM: ${CMAKE_SYSTEM_NAME}")
project ( foo CXX)

我使用cygwin控制台并执行:

cmake path/to/my/CMakeLists.txt

选择输出:

>    CYGWIN: 
>    CMAKE SYSTEM:
> -- The CXX compiler identification is GNU 4.9.2
> 
>    ( a warning about the WIN32 variable not being defined by cmake anymore)
> 
> -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++.exe
> -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++.exe -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Detecting CXX compile features
> -- Detecting CXX compile features - done
> -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc.exe
> -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc.exe -- works
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /foo/directory

配置:

  • uname CYGWIN_NT-6.1
  • cmake版本3.3.2(由Kitware维护和支持的CMake套件(kitware.com/cmake)。

1 个答案:

答案 0 :(得分:2)

CYGWIN cmake变量由project()命令定义。在message命令之前移动它可以解决问题。

的CMakeLists.txt:

project(foo CXX)
message("CYGWIN: ${CYGWIN}")
message("CMAKE SYSTEM: ${CMAKE_SYSTEM_NAME}")

相关产出:

> -- The CXX compiler identification is GNU 4.9.2
>    (a lot of talking)
>    CYGWIN: 1
>    CMAKE SYSTEM: CYGWIN