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 /libcxxabi | |
| 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 'libcxxabi')
| -rw-r--r-- | libcxxabi/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | libcxxabi/src/CMakeLists.txt | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index cf478bcee01f..3dabd87b9c58 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -244,7 +244,7 @@ include(HandleLibcxxabiFlags) #=============================================================================== # Configure target flags -if (${CMAKE_SYSTEM_NAME} MATCHES "AIX") +if ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX") add_flags_if_supported("-mdefault-visibility-export-mapping=explicit") set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF) endif() @@ -458,7 +458,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}") # On AIX, avoid picking up VMX extensions(i.e. vec_malloc) which would change # the default alignment of the allocators here. -if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") +if (UNIX AND "${CMAKE_SYSTEM_NAME}" MATCHES "AIX") add_definitions("-D_XOPEN_SOURCE=700") endif() diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt index 0675577aed6a..38a54b16278a 100644 --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -37,7 +37,7 @@ else() endif() if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN) - AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX")) + AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")) list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp ) |
