David Tenty 63195d3d7a
[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.)
ff03db6657

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.
2025-08-20 12:45:41 -04:00

45 lines
1.1 KiB
CMake

# Ensure that libLLVMTargetParser does not carry any static global initializer.
# ManagedStatic can be used to enable lazy-initialization of globals.
#
# HAS_WERROR_GLOBAL_CTORS and LLVM_HAS_NOGLOBAL_CTOR_MUTEX should have been set
# by llvm/lib/Support/CMakeLists.txt (which provides the required Support
# dependency).
if (HAS_WERROR_GLOBAL_CTORS AND NOT LLVM_HAS_NOGLOBAL_CTOR_MUTEX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=global-constructors")
endif()
# Solaris code uses kstat, so specify dependency explicitly for shared builds.
if ("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
set(system_libs kstat)
endif()
add_llvm_component_library(LLVMTargetParser
AArch64TargetParser.cpp
ARMTargetParserCommon.cpp
ARMTargetParser.cpp
CSKYTargetParser.cpp
Host.cpp
LoongArchTargetParser.cpp
PPCTargetParser.cpp
RISCVISAInfo.cpp
RISCVTargetParser.cpp
SubtargetFeature.cpp
TargetParser.cpp
Triple.cpp
X86TargetParser.cpp
XtensaTargetParser.cpp
ADDITIONAL_HEADER_DIRS
Unix
Windows
LINK_LIBS
${system_libs}
LINK_COMPONENTS
Support
DEPENDS
target_parser_gen
)