diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..cd909be --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,78 @@ +name: Build +on: push +jobs: + build: + strategy: + matrix: + build_type: + - Release + - Debug + + include: + - os: ubuntu-20.04 + compiler: g++ + compiler_package: g++ + boost_version: '1.67' + + - os: ubuntu-20.04 + compiler: g++ + compiler_package: g++ + boost_version: '1.67' + + - os: ubuntu-20.04 + compiler: clang++ + compiler_package: clang + boost_version: '1.67' + + - os: ubuntu-20.04 + compiler: clang++ + compiler_package: clang + boost_version: '1.67' + + name: Build ${{ matrix.build_type }} with ${{ matrix.compiler }} and boost ${{ matrix.boost_version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update apt-get + run: sudo apt-get update + + - name: Install apt packages for dependencies + run: > + sudo apt-get install -y --no-install-recommends + ccache + cmake + libboost-atomic${{ matrix.boost_version }}-dev + libboost-context${{ matrix.boost_version }}-dev + libboost-coroutine${{ matrix.boost_version }}-dev + libboost-date-time${{ matrix.boost_version }}-dev + libboost-thread${{ matrix.boost_version }}-dev + ninja-build + ${{ matrix.compiler_package }} + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1 + with: + key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }} + max-size: 1G + + - name: Configure + run: > + cmake + -B build + -S . + -G Ninja + -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} + -D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/install + -D CMAKE_CXX_COMPILER=${{ matrix.compiler }} + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + -D RESOURCE_POOL_BUILD_TESTS=ON + -D RESOURCE_POOL_BUILD_EXAMPLES=ON + -D RESOURCE_POOL_BUILD_BENCHMARKS=ON + + - name: Build + run: cmake --build build + + - name: Install + run: cmake --install build diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index cdcaa55..851d28c 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -9,52 +9,24 @@ find_package(Boost COMPONENTS coroutine context REQUIRED) find_package(benchmark) if(NOT TARGET google_benchmark AND NOT benchmark_FOUND) - include(ExternalProject) - - set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/external) - - if(NOT GOOGLE_BENCHMARK_REPOSITORY) - if(NOT DEFINED ENV{GOOGLE_BENCHMARK_REPOSITORY}) - set(GOOGLE_BENCHMARK_REPOSITORY https://github.com/google/benchmark.git) - else() - set(GOOGLE_BENCHMARK_REPOSITORY $ENV{GOOGLE_BENCHMARK_REPOSITORY}) - endif() - endif() - - ExternalProject_Add( - google_benchmark - GIT_REPOSITORY ${GOOGLE_BENCHMARK_REPOSITORY} - TIMEOUT 1 - CONFIGURE_COMMAND cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_GTEST_TESTS=OFF ../google_benchmark - INSTALL_COMMAND "" - UPDATE_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON + set(BENCHMARK_ENABLE_TESTING OFF) + set(BENCHMARK_ENABLE_INSTALL OFF) + set(BENCHMARK_ENABLE_GTEST_TESTS OFF) + + include(FetchContent) + FetchContent_Declare(benchmark + URL https://github.com/google/benchmark/archive/refs/tags/v1.8.3.zip + URL_HASH SHA512=d73587ad9c49338749e1d117a6f8c7ff9c603a91a2ffa91a7355c7df7dea82710b9a810d34ddfef20973ecdc77092ec10fb2b4e4cc8d2e7810cbed79617b3828 + SOURCE_DIR fetched/benchmark ) - - ExternalProject_Get_Property(google_benchmark source_dir) - include_directories(SYSTEM ${source_dir}/include) - - ExternalProject_Get_Property(google_benchmark binary_dir) - link_directories(${binary_dir}/src) -endif() - -if(benchmark_FOUND) - include_directories(SYSTEM ${benchmark_INCLUDE_DIRS}) - get_filename_component(_BENCHMARK_LIB_DIR ${benchmark_LIBRARIES} PATH) - link_directories(${_BENCHMARK_LIB_DIR}) + FetchContent_MakeAvailableExcludeFromAll(benchmark) endif() add_executable(resource_pool_benchmark_async async.cc) -if(TARGET google_benchmark) - add_dependencies(resource_pool_benchmark_async google_benchmark) -endif() - set(LIBRARIES pthread - benchmark + benchmark::benchmark Boost::coroutine Boost::context elsid::resource_pool