Skip to content

Commit

Permalink
chore(thirdparty): find and use OpenSSL by CMake functions (apache#1679)
Browse files Browse the repository at this point in the history
Use find_package(OpenSSL REQUIRED) to find OpenSSL, and use related CMake functions
to add include directories and link libs.
  • Loading branch information
acelyc111 authored Nov 9, 2023
1 parent 5e9a2a9 commit dbd5f20
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 27 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/lint_and_test_cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ jobs:
name: macOS
needs: cpp_clang_format_linter
runs-on: macos-12
env:
OPENSSL_ROOT_DIR: /usr/local/opt/openssl
steps:
- name: Install Softwares
run: |
Expand All @@ -680,7 +678,7 @@ jobs:
run: |
export JAVA_HOME="${JAVA_HOME_8_X64}"
mkdir -p build
cmake -DCMAKE_BUILD_TYPE=Release -B build/ -DMACOS_OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} -DROCKSDB_PORTABLE=1
cmake -DCMAKE_BUILD_TYPE=Release -B build/ -DROCKSDB_PORTABLE=1
cmake --build build/ -j $(sysctl -n hw.physicalcpu)
- name: Compilation
run: |
Expand Down
11 changes: 5 additions & 6 deletions cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,15 @@ function(dsn_setup_thirdparty_libs)
message (STATUS "JAVA_JVM_LIBRARY=${JAVA_JVM_LIBRARY}")
link_libraries(${JAVA_JVM_LIBRARY})

find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
link_libraries(${OPENSSL_CRYPTO_LIBRARY})
link_libraries(${OPENSSL_SSL_LIBRARY})

link_directories(${THIRDPARTY_INSTALL_DIR}/lib)
if (NOT APPLE)
link_directories(${THIRDPARTY_INSTALL_DIR}/lib64)
endif()

if (APPLE)
include_directories(SYSTEM ${MACOS_OPENSSL_ROOT_DIR}/include)
link_directories(${MACOS_OPENSSL_ROOT_DIR}/lib)
message (STATUS "MACOS_OPENSSL_ROOT_DIR: ${MACOS_OPENSSL_ROOT_DIR}")
endif()
endfunction(dsn_setup_thirdparty_libs)

function(dsn_common_setup)
Expand Down
4 changes: 0 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ function run_build()
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_BUILD_TYPE=Release"
fi

if [ "$(uname)" == "Darwin" ]; then
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DMACOS_OPENSSL_ROOT_DIR=/usr/local/opt/openssl"
fi

if [ ! -z "${SANITIZER}" ]; then
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DSANITIZER=${SANITIZER}"
fi
Expand Down
1 change: 0 additions & 1 deletion src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ set(MY_PROJ_LIBS
PocoFoundation
PocoNetSSL
PocoJSON
crypto
hashtable
hdfs
rocksdb)
Expand Down
2 changes: 0 additions & 2 deletions src/meta/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ set(MY_PROJ_LIBS
PocoFoundation
PocoNetSSL
PocoJSON
crypto
gtest
ssl
hdfs)

set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_PROJ_LIBS dsn_http crypto rocksdb)
set(MY_PROJ_LIBS dsn_http rocksdb)

# Extra files that will be installed
set(MY_BINPLACES "")
Expand Down
2 changes: 1 addition & 1 deletion src/zookeeper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(MY_PROJ_SRC "")
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS zookeeper hashtable ssl crypto)
set(MY_PROJ_LIBS zookeeper hashtable)

# Extra files that will be installed
set(MY_BINPLACES "")
Expand Down
2 changes: 0 additions & 2 deletions src/zookeeper/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ set(MY_PROJ_LIBS
zookeeper
hashtable
gtest
ssl
crypto
rocksdb)

set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
Expand Down
9 changes: 2 additions & 7 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif ()
endif ()

if (APPLE)
if ("${MACOS_OPENSSL_ROOT_DIR}" STREQUAL "")
message(FATAL_ERROR "OpenSSL root should be set for MacOS")
endif()
endif()
find_package(OpenSSL REQUIRED)

include(ExternalProject)
include(CheckCXXCompilerFlag)
Expand Down Expand Up @@ -204,7 +200,6 @@ ExternalProject_Add(poco
https://github.com/pocoproject/poco/archive/refs/tags/poco-1.11.1-release.tar.gz
URL_MD5 a96210b60a675c4a8183ad1f2099d549
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
-DOPENSSL_ROOT_DIR=${MACOS_OPENSSL_ROOT_DIR}
-DENABLE_MONGODB=OFF
-DENABLE_PDF=OFF
-DENABLE_DATA=OFF
Expand All @@ -230,7 +225,7 @@ ExternalProject_Add(fds
URL_MD5 f7e0f86534f7b15c2a9b349f5cb45503
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_fds_for_macos.patch
CMAKE_ARGS -DPOCO_INCLUDE=${TP_OUTPUT}/include
-DMACOS_OPENSSL_INCLUDE_DIR=${MACOS_OPENSSL_ROOT_DIR}/include
-DMACOS_OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DPOCO_LIB=${TP_OUTPUT}/lib
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
Expand Down

0 comments on commit dbd5f20

Please sign in to comment.