我在 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
配置:
- 命名 CYGWIN_NT-6.1
- cmake 版本 3.3.2(CMake 套件由 Kitware (kitware.com/cmake) 维护和支持。
最佳答案
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
关于CMAKE 未定义 CYGWIN 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35728166/