From f50a03ba1eb32524db702a3b72b44909e6c76295 Mon Sep 17 00:00:00 2001 From: badaix Date: Mon, 3 Jun 2024 22:30:43 +0200 Subject: [PATCH] Add OpenSSL include dir --- .github/workflows/ci.yml | 74 +++++++++++++++++++++------------------- common/CMakeLists.txt | 4 +++ common/base64.cpp | 10 +++--- common/base64.h | 4 +-- test/CMakeLists.txt | 2 +- 5 files changed, 50 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3131aeab..ccd31dfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,42 +234,44 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: print environment - run: env - - name: dependencies - run: brew install pkgconfig libsoxr flac libvorbis opus ccache expat - - name: cache boost - id: cache-boost - uses: actions/cache@v4 - with: - path: boost_${{ env.BOOST_VERSION }} - key: boost-${{ env.BOOST_VERSION }} - enableCrossOsArchive: true - - name: get boost - if: steps.cache-boost.outputs.cache-hit != 'true' - run: | - wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2 - tar xjf boost_${BOOST_VERSION}.tar.bz2 - - name: cache ccache - id: cache-ccache - uses: actions/cache@v4 - with: - path: /Users/runner/Library/Caches/ccache - key: ${{ runner.os }}-${{ matrix.xcode }}-ccache-${{ github.sha }} - restore-keys: ${{ runner.os }}-${{ matrix.xcode }}-ccache- - - name: configure - run: | - cmake -S . -B build \ - -DWERROR=ON -DBUILD_TESTS=ON \ - -DBOOST_ROOT=boost_${BOOST_VERSION} \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_FLAGS="-I/usr/local/include -DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14" - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer - - name: build - run: cmake --build build --parallel 3 --verbose + - uses: actions/checkout@v4 + - name: print environment + run: env + - name: dependencies + run: | + brew update + brew install pkgconfig libsoxr flac libvorbis opus ccache expat + - name: cache boost + id: cache-boost + uses: actions/cache@v4 + with: + path: boost_${{ env.BOOST_VERSION }} + key: boost-${{ env.BOOST_VERSION }} + enableCrossOsArchive: true + - name: get boost + if: steps.cache-boost.outputs.cache-hit != 'true' + run: | + wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2 + tar xjf boost_${BOOST_VERSION}.tar.bz2 + - name: cache ccache + id: cache-ccache + uses: actions/cache@v4 + with: + path: /Users/runner/Library/Caches/ccache + key: ${{ runner.os }}-${{ matrix.xcode }}-ccache-${{ github.sha }} + restore-keys: ${{ runner.os }}-${{ matrix.xcode }}-ccache- + - name: configure + run: | + cmake -S . -B build \ + -DWERROR=ON -DBUILD_TESTS=ON \ + -DBOOST_ROOT=boost_${BOOST_VERSION} \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_FLAGS="-I/usr/local/include -DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14" + env: + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer + - name: build + run: cmake --build build --parallel 3 --verbose windows: diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ff1012b7..51d90bbf 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -4,6 +4,8 @@ if(NOT WIN32 AND NOT ANDROID) list(APPEND SOURCES daemon.cpp) endif() +include_directories(${SOXR_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) + if(SOXR_FOUND) include_directories(${SOXR_INCLUDE_DIRS}) endif(SOXR_FOUND) @@ -15,3 +17,5 @@ if(ANDROID) elseif(SOXR_FOUND) target_link_libraries(common ${SOXR_LIBRARIES}) endif() + +target_link_libraries(common OpenSSL::Crypto OpenSSL::SSL) diff --git a/common/base64.cpp b/common/base64.cpp index 0c84c96f..302d3027 100644 --- a/common/base64.cpp +++ b/common/base64.cpp @@ -39,7 +39,7 @@ static inline bool is_base64(unsigned char c) return ((isalnum(c) != 0) || (c == '+') || (c == '/')); } -std::string base64_encode(const unsigned char* bytes_to_encode, unsigned int in_len) +std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len) { std::string ret; int i = 0; @@ -90,7 +90,7 @@ std::string base64_encode(const std::string& text) std::string base64_decode(const std::string& encoded_string) { - int in_len = encoded_string.size(); + size_t in_len = encoded_string.size(); int i = 0; int in_ = 0; unsigned char char_array_4[4], char_array_3[3]; @@ -103,7 +103,7 @@ std::string base64_decode(const std::string& encoded_string) if (i == 4) { for (i = 0; i < 4; i++) - char_array_4[i] = base64_chars.find(char_array_4[i]); + char_array_4[i] = static_cast(base64_chars.find(char_array_4[i])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); @@ -122,7 +122,7 @@ std::string base64_decode(const std::string& encoded_string) char_array_4[j] = 0; for (j = 0; j < 4; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]); + char_array_4[j] = static_cast(base64_chars.find(char_array_4[j])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); @@ -136,7 +136,7 @@ std::string base64_decode(const std::string& encoded_string) } -std::string base64url_encode(const unsigned char* bytes_to_encode, unsigned int in_len) +std::string base64url_encode(const unsigned char* bytes_to_encode, size_t in_len) { std::string res = base64_encode(bytes_to_encode, in_len); std::replace(res.begin(), res.end(), '+', '-'); diff --git a/common/base64.h b/common/base64.h index b987c657..62889332 100644 --- a/common/base64.h +++ b/common/base64.h @@ -20,10 +20,10 @@ #include -std::string base64_encode(const unsigned char* bytes_to_encode, unsigned int in_len); +std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len); std::string base64_encode(const std::string& text); std::string base64_decode(const std::string& encoded_string); -std::string base64url_encode(const unsigned char* bytes_to_encode, unsigned int in_len); +std::string base64url_encode(const unsigned char* bytes_to_encode, size_t in_len); std::string base64url_encode(const std::string& text); std::string base64url_decode(const std::string& encoded_string); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 02896476..bd6c2342 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,7 @@ set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_library(Catch INTERFACE) target_include_directories( - Catch INTERFACE ${CATCH_INCLUDE_DIR} ${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIR}) + Catch INTERFACE ${CATCH_INCLUDE_DIR} ${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}) set(TEST_LIBRARIES Catch) if(ANDROID)