diff options
| author | David Tenty <daltenty@ibm.com> | 2025-08-20 12:45:41 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-20 12:45:41 -0400 |
| commit | 63195d3d7a8bde05590f91a38398f986bb4265b2 (patch) | |
| tree | 78bf2ad890b8561a789887b5623ce6eb56e6af30 /third-party | |
| parent | fdfcebb38d18fa328d51794e4f8b6914dc87759b (diff) | |
[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
https://gitlab.kitware.com/cmake/cmake/-/commit/ff03db6657c38c8cf992877ea66174c33d0bcb0b
However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:
`if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")`
which becomes:
`if (AIX MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`
You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.
Diffstat (limited to 'third-party')
| -rw-r--r-- | third-party/benchmark/src/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | third-party/unittest/CMakeLists.txt | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/third-party/benchmark/src/CMakeLists.txt b/third-party/benchmark/src/CMakeLists.txt index 943594b70bcd..0357dcce3f83 100644 --- a/third-party/benchmark/src/CMakeLists.txt +++ b/third-party/benchmark/src/CMakeLists.txt @@ -57,12 +57,12 @@ endif(HAVE_LIB_RT) # We need extra libraries on Windows -if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") target_link_libraries(benchmark PRIVATE shlwapi) endif() # We need extra libraries on Solaris -if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") +if("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS") target_link_libraries(benchmark PRIVATE kstat) endif() diff --git a/third-party/unittest/CMakeLists.txt b/third-party/unittest/CMakeLists.txt index b9f3593320d7..3fa885a16ea1 100644 --- a/third-party/unittest/CMakeLists.txt +++ b/third-party/unittest/CMakeLists.txt @@ -16,7 +16,7 @@ if(WIN32) endif() # Google Test requires headers which need _ALL_SOURCE to build on AIX -if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") +if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX") remove_definitions("-D_XOPEN_SOURCE=700") add_definitions("-D_ALL_SOURCE") endif() |
