This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new dbd5f202e chore(thirdparty): find and use OpenSSL by CMake functions 
(#1679)
dbd5f202e is described below

commit dbd5f202e86c11464d9742b406b5ff17d52d0ed4
Author: Yingchun Lai <[email protected]>
AuthorDate: Thu Nov 9 21:07:55 2023 +0800

    chore(thirdparty): find and use OpenSSL by CMake functions (#1679)
    
    Use find_package(OpenSSL REQUIRED) to find OpenSSL, and use related CMake 
functions
    to add include directories and link libs.
---
 .github/workflows/lint_and_test_cpp.yaml |  4 +---
 cmake_modules/BaseFunctions.cmake        | 11 +++++------
 run.sh                                   |  4 ----
 src/meta/CMakeLists.txt                  |  1 -
 src/meta/test/CMakeLists.txt             |  2 --
 src/utils/CMakeLists.txt                 |  2 +-
 src/zookeeper/CMakeLists.txt             |  2 +-
 src/zookeeper/test/CMakeLists.txt        |  2 --
 thirdparty/CMakeLists.txt                |  9 ++-------
 9 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/lint_and_test_cpp.yaml 
b/.github/workflows/lint_and_test_cpp.yaml
index f3dc28d38..1f5af4ee2 100644
--- a/.github/workflows/lint_and_test_cpp.yaml
+++ b/.github/workflows/lint_and_test_cpp.yaml
@@ -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: |
@@ -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: |
diff --git a/cmake_modules/BaseFunctions.cmake 
b/cmake_modules/BaseFunctions.cmake
index 0147b5029..ad4133e0b 100644
--- a/cmake_modules/BaseFunctions.cmake
+++ b/cmake_modules/BaseFunctions.cmake
@@ -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)
diff --git a/run.sh b/run.sh
index 2672094f7..ab5e9852d 100755
--- a/run.sh
+++ b/run.sh
@@ -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
diff --git a/src/meta/CMakeLists.txt b/src/meta/CMakeLists.txt
index def16ec26..9a8b2c44b 100644
--- a/src/meta/CMakeLists.txt
+++ b/src/meta/CMakeLists.txt
@@ -51,7 +51,6 @@ set(MY_PROJ_LIBS
     PocoFoundation
     PocoNetSSL
     PocoJSON
-    crypto
     hashtable
     hdfs
     rocksdb)
diff --git a/src/meta/test/CMakeLists.txt b/src/meta/test/CMakeLists.txt
index 16c4ff483..108c11129 100644
--- a/src/meta/test/CMakeLists.txt
+++ b/src/meta/test/CMakeLists.txt
@@ -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)
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index 1127a868e..c3cbc3db8 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -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 "")
diff --git a/src/zookeeper/CMakeLists.txt b/src/zookeeper/CMakeLists.txt
index 5e39d70ef..c6d99a55d 100644
--- a/src/zookeeper/CMakeLists.txt
+++ b/src/zookeeper/CMakeLists.txt
@@ -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 "")
diff --git a/src/zookeeper/test/CMakeLists.txt 
b/src/zookeeper/test/CMakeLists.txt
index 6179f8d1e..5a06fa693 100644
--- a/src/zookeeper/test/CMakeLists.txt
+++ b/src/zookeeper/test/CMakeLists.txt
@@ -39,8 +39,6 @@ set(MY_PROJ_LIBS
     zookeeper
     hashtable
     gtest
-    ssl
-    crypto
     rocksdb)
 
 set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 4f00ccbf4..a47a357fb 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -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)
@@ -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
@@ -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}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to