From 7c6d0cf720248fb90e9794a7c88e1a9097b30fee Mon Sep 17 00:00:00 2001 From: Sandor Dargo Date: Thu, 10 Oct 2024 14:53:41 +0200 Subject: [PATCH] Small fix --- .appveyor/build.cmd | 20 -------- .appveyor/install.cmd | 15 ------ .appveyor/test.cmd | 13 ----- .github/workflows/all.yml | 104 +++++++++++++++++++++++++++----------- CMakeLists.txt | 20 +++++--- appveyor.yml | 36 ------------- 6 files changed, 88 insertions(+), 120 deletions(-) delete mode 100644 .appveyor/build.cmd delete mode 100644 .appveyor/install.cmd delete mode 100644 .appveyor/test.cmd delete mode 100644 appveyor.yml diff --git a/.appveyor/build.cmd b/.appveyor/build.cmd deleted file mode 100644 index 90a81b02..00000000 --- a/.appveyor/build.cmd +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -if "%PLATFORM%" == "" ( - echo Platform not defined! - exit /b 1 -) - -mkdir build_%PLATFORM% -pushd build_%PLATFORM% - -if "%PLATFORM%" == "Win32" ( - cmake -G "Visual Studio 16 2019" -A Win32 .. -) else if "%PLATFORM%" == "x64" ( - cmake -G "Visual Studio 16 2019" -A x64 .. -) else ( - echo Unknown platform! - exit /b 2 -) - -popd diff --git a/.appveyor/install.cmd b/.appveyor/install.cmd deleted file mode 100644 index 5f1ac401..00000000 --- a/.appveyor/install.cmd +++ /dev/null @@ -1,15 +0,0 @@ -@echo off - -if "%PLATFORM%" == "" ( - echo Platform not defined! - exit /b 1 -) - -if "%PLATFORM%" == "Win32" ( - set BITS=32 -) else if "%PLATFORM%" == "x64" ( - set BITS=64 -) else ( - echo Unknown platform! - exit /b 2 -) diff --git a/.appveyor/test.cmd b/.appveyor/test.cmd deleted file mode 100644 index 5062ffe6..00000000 --- a/.appveyor/test.cmd +++ /dev/null @@ -1,13 +0,0 @@ -@echo off - -if "%PLATFORM%" == "" ( - echo Platform not defined! - exit /b 1 -) - -if "%CONFIGURATION%" == "" ( - echo Configuration not defined! - exit /b 2 -) - -build_%PLATFORM%\test\%CONFIGURATION%\spotify_json_test.exe diff --git a/.github/workflows/all.yml b/.github/workflows/all.yml index e68c2317..472f6f54 100644 --- a/.github/workflows/all.yml +++ b/.github/workflows/all.yml @@ -13,13 +13,6 @@ jobs: strategy: # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. fail-fast: false - - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - # - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: os: [ubuntu-latest, windows-latest, macos-latest] build_type: [Release, Debug] @@ -31,33 +24,30 @@ jobs: if: matrix.os == 'ubuntu-latest' id: boost shell: bash - run: | - DEPS_DIR="${{ github.workspace }}/deps" - BOOST_LIBRARIES="chrono,system,test" - BOOST_VERSION="1.70.0" - BOOST_URL="https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION//\./_}.tar.gz" - BOOST_DIR="${DEPS_DIR}/boost" - echo "Downloading Boost ${BOOST_VERSION} from ${BOOST_URL}" - mkdir -p ${BOOST_DIR} && cd ${BOOST_DIR} - wget -O - ${BOOST_URL} | tar --strip-components=1 -xz -C ${BOOST_DIR} || exit 1 - ./bootstrap.sh --with-libraries=${BOOST_LIBRARIES} && ./b2 - export BOOST_ROOT=${BOOST_DIR} - echo "boost-root-dir=$BOOST_ROOT" >> "$GITHUB_OUTPUT" + run: sudo apt-get install libboost-all-dev - name: Install Boost (MacOs) if: matrix.os == 'macos-latest' id: boost-macos shell: bash - run: | + run: | brew install boost export BOOST_ROOT=$(brew --prefix boost) echo "boost-root-dir=$BOOST_ROOT" >> "$GITHUB_OUTPUT" - - name: Verify Boost (MacOs) - if: matrix.os == 'macos-latest' - shell: bash - run: | - ls /opt/homebrew/opt/boost/lib + - name: Install vcpkg + if: matrix.os == 'windows-latest' + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + git checkout master # Use a specific version if needed + ./bootstrap-vcpkg.bat + + - name: Install Boost (Windows) + if: matrix.os == 'windows-latest' + run: | + cd vcpkg + .\vcpkg.exe install boost-algorithm boost-assert boost-test boost-system boost-chrono boost-container --triplet x64-windows - name: Set build directory id: strings @@ -68,20 +58,74 @@ jobs: - name: Configure CMake (Linux) if: matrix.os == 'ubuntu-latest' run: > - export BOOST_ROOT="${{ steps.boost.outputs.boost-root-dir }}" && echo "$BOOST_ROOT" && cmake -B ${{ steps.strings.outputs.build-output-dir }} + cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_PREFIX_PATH="${{ steps.boost.outputs.boost-root-dir }}" + -DBOOST_ROOT="${{ steps.boost.outputs.boost-root-dir }}" + -DBoost_DIR="${{ steps.boost.outputs.boost-root-dir }}" + -DBoost_NO_BOOST_CMAKE=ON + -DBoost_NO_SYSTEM_PATHS=ON + -DBoost_USE_STATIC_LIBS=OFF + -DBoost_USE_STATIC_RUNTIME=OFF + -DSPOTIFY_JSON_USE_SSE42=OFF + -S ${{ github.workspace }} + + - name: Configure CMake (Windows) + if: matrix.os == 'windows-latest' + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake + -DBOOST_ROOT="./vcpkg/installed/x64-windows" + -DBoost_NO_SYSTEM_PATHS=ON + -DBoost_LIBRARY_DIRS="${{ github.workspace }}\vcpkg\installed\x64-windows\lib" + -DBoost_INCLUDE_DIR="${{ github.workspace }}\vcpkg\installed\x64-windows\include" + -DBoost_USE_STATIC_LIBS=OFF + -DSPOTIFY_JSON_USE_SSE42=OFF -S ${{ github.workspace }} - name: Configure CMake (MacOs) if: matrix.os == 'macos-latest' run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_PREFIX_PATH="/opt/homebrew/opt/boost" -DBoost_ROOT="/opt/homebrew/opt/boost" -DBOOST_LIBRARYDIR="/opt/homebrew/opt/boost/lib" + -DCMAKE_PREFIX_PATH="/opt/homebrew/opt/boost" + -DBOOST_ROOT="/opt/homebrew/opt/boost" + -DBoost_NO_BOOST_CMAKE=ON + -DBOOST_LIBRARYDIR="/opt/homebrew/opt/boost/lib" + -DBoost_USE_STATIC_LIBS=OFF + -DBoost_USE_STATIC_RUNTIME=OFF -S ${{ github.workspace }} - + - name: Build run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - - name: Test + - name: Test (Linux / MacOS) + if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' working-directory: ${{ steps.strings.outputs.build-output-dir }} - run: ctest --build-config ${{ matrix.build_type }} + run: ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure + + - name: Test (Windows Relese) + if: matrix.os == 'windows-latest' && matrix.build_type == 'Release' + working-directory: ${{ steps.strings.outputs.build-output-dir }} + shell: pwsh + run: | + $env:PATH += ";${{ github.workspace }}\vcpkg\installed\x64-windows\bin" + ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure -V + + - name: Test (Windows Debug) + if: matrix.os == 'windows-latest' && matrix.build_type == 'Debug' + working-directory: ${{ steps.strings.outputs.build-output-dir }} + shell: pwsh + run: | + $env:PATH += ";${{ github.workspace }}\vcpkg\installed\x64-windows\debug\bin" + ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure --parallel 4 -V + + - name: Install valgrind (Linux) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: sudo apt-get install -qq valgrind + + - name: Run valgrind test (Linux) + if: matrix.os == 'ubuntu-latest' + working-directory: ${{ steps.strings.outputs.build-output-dir }} + shell: bash + run: valgrind --leak-check=full ./test/spotify_json_test diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aa2c99d..cc1103ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,19 @@ # License for the specific language governing permissions and limitations under # the License. -cmake_minimum_required(VERSION 3.15.0) +cmake_minimum_required(VERSION 3.21.0) project(spotify-json) +# Set policy for CMP0144 to enable upper-case BOOST_ROOT usage +if (POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif() + +# Set policy for CMP0167 to rely on BoostConfig.cmake rather than FindBoost +if (POLICY CMP0167) + cmake_policy(SET CMP0167 NEW) +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -139,7 +149,9 @@ if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL " endif() if(WIN32) - target_compile_options(${json_library_TARGET} PRIVATE "/MT$<$:d>") + message(STATUS "Building on Windows") + # target_compile_options(${json_library_TARGET} PRIVATE "/MT$<$:d>") + target_compile_options(${json_library_TARGET} PRIVATE "/MT$<$:d> /O2") endif() option(SPOTIFY_JSON_USE_SSE42 "Build library with SSE 4.2 support (on x86 and x86-64 platforms)" ON) @@ -174,10 +186,6 @@ target_link_libraries(${json_library_TARGET} double-conversion) option(SPOTIFY_JSON_BUILD_TESTS "Build tests and benchmarks" ON) if(SPOTIFY_JSON_BUILD_TESTS) - set(Boost_USE_MULTITHREADED ON) - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_STATIC_RUNTIME ON) - find_package(Boost COMPONENTS chrono unit_test_framework system) if(Boost_FOUND) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a592677f..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: '1.0.0-{build}' - -branches: - only: - - master - -cache: - - '%LocalAppData%\NuGet\Cache' - -platform: - - Win32 - - x64 - -configuration: - - Debug - - Release - -matrix: - fast_finish: true - -image: Visual Studio 2019 - -environment: - BOOST_ROOT: C:\Libraries\boost_1_71_0 - -install: - - cmd: .appveyor\install.cmd - -before_build: - - cmd: .appveyor\build.cmd - -build: - project: build_%PLATFORM%\spotify-json.sln - -after_build: - - cmd: .appveyor\test.cmd