Cause
Signature command ifcmake
if(<variable|string> MATCHES regex)
but not
if(<string> MATCHES regex)
, CYGWIN , , CYGWIN .
</h3 >
CYGWIN (. ):
> cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(foo)
message("cygwin variable: ${CYGWIN}")
> cmake -H. -B_builds
...
cygwin variable: 1
...
if (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
message("EQUALS CYGWIN")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "CYGWIN")
message("MATCHES CYGWIN")
endif()
if (${FOO} MATCHES "BAR")
message("MATCHES BAR")
endif()
<variable|string> ,
:
> cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(foo)
set("/this/is/definitely/not/a/variable/name" "surprise!")
message("${/this/is/definitely/not/a/variable/name}")
> cmake -H. -B_builds
...
surprise!
...
, string:
string(COMPARE EQUAL "${CMAKE_SYSTEM_NAME}" "CYGWIN" is_cygwin)
if(is_cygwin)
message("Hello, cygwin!")
endif()
, CYGWIN:
if(CYGWIN)
message("Hello, cygwin!")
endif()
user2288008