From 75a3eca905f0a25137cf8f33541b591cdf5c53ac Mon Sep 17 00:00:00 2001 From: Chris McGee <87777443+cmcgee1024@users.noreply.github.com> Date: Mon, 10 Feb 2025 12:10:44 -0500 Subject: [PATCH] Add the necessary swift defines in CMake for Crypto module (#323) ### 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: When building SwiftPM with CMake and the swift-crypto package there are errors being produced on macOS relating to missing imports provided by the CryptoKit package. ### Modifications: Modify the CMakeLists.txt file for the Crypto target so that the defines are set like they are in the Package.swift. ### Result: After the change, building SwiftPM with CMake on macOS should work. --- Sources/_CryptoExtras/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/_CryptoExtras/CMakeLists.txt b/Sources/_CryptoExtras/CMakeLists.txt index 9c578708..779d925d 100644 --- a/Sources/_CryptoExtras/CMakeLists.txt +++ b/Sources/_CryptoExtras/CMakeLists.txt @@ -52,6 +52,12 @@ add_library(_CryptoExtras "Util/SubjectPublicKeyInfo.swift" "ZKPs/DLEQ.swift") +target_compile_options(_CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM="true") + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "WASI" OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + target_compile_options(_CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM_FORCE_BUILD_API="true") +endif() + target_include_directories(_CryptoExtras PRIVATE $ $)