Skip to content

CMake build support #62

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ DerivedData
**/gyb.pyc

.*.sw[nop]

CMakeFiles
CMakeCache.txt
cmake_*.cmake
*.ninja
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This source file is part of the SwiftCrypto open source project
#
# Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
# Licensed under Apache License v2.0
#
# See LICENSE.txt for license information
# See CONTRIBUTORS.md for the list of SwiftCrypto project authors
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.15.1)

project(swift-crypto
LANGUAGES C Swift)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

include(SwiftSupport)

if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

add_subdirectory(Sources)
add_subdirectory(cmake/modules)
324 changes: 324 additions & 0 deletions Sources/CCryptoBoringSSL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
# This source file is part of the SwiftCrypto open source project
#
# Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
# Licensed under Apache License v2.0
#
# See LICENSE.txt for license information
# See CONTRIBUTORS.md for the list of SwiftCrypto project authors
#
# SPDX-License-Identifier: Apache-2.0

add_library(CCryptoBoringSSL STATIC
crypto/asn1/a_bitstr.c
crypto/asn1/a_bool.c
crypto/asn1/a_d2i_fp.c
crypto/asn1/a_dup.c
crypto/asn1/a_enum.c
crypto/asn1/a_gentm.c
crypto/asn1/a_i2d_fp.c
crypto/asn1/a_int.c
crypto/asn1/a_mbstr.c
crypto/asn1/a_object.c
crypto/asn1/a_octet.c
crypto/asn1/a_print.c
crypto/asn1/a_strnid.c
crypto/asn1/a_time.c
crypto/asn1/a_type.c
crypto/asn1/a_utctm.c
crypto/asn1/a_utf8.c
crypto/asn1/asn1_lib.c
crypto/asn1/asn1_par.c
crypto/asn1/asn_pack.c
crypto/asn1/f_enum.c
crypto/asn1/f_int.c
crypto/asn1/f_string.c
crypto/asn1/tasn_dec.c
crypto/asn1/tasn_enc.c
crypto/asn1/tasn_fre.c
crypto/asn1/tasn_new.c
crypto/asn1/tasn_typ.c
crypto/asn1/tasn_utl.c
crypto/asn1/time_support.c
crypto/base64/base64.c
crypto/bio/bio.c
crypto/bio/bio_mem.c
crypto/bio/connect.c
crypto/bio/fd.c
crypto/bio/file.c
crypto/bio/hexdump.c
crypto/bio/pair.c
crypto/bio/printf.c
crypto/bio/socket.c
crypto/bio/socket_helper.c
crypto/bn_extra/bn_asn1.c
crypto/bn_extra/convert.c
crypto/buf/buf.c
crypto/bytestring/asn1_compat.c
crypto/bytestring/ber.c
crypto/bytestring/cbb.c
crypto/bytestring/cbs.c
crypto/bytestring/unicode.c
crypto/chacha/chacha.c
crypto/cipher_extra/cipher_extra.c
crypto/cipher_extra/derive_key.c
crypto/cipher_extra/e_aesccm.c
crypto/cipher_extra/e_aesctrhmac.c
crypto/cipher_extra/e_aesgcmsiv.c
crypto/cipher_extra/e_chacha20poly1305.c
crypto/cipher_extra/e_null.c
crypto/cipher_extra/e_rc2.c
crypto/cipher_extra/e_rc4.c
crypto/cipher_extra/e_tls.c
crypto/cipher_extra/tls_cbc.c
crypto/cmac/cmac.c
crypto/conf/conf.c
crypto/cpu-aarch64-fuchsia.c
crypto/cpu-aarch64-linux.c
crypto/cpu-arm-linux.c
crypto/cpu-arm.c
crypto/cpu-intel.c
crypto/cpu-ppc64le.c
crypto/crypto.c
crypto/curve25519/curve25519.c
crypto/curve25519/spake25519.c
crypto/dh/check.c
crypto/dh/dh.c
crypto/dh/dh_asn1.c
crypto/dh/params.c
crypto/digest_extra/digest_extra.c
crypto/dsa/dsa.c
crypto/dsa/dsa_asn1.c
crypto/ec_extra/ec_asn1.c
crypto/ec_extra/ec_derive.c
crypto/ec_extra/hash_to_curve.c
crypto/ecdh_extra/ecdh_extra.c
crypto/ecdsa_extra/ecdsa_asn1.c
crypto/engine/engine.c
crypto/err/err.c
crypto/err/err_data.c
crypto/evp/digestsign.c
crypto/evp/evp.c
crypto/evp/evp_asn1.c
crypto/evp/evp_ctx.c
crypto/evp/p_dsa_asn1.c
crypto/evp/p_ec.c
crypto/evp/p_ec_asn1.c
crypto/evp/p_ed25519.c
crypto/evp/p_ed25519_asn1.c
crypto/evp/p_rsa.c
crypto/evp/p_rsa_asn1.c
crypto/evp/p_x25519.c
crypto/evp/p_x25519_asn1.c
crypto/evp/pbkdf.c
crypto/evp/print.c
crypto/evp/scrypt.c
crypto/evp/sign.c
crypto/ex_data.c
crypto/fipsmodule/aes/aes.c
crypto/fipsmodule/aes/aes_nohw.c
crypto/fipsmodule/aes/key_wrap.c
crypto/fipsmodule/aes/mode_wrappers.c
crypto/fipsmodule/bn/add.c
crypto/fipsmodule/bn/asm/x86_64-gcc.c
crypto/fipsmodule/bn/bn.c
crypto/fipsmodule/bn/bytes.c
crypto/fipsmodule/bn/cmp.c
crypto/fipsmodule/bn/ctx.c
crypto/fipsmodule/bn/div.c
crypto/fipsmodule/bn/div_extra.c
crypto/fipsmodule/bn/exponentiation.c
crypto/fipsmodule/bn/gcd.c
crypto/fipsmodule/bn/gcd_extra.c
crypto/fipsmodule/bn/generic.c
crypto/fipsmodule/bn/jacobi.c
crypto/fipsmodule/bn/montgomery.c
crypto/fipsmodule/bn/montgomery_inv.c
crypto/fipsmodule/bn/mul.c
crypto/fipsmodule/bn/prime.c
crypto/fipsmodule/bn/random.c
crypto/fipsmodule/bn/rsaz_exp.c
crypto/fipsmodule/bn/shift.c
crypto/fipsmodule/bn/sqrt.c
crypto/fipsmodule/cipher/aead.c
crypto/fipsmodule/cipher/cipher.c
crypto/fipsmodule/cipher/e_aes.c
crypto/fipsmodule/cipher/e_des.c
crypto/fipsmodule/des/des.c
crypto/fipsmodule/digest/digest.c
crypto/fipsmodule/digest/digests.c
crypto/fipsmodule/ec/ec.c
crypto/fipsmodule/ec/ec_key.c
crypto/fipsmodule/ec/ec_montgomery.c
crypto/fipsmodule/ec/felem.c
crypto/fipsmodule/ec/oct.c
crypto/fipsmodule/ec/p224-64.c
crypto/fipsmodule/ec/p256-x86_64.c
crypto/fipsmodule/ec/p256.c
crypto/fipsmodule/ec/scalar.c
crypto/fipsmodule/ec/simple.c
crypto/fipsmodule/ec/simple_mul.c
crypto/fipsmodule/ec/util.c
crypto/fipsmodule/ec/wnaf.c
crypto/fipsmodule/ecdh/ecdh.c
crypto/fipsmodule/ecdsa/ecdsa.c
crypto/fipsmodule/fips_shared_support.c
crypto/fipsmodule/hmac/hmac.c
crypto/fipsmodule/is_fips.c
crypto/fipsmodule/md4/md4.c
crypto/fipsmodule/md5/md5.c
crypto/fipsmodule/modes/cbc.c
crypto/fipsmodule/modes/cfb.c
crypto/fipsmodule/modes/ctr.c
crypto/fipsmodule/modes/gcm.c
crypto/fipsmodule/modes/gcm_nohw.c
crypto/fipsmodule/modes/ofb.c
crypto/fipsmodule/modes/polyval.c
crypto/fipsmodule/rand/ctrdrbg.c
crypto/fipsmodule/rand/fork_detect.c
crypto/fipsmodule/rand/rand.c
crypto/fipsmodule/rand/urandom.c
crypto/fipsmodule/rsa/blinding.c
crypto/fipsmodule/rsa/padding.c
crypto/fipsmodule/rsa/rsa.c
crypto/fipsmodule/rsa/rsa_impl.c
crypto/fipsmodule/self_check/self_check.c
crypto/fipsmodule/sha/sha1-altivec.c
crypto/fipsmodule/sha/sha1.c
crypto/fipsmodule/sha/sha256.c
crypto/fipsmodule/sha/sha512.c
crypto/fipsmodule/tls/kdf.c
crypto/hkdf/hkdf.c
crypto/hpke/hpke.c
crypto/hrss/hrss.c
crypto/lhash/lhash.c
crypto/mem.c
crypto/obj/obj.c
crypto/obj/obj_xref.c
crypto/pem/pem_all.c
crypto/pem/pem_info.c
crypto/pem/pem_lib.c
crypto/pem/pem_oth.c
crypto/pem/pem_pk8.c
crypto/pem/pem_pkey.c
crypto/pem/pem_x509.c
crypto/pem/pem_xaux.c
crypto/pkcs7/pkcs7.c
crypto/pkcs7/pkcs7_x509.c
crypto/pkcs8/p5_pbev2.c
crypto/pkcs8/pkcs8.c
crypto/pkcs8/pkcs8_x509.c
crypto/poly1305/poly1305.c
crypto/poly1305/poly1305_arm.c
crypto/poly1305/poly1305_vec.c
crypto/pool/pool.c
crypto/rand_extra/deterministic.c
crypto/rand_extra/forkunsafe.c
crypto/rand_extra/fuchsia.c
crypto/rand_extra/rand_extra.c
crypto/rand_extra/windows.c
crypto/rc4/rc4.c
crypto/refcount_c11.c
crypto/refcount_lock.c
crypto/rsa_extra/rsa_asn1.c
crypto/rsa_extra/rsa_print.c
crypto/siphash/siphash.c
crypto/stack/stack.c
crypto/thread.c
crypto/thread_none.c
crypto/thread_pthread.c
crypto/thread_win.c
crypto/trust_token/pmbtoken.c
crypto/trust_token/trust_token.c
crypto/trust_token/voprf.c
crypto/x509/a_digest.c
crypto/x509/a_sign.c
crypto/x509/a_strex.c
crypto/x509/a_verify.c
crypto/x509/algorithm.c
crypto/x509/asn1_gen.c
crypto/x509/by_dir.c
crypto/x509/by_file.c
crypto/x509/i2d_pr.c
crypto/x509/rsa_pss.c
crypto/x509/t_crl.c
crypto/x509/t_req.c
crypto/x509/t_x509.c
crypto/x509/t_x509a.c
crypto/x509/x509.c
crypto/x509/x509_att.c
crypto/x509/x509_cmp.c
crypto/x509/x509_d2.c
crypto/x509/x509_def.c
crypto/x509/x509_ext.c
crypto/x509/x509_lu.c
crypto/x509/x509_obj.c
crypto/x509/x509_r2x.c
crypto/x509/x509_req.c
crypto/x509/x509_set.c
crypto/x509/x509_trs.c
crypto/x509/x509_txt.c
crypto/x509/x509_v3.c
crypto/x509/x509_vfy.c
crypto/x509/x509_vpm.c
crypto/x509/x509cset.c
crypto/x509/x509name.c
crypto/x509/x509rset.c
crypto/x509/x509spki.c
crypto/x509/x_algor.c
crypto/x509/x_all.c
crypto/x509/x_attrib.c
crypto/x509/x_crl.c
crypto/x509/x_exten.c
crypto/x509/x_info.c
crypto/x509/x_name.c
crypto/x509/x_pkey.c
crypto/x509/x_pubkey.c
crypto/x509/x_req.c
crypto/x509/x_sig.c
crypto/x509/x_spki.c
crypto/x509/x_val.c
crypto/x509/x_x509.c
crypto/x509/x_x509a.c
crypto/x509v3/pcy_cache.c
crypto/x509v3/pcy_data.c
crypto/x509v3/pcy_lib.c
crypto/x509v3/pcy_map.c
crypto/x509v3/pcy_node.c
crypto/x509v3/pcy_tree.c
crypto/x509v3/v3_akey.c
crypto/x509v3/v3_akeya.c
crypto/x509v3/v3_alt.c
crypto/x509v3/v3_bcons.c
crypto/x509v3/v3_bitst.c
crypto/x509v3/v3_conf.c
crypto/x509v3/v3_cpols.c
crypto/x509v3/v3_crld.c
crypto/x509v3/v3_enum.c
crypto/x509v3/v3_extku.c
crypto/x509v3/v3_genn.c
crypto/x509v3/v3_ia5.c
crypto/x509v3/v3_info.c
crypto/x509v3/v3_int.c
crypto/x509v3/v3_lib.c
crypto/x509v3/v3_ncons.c
crypto/x509v3/v3_ocsp.c
crypto/x509v3/v3_pci.c
crypto/x509v3/v3_pcia.c
crypto/x509v3/v3_pcons.c
crypto/x509v3/v3_pmaps.c
crypto/x509v3/v3_prn.c
crypto/x509v3/v3_purp.c
crypto/x509v3/v3_skey.c
crypto/x509v3/v3_utl.c)

target_include_directories(CCryptoBoringSSL PUBLIC
include)

target_compile_definitions(CCryptoBoringSSL PRIVATE
$<$<PLATFORM_ID:Windows>:WIN32_LEAN_AND_MEAN>)
set_target_properties(CCryptoBoringSSL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(CCryptoBoringSSL)

set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CCryptoBoringSSL)
4 changes: 4 additions & 0 deletions Sources/CCryptoBoringSSL/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module CCryptoBoringSSL {
umbrella header "CCryptoBoringSSL.h"
export *
}
26 changes: 26 additions & 0 deletions Sources/CCryptoBoringSSLShims/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This source file is part of the SwiftCrypto open source project
#
# Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
# Licensed under Apache License v2.0
#
# See LICENSE.txt for license information
# See CONTRIBUTORS.md for the list of SwiftCrypto project authors
#
# SPDX-License-Identifier: Apache-2.0

add_library(CCryptoBoringSSLShims STATIC
shims.c)

target_include_directories(CCryptoBoringSSLShims PUBLIC
include
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>)

target_link_libraries(CCryptoBoringSSLShims PUBLIC
CCryptoBoringSSL)

set_target_properties(CCryptoBoringSSLShims PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

_install_target(CCryptoBoringSSLShims)

set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CCryptoBoringSSLShims)
Loading