-
Notifications
You must be signed in to change notification settings - Fork 440
[CMake] Updates to allow inclusion using FetchContent #2173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
87d268f
19b95e6
05e4a10
a47c358
1b30b77
b369ac0
bcd7fc4
1b410c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,25 @@ project(SwiftSyntax LANGUAGES C Swift) | |
set(SWIFT_VERSION 5) | ||
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION}) | ||
|
||
if(CMAKE_VERSION VERSION_LESS 3.21) | ||
get_property(parent_dir DIRECTORY PROPERTY PARENT_DIRECTORY) | ||
if(NOT parent_dir) | ||
set(PROJECT_IS_TOP_LEVEL TRUE) | ||
endif() | ||
endif() | ||
|
||
# The subdirectory into which host libraries will be installed. | ||
set(SWIFT_HOST_LIBRARIES_SUBDIRECTORY "swift/host") | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARIES_SUBDIRECTORY}") | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARIES_SUBDIRECTORY}") | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") | ||
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARIES_SUBDIRECTORY}") | ||
endif() | ||
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARIES_SUBDIRECTORY}") | ||
endif() | ||
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") | ||
endif() | ||
|
||
set(CMAKE_MACOSX_RPATH YES) | ||
|
||
|
@@ -49,22 +62,25 @@ if (NOT SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT) | |
endif() | ||
|
||
# Determine the module triple. | ||
# FIXME: This is a hack. It's all a hack. Windows isn't setting | ||
# CMAKE_Swift_COMPILER_TARGET. | ||
if(CMAKE_Swift_COMPILER_TARGET) | ||
string(REGEX REPLACE "macosx[0-9]+([.][0-9]+)?" "macos" SWIFT_MODULE_TRIPLE | ||
${CMAKE_Swift_COMPILER_TARGET}) | ||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | ||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") | ||
set(SWIFT_MODULE_TRIPLE "x86_64-unknown-windows-msvc") | ||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64") | ||
set(SWIFT_MODULE_TRIPLE "aarch64-unknown-windows-msvc") | ||
if("${SWIFT_HOST_MODULE_TRIPLE}" STREQUAL "") | ||
# FIXME: This is a hack. It's all a hack. Windows isn't setting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I follow this. This is meant to be a user controlled option, what were you expecting? Or is this is a bug CMake that we should also try to get fixed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is just what was already there, I don't think this is a CMake bug. For non-Windows it's all being set via build-script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to expand on this... The reason we need the module triple at all is to output the module in the subfolder format rather than the flat format. Ideally we'll get that fixed at some point in CMake itself 😅. |
||
# CMAKE_Swift_COMPILER_TARGET. | ||
if(CMAKE_Swift_COMPILER_TARGET) | ||
string(REGEX REPLACE "macosx[0-9]+([.][0-9]+)?" "macos" SWIFT_HOST_MODULE_TRIPLE | ||
${CMAKE_Swift_COMPILER_TARGET}) | ||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | ||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") | ||
set(SWIFT_HOST_MODULE_TRIPLE "x86_64-unknown-windows-msvc") | ||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64") | ||
set(SWIFT_HOST_MODULE_TRIPLE "aarch64-unknown-windows-msvc") | ||
else() | ||
message(FATAL_ERROR "Unrecognized architecture for Windows host") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Unrecognized architecture for Windows host") | ||
message(FATAL_ERROR "Host module triple required") | ||
endif() | ||
endif() | ||
|
||
message(STATUS "Module triple: ${SWIFT_MODULE_TRIPLE}") | ||
message(STATUS "Module triple: ${SWIFT_HOST_MODULE_TRIPLE}") | ||
|
||
# Force single-threaded-only syntax trees to eliminate the Darwin | ||
# dependency in the compiler. | ||
|
@@ -78,10 +94,4 @@ if (SWIFTSYNTAX_ENABLE_ASSERTIONS) | |
endif() | ||
|
||
add_subdirectory(Sources) | ||
|
||
export(EXPORT SwiftSyntaxTargets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/SwiftSyntaxTargets.cmake" | ||
NAMESPACE SwiftSyntax:: | ||
) | ||
|
||
add_subdirectory(cmake/modules) |
Uh oh!
There was an error while loading. Please reload this page.