From f5bd346573aacba601c948038e39aed24c8c069e Mon Sep 17 00:00:00 2001 From: Jaquee Date: Sun, 2 Apr 2017 12:19:25 +0200 Subject: [PATCH] IOS CMAKE build settings --- CMakeLists.txt | 16 ++++++++++------ external/CMakeLists.txt | 7 ++++--- external/unbound/CMakeLists.txt | 7 ++++++- src/CMakeLists.txt | 24 +++++++++++++++--------- src/crypto/CMakeLists.txt | 2 +- src/wallet/CMakeLists.txt | 7 ++++++- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b25e5c..f4deff59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,9 @@ # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +if (IOS) + INCLUDE(CmakeLists_IOS.txt) +endif() cmake_minimum_required(VERSION 2.8.7) @@ -77,7 +80,7 @@ if (ARM_TEST STREQUAL "arm") endif() endif() -if (ARM_ID STREQUAL "aarch64") +if (ARM_ID STREQUAL "aarch64" OR ARM_ID STREQUAL "arm64") set(ARM 1) set(ARM8 1) endif() @@ -312,7 +315,7 @@ else() endif() # Handle OpenSSL, used for sha256sum on binary updates -if (APPLE) +if (APPLE AND NOT IOS) if (NOT OpenSSL_DIR) EXECUTE_PROCESS(COMMAND brew --prefix openssl OUTPUT_VARIABLE OPENSSL_ROOT_DIR @@ -322,7 +325,7 @@ if (APPLE) endif() find_package(OpenSSL REQUIRED) -if(STATIC) +if(STATIC AND NOT IOS) if(UNIX) set(OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES};${CMAKE_DL_LIBS}") endif() @@ -337,7 +340,7 @@ endif() add_subdirectory(external) # Final setup for miniupnpc -if(UPNP_STATIC) +if(UPNP_STATIC OR IOS) add_definitions("-DUPNP_STATIC") else() add_definitions("-DUPNP_DYNAMIC") @@ -540,8 +543,9 @@ else() endif(ARM) - if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON") + if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS) #From Android 5: "only position independent executables (PIE) are supported" + message(STATUS "Enabling PIE executable") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie") @@ -650,7 +654,7 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) if(ANDROID) set(ATOMIC libatomic.a) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32") +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32" AND NOT IOS) find_library(ATOMIC atomic) list(APPEND EXTRA_LIBRARIES ${ATOMIC}) endif() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 3c0c0d68..7dbb5547 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -34,11 +34,12 @@ # We always compile if we are building statically to reduce static dependency issues... # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # others. - -find_package(Miniupnpc QUIET) +if(NOT IOS) + find_package(Miniupnpc QUIET) +endif() # If we have the correct shared version and we're not building static, use it -if(STATIC) +if(STATIC OR IOS) set(USE_SHARED_MINIUPNPC false) elseif(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER) set(USE_SHARED_MINIUPNPC true) diff --git a/external/unbound/CMakeLists.txt b/external/unbound/CMakeLists.txt index d27997ea..94294013 100644 --- a/external/unbound/CMakeLists.txt +++ b/external/unbound/CMakeLists.txt @@ -215,6 +215,11 @@ endif () if (INSTALL_VENDORED_LIBUNBOUND) + if(IOS) + set(lib_folder lib-${ARCH}) + else() + set(lib_folder lib) + endif() install(TARGETS unbound - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION ${lib_folder}) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7cf03db7..d83242a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,18 +101,24 @@ add_subdirectory(crypto) add_subdirectory(ringct) add_subdirectory(cryptonote_basic) add_subdirectory(cryptonote_core) -add_subdirectory(blockchain_db) +if(NOT IOS) + add_subdirectory(blockchain_db) +endif() add_subdirectory(mnemonics) -add_subdirectory(rpc) +if(NOT IOS) + add_subdirectory(rpc) +endif() add_subdirectory(wallet) -add_subdirectory(p2p) +if(NOT IOS) + add_subdirectory(p2p) +endif() add_subdirectory(cryptonote_protocol) - -add_subdirectory(simplewallet) -add_subdirectory(daemonizer) -add_subdirectory(daemon) - -add_subdirectory(blockchain_utilities) +if(NOT IOS) + add_subdirectory(simplewallet) + add_subdirectory(daemonizer) + add_subdirectory(daemon) + add_subdirectory(blockchain_utilities) +endif() if(PER_BLOCK_CHECKPOINT) add_subdirectory(blocks) diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index c047b004..277ee64c 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -93,7 +93,7 @@ endif() # Because of the way Qt works on android with JNI, the code does not live in the main android thread # So this code runs with a 1 MB default stack size. # This will force the use of the heap for the allocation of the scratchpad -if (ANDROID) +if (ANDROID OR IOS) if( BUILD_GUI_DEPS ) add_definitions(-DFORCE_USE_HEAP=1) endif() diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index aed021b9..2e7610b6 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -132,8 +132,13 @@ if (BUILD_GUI_DEPS) list(APPEND objlibs $) # matches naming convention in src/CMakeLists.txt endforeach() add_library(wallet_merged STATIC ${objlibs}) + if(IOS) + set(lib_folder lib-${ARCH}) + else() + set(lib_folder lib) + endif() install(TARGETS wallet_merged - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION ${lib_folder}) install(FILES ${wallet_api_headers} DESTINATION include/wallet)