Drude
Drude

Reputation: 61

CMAKE does not define the CYGWIN variable

I am using cmake on a cygwin console under Windows 7 64 bit. However the cmake variable CYGWIN (https://cmake.org/cmake/help/v3.3/variable/CYGWIN.html) is undefined. Am I missing something?

For example, here is my CMakeLists.txt:

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

I lauch the cygwin console and do:

cmake path/to/my/CMakeLists.txt

Selected Output:

>    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

Configuration:

Upvotes: 2

Views: 1610

Answers (1)

Drude
Drude

Reputation: 61

The CYGWIN cmake variable is defined by the project() command. Moving it before the message commands solves the problem.

CMakeLists.txt:

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

Relevant Output:

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

Upvotes: 4

Related Questions