Skip to content

Commit

Permalink
Fix Cmake for Android and Windows builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
KGronek-Pubnub committed Oct 24, 2024
1 parent dab23a6 commit 8148df9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,13 @@ if(${OPENSSL})
if(WIN32 OR WIN64 OR MSVC)
find_library(OpenSSL REQUIRED NAMES libssl PATHS ${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR} NO_DEFAULT_PATH)
find_library(Crypto REQUIRED NAMES libcrypto PATHS ${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR} NO_DEFAULT_PATH)
else()
find_library(OpenSSL REQUIRED NAMES ssl PATHS ${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR} NO_DEFAULT_PATH)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
# find_library doesn't work when building for Android architecture
set(OpenSSL "${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR}/libssl.a")
set(Crypto "${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR}/libcrypto.a")
link_libraries(${OpenSSL} ${Crypto})
else()
find_library(OpenSSL REQUIRED NAMES ssl PATHS ${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR} NO_DEFAULT_PATH)
find_library(Crypto REQUIRED NAMES crypto PATHS ${OPENSSL_ROOT_DIR}/${CUSTOM_OPENSSL_LIB_DIR} NO_DEFAULT_PATH)
endif()

Expand Down Expand Up @@ -478,9 +483,15 @@ if(${OPENSSL})
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
${FEATURE_SOURCEFILES})

set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/openssl/pbauto_heartbeat_init_posix.c
${FEATURE_SOURCEFILES})
if(UNIX)
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/posix/pbauto_heartbeat_init_posix.c
${FEATURE_SOURCEFILES})
else()
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/windows/pbauto_heartbeat_init_windows.c
${FEATURE_SOURCEFILES})
endif()

set(LDLIBS ${LDLIBS})

Expand Down Expand Up @@ -537,7 +548,7 @@ if(NOT ESP_PLATFORM)
set(LIBTYPE SHARED)
else()
message(STATUS "Building static library")
set(LIBYTPE STATIC)
set(LIBTYPE STATIC)
endif()

add_library(pubnub ${LIBTYPE} ${SOURCEFILES})
Expand Down
1 change: 0 additions & 1 deletion openssl/pbauto_heartbeat_init_posix.c

This file was deleted.

0 comments on commit 8148df9

Please sign in to comment.