mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:
- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
expands to 1, where it would previously coerce to a string.
- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
left-hand side expands twice.
In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:
- Quoted right-hand side of `STREQUAL` where I was confident it was
intended to be a string literal.
- Removed manual variable expansion on left-hand side of `STREQUAL`,
`MATCHES` and `IN_LIST` where I was confident it was unintended.
Fixes #65028.
66 lines
1.5 KiB
CMake
66 lines
1.5 KiB
CMake
|
|
|
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
|
set(SWIFT_GYB_FLAGS --line-directive "^\"#line %(line)d \\\"%(file)s\\\"^\"")
|
|
else()
|
|
set(SWIFT_GYB_FLAGS --line-directive "\'#line" "%(line)d" "\"%(file)s\"\'")
|
|
endif()
|
|
|
|
add_swift_host_library(swiftParse STATIC
|
|
Confusables.cpp
|
|
Lexer.cpp
|
|
ParseDecl.cpp
|
|
ParseExpr.cpp
|
|
ParseGeneric.cpp
|
|
ParseIfConfig.cpp
|
|
ParsePattern.cpp
|
|
Parser.cpp
|
|
ParseRegex.cpp
|
|
ParseRequests.cpp
|
|
ParseStmt.cpp
|
|
ParseType.cpp
|
|
ParseVersion.cpp
|
|
PersistentParserState.cpp)
|
|
target_link_libraries(swiftParse PRIVATE
|
|
swiftAST
|
|
)
|
|
|
|
if (SWIFT_SWIFT_PARSER)
|
|
target_link_libraries(swiftParse
|
|
PRIVATE
|
|
SwiftSyntax::SwiftBasicFormat
|
|
SwiftSyntax::SwiftParser
|
|
SwiftSyntax::SwiftParserDiagnostics
|
|
SwiftSyntax::SwiftDiagnostics
|
|
SwiftSyntax::SwiftSyntax
|
|
SwiftSyntax::SwiftOperators
|
|
SwiftSyntax::SwiftSyntaxBuilder
|
|
SwiftSyntax::SwiftSyntaxMacros
|
|
swiftASTGen
|
|
)
|
|
|
|
add_dependencies(swiftParse
|
|
SwiftSyntax::SwiftBasicFormat
|
|
SwiftSyntax::SwiftParser
|
|
SwiftSyntax::SwiftParserDiagnostics
|
|
SwiftSyntax::SwiftDiagnostics
|
|
SwiftSyntax::SwiftSyntax
|
|
SwiftSyntax::SwiftOperators
|
|
SwiftSyntax::SwiftSyntaxBuilder
|
|
SwiftSyntax::SwiftSyntaxMacros
|
|
swiftASTGen
|
|
)
|
|
|
|
target_compile_definitions(swiftParse
|
|
PRIVATE
|
|
SWIFT_SWIFT_PARSER
|
|
)
|
|
endif()
|
|
|
|
if(SWIFT_COMPILER_VERSION)
|
|
set_property(SOURCE ParseVersion.cpp APPEND_STRING PROPERTY COMPILE_FLAGS
|
|
" -DSWIFT_COMPILER_VERSION=\"\\\"${SWIFT_COMPILER_VERSION}\\\"\"")
|
|
endif()
|
|
|
|
set_swift_llvm_is_available(swiftParse)
|