Fix CMakeLists.txt for Windows (#326)

This change prepares swift-crypto for use on Windows with CMake and also
the Package.swift for use in the Swift toolchain CI system.

### Checklist
- [X] I've run tests to see all new and existing tests pass
- [X] I've followed the code style of the rest of the project
- [X] I've read the [Contribution Guidelines](CONTRIBUTING.md)
- [X] I've updated the documentation if necessary

#### If you've made changes to `gyb` files
- [X] I've run `.script/generate_boilerplate_files_with_gyb` and
included updated generated files in a commit of this pull request

### Motivation:

Upgrading swift-crypto from an older version requires that Windows works
properly with CMake, and also SwiftPM.

### Modifications:

Modify the CMakeLists.txt files and the generator script so that it
conditionally adds assembly files for non-Windows platforms. Prepare the
Package.swift file for use in Swift CI pipelines, by consulting an
environment to either use the absolute URL, or a prepared version of the
swift-asn1 dependency.

### Result:

After this change it should be possible to build with the newest
swift-crypto in the Swift CI system.
This commit is contained in:
Chris McGee authored and GitHub committed 2025-02-14 13:37:49 +00:00
1 parent b81059d507
commit b6049c0b2e
8 files changed
+33 -16

No files matched your search

+5 -2
View File
@@ -32,7 +32,7 @@ function update_cmakelists_source() {
src_exts=("*.c" "*.swift" "*.cc")
num_exts=${#src_exts[@]}
echo "Finding source files (" "${src_exts[@]}" ") platform independent assembly files under $src_root"
echo "Finding source files (" "${src_exts[@]}" ") and platform independent assembly files under $src_root"
# Build file extensions argument for `find`
declare -a exts_arg
@@ -56,7 +56,10 @@ function update_cmakelists_source() {
fi
# Wrap quotes around each filename since it might contain spaces
srcs=$($find -L "${src_root}" -type f \( \( "${exts_arg[@]}" \) -o \( -name "*.S" -a ! -name "*x86_64*" -a ! -name "*arm*" -a ! -name "*apple*" -a ! -name "*linux*" \) \) -printf ' "%P"\n' | LC_ALL=POSIX sort)
srcs=$($find -L "${src_root}" -type f \( "${exts_arg[@]}" \) -printf ' "%P"\n' | LC_ALL=POSIX sort)
asm_srcs=$($find -L "${src_root}" -type f \( \( -name "*.S" -a ! -name "*x86_64*" -a ! -name "*arm*" -a ! -name "*apple*" -a ! -name "*linux*" \) \) -printf ' "$<$<NOT:$<PLATFORM_ID:Windows>>:%P>"\n' | LC_ALL=POSIX sort)
srcs="$srcs"$'\n'"$asm_srcs"
echo "$srcs"
# Update list of source files in CMakeLists.txt