From 9b65711288d33ef9e64338eb20b6337208c3b0f6 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 9 Nov 2023 13:26:18 +0800 Subject: [PATCH 1/5] chore(thirdparty): find and uss openssl antomatically --- .github/workflows/lint_and_test_cpp.yaml | 4 +--- cmake_modules/BaseFunctions.cmake | 6 ------ run.sh | 4 ---- thirdparty/CMakeLists.txt | 9 ++------- 4 files changed, 3 insertions(+), 20 deletions(-) diff --git a/.github/workflows/lint_and_test_cpp.yaml b/.github/workflows/lint_and_test_cpp.yaml index f3dc28d389..1f5af4ee2d 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 0147b50298..fd2c0acb3d 100644 --- a/cmake_modules/BaseFunctions.cmake +++ b/cmake_modules/BaseFunctions.cmake @@ -352,12 +352,6 @@ function(dsn_setup_thirdparty_libs) 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 2672094f7c..ab5e9852df 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/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index f005f321aa..bbced3c39f 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} From 217dda8616ba595ca3ae95e4ea04a016a3d3db32 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 9 Nov 2023 14:14:18 +0800 Subject: [PATCH 2/5] fix build pegasus include openssl failed --- cmake_modules/BaseFunctions.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake_modules/BaseFunctions.cmake b/cmake_modules/BaseFunctions.cmake index fd2c0acb3d..3753866706 100644 --- a/cmake_modules/BaseFunctions.cmake +++ b/cmake_modules/BaseFunctions.cmake @@ -348,6 +348,9 @@ 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_directories(${THIRDPARTY_INSTALL_DIR}/lib) if (NOT APPLE) link_directories(${THIRDPARTY_INSTALL_DIR}/lib64) From 242b62bbc24022b446623f50e8f187e272a43689 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 9 Nov 2023 15:01:34 +0800 Subject: [PATCH 3/5] add link fir --- cmake_modules/BaseFunctions.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake_modules/BaseFunctions.cmake b/cmake_modules/BaseFunctions.cmake index 3753866706..22220a6e4f 100644 --- a/cmake_modules/BaseFunctions.cmake +++ b/cmake_modules/BaseFunctions.cmake @@ -350,6 +350,7 @@ function(dsn_setup_thirdparty_libs) find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) + link_libraries(${OPENSSL_CRYPTO_LIBRARY}) link_directories(${THIRDPARTY_INSTALL_DIR}/lib) if (NOT APPLE) From fd902457932fc256fc7d60d60a03aca93c7ff297 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 9 Nov 2023 18:09:42 +0800 Subject: [PATCH 4/5] fix link crypto --- src/meta/CMakeLists.txt | 1 - src/meta/test/CMakeLists.txt | 1 - src/utils/CMakeLists.txt | 2 +- src/zookeeper/CMakeLists.txt | 2 +- src/zookeeper/test/CMakeLists.txt | 1 - 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/meta/CMakeLists.txt b/src/meta/CMakeLists.txt index def16ec26c..9a8b2c44b0 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 16c4ff4836..2139dc3845 100644 --- a/src/meta/test/CMakeLists.txt +++ b/src/meta/test/CMakeLists.txt @@ -57,7 +57,6 @@ set(MY_PROJ_LIBS PocoFoundation PocoNetSSL PocoJSON - crypto gtest ssl hdfs) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 1127a868ef..c3cbc3db88 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 5e39d70ef0..ecf1953815 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 ssl) # Extra files that will be installed set(MY_BINPLACES "") diff --git a/src/zookeeper/test/CMakeLists.txt b/src/zookeeper/test/CMakeLists.txt index 6179f8d1ec..d05637bb74 100644 --- a/src/zookeeper/test/CMakeLists.txt +++ b/src/zookeeper/test/CMakeLists.txt @@ -40,7 +40,6 @@ set(MY_PROJ_LIBS hashtable gtest ssl - crypto rocksdb) set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) From 17d5a136a0ff9bc026fae0d6b18cbba15d7f24da Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 9 Nov 2023 19:26:07 +0800 Subject: [PATCH 5/5] fix link ssl --- cmake_modules/BaseFunctions.cmake | 1 + src/meta/test/CMakeLists.txt | 1 - src/zookeeper/CMakeLists.txt | 2 +- src/zookeeper/test/CMakeLists.txt | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake_modules/BaseFunctions.cmake b/cmake_modules/BaseFunctions.cmake index 22220a6e4f..ad4133e0bc 100644 --- a/cmake_modules/BaseFunctions.cmake +++ b/cmake_modules/BaseFunctions.cmake @@ -351,6 +351,7 @@ function(dsn_setup_thirdparty_libs) 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) diff --git a/src/meta/test/CMakeLists.txt b/src/meta/test/CMakeLists.txt index 2139dc3845..108c111298 100644 --- a/src/meta/test/CMakeLists.txt +++ b/src/meta/test/CMakeLists.txt @@ -58,7 +58,6 @@ set(MY_PROJ_LIBS PocoNetSSL PocoJSON gtest - ssl hdfs) set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) diff --git a/src/zookeeper/CMakeLists.txt b/src/zookeeper/CMakeLists.txt index ecf1953815..c6d99a55d9 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) +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 d05637bb74..5a06fa6933 100644 --- a/src/zookeeper/test/CMakeLists.txt +++ b/src/zookeeper/test/CMakeLists.txt @@ -39,7 +39,6 @@ set(MY_PROJ_LIBS zookeeper hashtable gtest - ssl rocksdb) set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)