Skip to content

Commit

Permalink
support iOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsu0413 committed Feb 11, 2024
1 parent a66c896 commit bb6926a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
22 changes: 14 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,11 @@ else()
endif()

if (OPENSSL_THREADS)
find_package(Threads REQUIRED)
if (NOT IOS)
find_package(Threads REQUIRED)
else()
add_library(Threads::Threads INTERFACE IMPORTED)
endif()
set(OPENSSL_NO_THREADS OFF CACHE BOOL "Build without threads supported (automatically set, use OPENSSL_THREADS if this is to be modified)" FORCE)
else()
set(OPENSSL_NO_THREADS ON CACHE BOOL "Build without threads supported (automatically set, use OPENSSL_THREADS if this is to be modified)" FORCE)
Expand Down Expand Up @@ -440,14 +444,16 @@ elseif (APPLE AND NOT IOS)
endif()
endif()
elseif (IOS)
if (OPENSSL_TARGET_ARCH STREQUAL "x64")
set(OPENSSL_BUILD_PLATFORM "iossimulator-xcrun")
elseif (OPENSSL_TARGET_ARCH STREQUAL "arm32")
set(OPENSSL_BUILD_PLATFORM "ios-xcrun")
elseif (OPENSSL_TARGET_ARCH STREQUAL "arm64")
set(OPENSSL_BUILD_PLATFORM "ios64-xcrun")
if (OPENSSL_OSX_ARCHITECTURES_LENGTH GREATER 1)
# set in buildinf.h.appleUnified.cmake.in
else()
set(OPENSSL_BUILD_PLATFORM "iphoneos-cross")
if (OPENSSL_TARGET_ARCH STREQUAL "arm64")
set(OPENSSL_BUILD_PLATFORM "ios64-xcrun")
elseif (OPENSSL_TARGET_ARCH STREQUAL "arm32")
set(OPENSSL_BUILD_PLATFORM "ios-xcrun")
else()
set(OPENSSL_BUILD_PLATFORM "iossimulator-xcrun")
endif()
endif()
elseif (ANDROID)
if (OPENSSL_TARGET_ARCH STREQUAL "x64")
Expand Down
1 change: 1 addition & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ target_link_libraries(openssl

install(TARGETS openssl
RUNTIME
BUNDLE DESTINATION "${CMAKE_BINARY_DIR}"
)

install(PROGRAMS CA.pl
Expand Down
4 changes: 2 additions & 2 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if (NOT HAVE_SIZEOF_LONG)
else()
if (NOT SIZEOF_LONG)
if (HAVE_SIZEOF_LONG AND SIZEOF_LONG_KEYS)
foreach (SIZE_OF_LONG_KEY IN LIST SIZEOF_LONG_KEYS)
foreach (SIZE_OF_LONG_KEY IN LISTS SIZEOF_LONG_KEYS)
if (SIZEOF_LONG EQUAL 0)
set(SIZEOF_LONG ${SIZEOF_LONG-${SIZE_OF_LONG_KEY}})
elseif (NOT SIZEOF_LONG EQUAL ${SIZEOF_LONG-${SIZE_OF_LONG_KEY}})
Expand Down Expand Up @@ -329,7 +329,7 @@ if (NOT OPENSSL_BUILD_TIMESTAMP)
set(OPENSSL_BUILD_TIMESTAMP "date not available")
endif()
set(OPENSSL_BUILDINF_H_CMAKE_IN "buildinf.h.cmake.in")
if ( APPLE AND ( NOT IOS ) AND CMAKE_OSX_ARCHITECTURES )
if ( APPLE AND CMAKE_OSX_ARCHITECTURES )
list(LENGTH CMAKE_OSX_ARCHITECTURES OPENSSL_OSX_ARCHITECTURES_LENGTH)
if (OPENSSL_OSX_ARCHITECTURES_LENGTH GREATER 1)
set(OPENSSL_BUILDINF_H_CMAKE_IN "buildinf.h.appleUnified.cmake.in")
Expand Down
17 changes: 16 additions & 1 deletion crypto/buildinf.h.appleUnified.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@ static char compiler_flags[] = {
@LIBCRYPTO_CFLAGS_SOOOOOOOOLONG@
'\0'
};

#include <TargetConditionals.h>

#if TARGET_OS_OSX
#ifdef __aarch64__
/* match future OpenSSL versions */
#define PLATFORM "platform: darwin64-arm64-cc"
#else
#define PLATFORM "platform: darwin64-x86_64-cc"
#endif
#endif /* __aarch64__ */
#elif TARGET_OS_IOS /* TARGET_OS_OSX */
#if TARGET_OS_SIMULATOR
#define PLATFORM "platform: iossimulator-xcrun"
#else
#ifdef __aarch64__
#define PLATFORM "platform: ios64-xcrun"
#else
#define PLATFORM "platform: ios-xcrun"
#endif /* __aarch64__ */
#endif /* TARGET_OS_SIMULATOR */
#endif /* TARGET_OS_IOS */
#define DATE "built on: @OPENSSL_BUILD_TIMESTAMP@"

0 comments on commit bb6926a

Please sign in to comment.