Skip to content

Commit cc0c2bf

Browse files
tinysun212jrose-apple
authored andcommitted
[cmake] Change CMake Policy CMP0054 for Cygwin (#4274)
In CMake 3.4.3, if `CMP0054` policy isn't set to any value, `cmake` uses the OLD behavior and issues a long warning message for every `if()` statement having a quoted variable whose value is an other variable's name. For example, ``` set(FOO 1) set(VAR_A FOO) set(VAR_B BAR) if ("${VAR_A}" STREQUAL "FOO") endif() if ("${VAR_B}" STREQUAL "BAR") endif() ``` issues `CMP0054` warning message for `"${VAR_A}"` and not for `"${VAR_B}"`. Cygwin `cmake` defines the variable `CMAKE_SYSTEM_NAME` as `CYGWIN` and defines the variable `CYGWIN` as 1(TRUE). Linux `cmake` defines the variable `CMAKE_SYSTEM_NAME` as `Linux` and there is no variable `Linux`. So, if we didn't set any value to `CMP0054` policy, every `if ("${CMAKE_SYSTEM_NAME}" ...)` generated long warning message in Cygwin, but did not generate in Linux.
1 parent 2e20c11 commit cc0c2bf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ if(POLICY CMP0051)
44
cmake_policy(SET CMP0051 NEW)
55
endif()
66

7+
if(POLICY CMP0054)
8+
cmake_policy(SET CMP0054 NEW)
9+
endif()
10+
711
# Add path for custom CMake modules.
812
list(APPEND CMAKE_MODULE_PATH
913
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

stdlib/public/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ else()
174174
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY})
175175
endif()
176176

177-
if(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
177+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
178178
execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}"
179179
OUTPUT_VARIABLE ENV_SYSTEMROOT)
180180

0 commit comments

Comments
 (0)