-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add a CMake based build for Windows
Given that swift-package-manager is not currently ready for Windows, this addition makes it possible to build for Windows.
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) | ||
|
||
project(swift-log | ||
LANGUAGES Swift) | ||
|
||
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swift) | ||
|
||
include(SwiftSupport) | ||
|
||
add_subdirectory(Sources) | ||
|
||
export(EXPORT swift-log | ||
NAMESPACE SwiftLog:: | ||
FILE swift-log-config.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(Logging) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
add_library(Logging | ||
Locks.swift | ||
Logging.swift | ||
LogHandler.swift) | ||
target_compile_options(Logging PRIVATE | ||
"SHELL:$<$<PLATFORM_ID:Windows>:-Xcc -D_CRT_SECURE_NO_WARNINGS>") | ||
set_target_properties(Logging PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) | ||
|
||
|
||
install(TARGETS Logging | ||
EXPORT swift-log | ||
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}> | ||
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}> | ||
RUNTIME DESTINATION bin) | ||
get_swift_host_arch(swift_arch) | ||
install(FILES | ||
EXPORT swift-log | ||
$<TARGET_PROPERTY:Logging,Swift_MODULE_DIRECTORY>/Logging.swiftdoc | ||
$<TARGET_PROPERTY:Logging,Swift_MODULE_DIRECTORY>/Logging.swiftmodule | ||
DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>/${swift_arch}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
# Returns the current architecture name in a variable | ||
# | ||
# Usage: | ||
# get_swift_host_arch(result_var_name) | ||
# | ||
# If the current architecture is supported by Swift, sets ${result_var_name} | ||
# with the sanitized host architecture name derived from CMAKE_SYSTEM_PROCESSOR. | ||
function(get_swift_host_arch result_var_name) | ||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") | ||
set("${result_var_name}" "x86_64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64") | ||
set("${result_var_name}" "aarch64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64") | ||
set("${result_var_name}" "powerpc64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le") | ||
set("${result_var_name}" "powerpc64le" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "s390x") | ||
set("${result_var_name}" "s390x" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6l") | ||
set("${result_var_name}" "armv6" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l") | ||
set("${result_var_name}" "armv7" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a") | ||
set("${result_var_name}" "armv7" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64") | ||
set("${result_var_name}" "x86_64" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64") | ||
set("${result_var_name}" "itanium" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86") | ||
set("${result_var_name}" "i686" PARENT_SCOPE) | ||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686") | ||
set("${result_var_name}" "i686" PARENT_SCOPE) | ||
else() | ||
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}") | ||
endif() | ||
endfunction() |