Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 13 additions & 34 deletions .github/workflows/cmake-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,27 @@ on:

jobs:
build:
name: CMake on ${{ matrix.os }} with ${{ matrix.dependencies }}
name: CMake on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-14, ubuntu-22.04, windows-2022]
dependencies: [submodule, vcpkg]
steps:
- name: Checkout source
uses: actions/checkout@v7
with:
submodules: ${{ matrix.dependencies == 'submodule' }}

- name: Mount vcpkg cache
if: matrix.dependencies == 'vcpkg'
uses: actions/cache@v5
with:
path: "~/.cache/vcpkg/archives"
key: vcpkg-${{ matrix.os }}

- name: Default to x64-windows vcpkg triplet
if: matrix.dependencies == 'vcpkg' && runner.os == 'Windows'
if: runner.os == 'Windows'
run: echo "VCPKG_DEFAULT_TRIPLET=x64-windows" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append

- name: Install vcpkg dependencies
if: matrix.dependencies == 'vcpkg'
run: vcpkg install benchmark civetweb curl[core] gtest zlib

- name: Generate German locale on Ubuntu
Expand All @@ -54,20 +49,12 @@ jobs:
if: runner.os == 'macOS'
run: brew install ninja

- name: "Configure for Unix with internal dependencies"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }} -B ${{ github.workspace }}/_build -DBUILD_SHARED_LIBS=ON

- name: "Configure for Windows with internal dependencies"
if: matrix.dependencies == 'submodule' && runner.os == 'Windows'
run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -S ${{ github.workspace }} -B ${{ github.workspace }}/_build -DBUILD_SHARED_LIBS=ON

- name: "Configure for Unix with vcpkg dependencies"
if: matrix.dependencies == 'vcpkg' && runner.os != 'Windows'
if: runner.os != 'Windows'
run: cmake -DUSE_THIRDPARTY_LIBRARIES=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_DEBUG_POSTFIX=_d -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }} -B ${{ github.workspace }}/_build

- name: "Configure for Windows with vcpkg dependencies"
if: matrix.dependencies == 'vcpkg' && runner.os == 'Windows'
if: runner.os == 'Windows'
run: cmake -DUSE_THIRDPARTY_LIBRARIES=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install "-DCMAKE_TOOLCHAIN_FILE=${Env:VCPKG_INSTALLATION_ROOT}\scripts\buildsystems\vcpkg.cmake" -DCMAKE_DEBUG_POSTFIX=_d -S ${{ github.workspace }} -B ${{ github.workspace }}/_build

- name: "Build Debug"
Expand All @@ -94,20 +81,12 @@ jobs:
- name: "Install Release"
run: cmake --install ${{ github.workspace }}/_build --config Release

- name: "Configure CMake import for Unix with internal dependencies"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake

- name: "Configure CMake import for Windows with internal dependencies"
if: matrix.dependencies == 'submodule' && runner.os == 'Windows'
run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake

- name: "Configure CMake import for Unix with vcpkg dependencies"
if: matrix.dependencies == 'vcpkg' && runner.os != 'Windows'
if: runner.os != 'Windows'
run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_CONFIGURATION_TYPES='Release;Debug' -G"Ninja Multi-Config" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake

- name: "Configure CMake import for Windows with vcpkg dependencies"
if: matrix.dependencies == 'vcpkg' && runner.os == 'Windows'
if: runner.os == 'Windows'
run: cmake -Dprometheus-cpp_DIR=${{ github.workspace }}/_install/lib/cmake/prometheus-cpp "-DCMAKE_TOOLCHAIN_FILE=${Env:VCPKG_INSTALLATION_ROOT}\scripts\buildsystems\vcpkg.cmake" -S ${{ github.workspace }}/cmake/project-import-cmake -B ${{ github.workspace }}/_import_cmake

- name: "Build CMake import Debug"
Expand All @@ -117,21 +96,21 @@ jobs:
run: cmake --build ${{ github.workspace }}/_import_cmake --config Release

- name: "Configure for Unix Shared Libs with internal dependencies"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
run: cmake -DUSE_THIRDPARTY_LIBRARIES=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install_shared -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -GNinja -S ${{ github.workspace }} -B ${{ github.workspace }}/_build_shared
if: runner.os != 'Windows'
run: cmake "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/_install_shared -DENABLE_WARNINGS_AS_ERRORS=ON -DENABLE_COMPRESSION=OFF -DENABLE_PUSH=OFF -DCMAKE_DEBUG_POSTFIX=_d -GNinja -S ${{ github.workspace }} -B ${{ github.workspace }}/_build_shared

- name: "Build for Unix Shared Libs"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
if: runner.os != 'Windows'
run: cmake --build ${{ github.workspace }}/_build_shared

- name: "Install for Unix Shared Libs"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
if: runner.os != 'Windows'
run: cmake --install ${{ github.workspace }}/_build_shared

- name: "Configure pkg-config import for Unix"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
run: cmake -DCMAKE_PREFIX_PATH=${{ github.workspace }}/_install_shared -GNinja -S ${{ github.workspace }}/cmake/project-import-pkgconfig -B ${{ github.workspace }}/_import_pkgconfig
if: runner.os != 'Windows'
run: cmake "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_PREFIX_PATH=${{ github.workspace }}/_install_shared -GNinja -S ${{ github.workspace }}/cmake/project-import-pkgconfig -B ${{ github.workspace }}/_import_pkgconfig

- name: "Build pkg-config import for Unix"
if: matrix.dependencies == 'submodule' && runner.os != 'Windows'
if: runner.os != 'Windows'
run: cmake --build ${{ github.workspace }}/_import_pkgconfig
4 changes: 1 addition & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ jobs:
- name: Install dependencies
run: |
apt-get update
apt-get install -y --no-install-recommends ca-certificates clang-19 cmake git iwyu libbenchmark-dev libcurl4-openssl-dev ninja-build zlib1g-dev
apt-get install -y --no-install-recommends ca-certificates clang-19 cmake git iwyu libbenchmark-dev libcivetweb-dev libcurl4-openssl-dev ninja-build zlib1g-dev

- name: Checkout source
uses: actions/checkout@v7
with:
submodules: true

- name: "CMake Configure"
run: cmake -GNinja -DRUN_IWYU=ON -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -S ${GITHUB_WORKSPACE} -B ${GITHUB_WORKSPACE}/_build
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/release.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion 3rdparty/civetweb
Submodule civetweb deleted from d7ba35
1 change: 0 additions & 1 deletion 3rdparty/googletest
Submodule googletest deleted from 063de7
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ option(ENABLE_PULL "Build prometheus-cpp pull library" ON)
option(ENABLE_PUSH "Build prometheus-cpp push library" ON)
option(ENABLE_COMPRESSION "Enable gzip compression" ON)
option(ENABLE_TESTING "Build tests" ON)
option(USE_THIRDPARTY_LIBRARIES "Use 3rdParty submodules" ON)
option(THIRDPARTY_CIVETWEB_WITH_SSL "Enable SSL support for embedded civetweb source code")
option(OVERRIDE_CXX_STANDARD_FLAGS "Force building with -std=c++17 even if the CXXFLAGS are configured differently" ON)
option(GENERATE_PKGCONFIG "Generate and install pkg-config files" ${UNIX})
option(RUN_IWYU "Run include-what-you-use" OFF)
Expand Down Expand Up @@ -82,11 +80,7 @@ endif()
include(CheckAtomic)

if(ENABLE_TESTING)
if(USE_THIRDPARTY_LIBRARIES)
find_package(googlemock-3rdparty CONFIG REQUIRED)
else()
find_package(GTest 1.8.1 CONFIG REQUIRED)
endif()
find_package(GTest 1.8.1 CONFIG REQUIRED)
find_package(benchmark CONFIG)
enable_testing()
endif()
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,21 @@ the [GitHub Workflows](.github/workflows) might help.

### With CMake

For CMake builds don't forget to fetch the submodules first. Please note that
[zlib](https://zlib.net/) and [libcurl](https://curl.se/) are not provided by
the included submodules. In the example below their usage is disabled.
`prometheus-cpp` does not vendor its dependencies. It expects the following
libraries to already be installed and discoverable via `find_package()`:

Then build as usual.
- [civetweb](https://github.com/civetweb/civetweb)
- [googletest](https://github.com/google/googletest) (optional, needed for `ENABLE_TESTING`)
- [benchmark](https://github.com/google/benchmark) (optional, needed for benchmarks)
- [zlib](https://zlib.net/) (optional, needed for `ENABLE_COMPRESSION`)
- [libcurl](https://curl.se/) (optional, needed for `ENABLE_PUSH`)

``` shell
# fetch third-party dependencies
git submodule init
git submodule update
Use whichever package manager you prefer to provide them, e.g.
[vcpkg](#vcpkg), [Conan](#conan), your system's package manager, or a
manually installed copy. In the example below push support and compression
are disabled to keep the dependency list minimal.

``` shell
mkdir _build
cd _build

Expand Down Expand Up @@ -155,9 +159,6 @@ configuration options.
To generate a Debian package you could follow these steps:

``` shell
# fetch third-party dependencies
git submodule update --init

# run cmake
cmake -B_build -DCPACK_GENERATOR=DEB -DBUILD_SHARED_LIBS=ON # or OFF for static libraries

Expand Down
73 changes: 0 additions & 73 deletions cmake/civetweb-3rdparty-config.cmake

This file was deleted.

29 changes: 0 additions & 29 deletions cmake/googlemock-3rdparty-config.cmake

This file was deleted.

10 changes: 1 addition & 9 deletions cmake/prometheus-cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ set_and_check(prometheus-cpp_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set(PROMETHEUS_CPP_ENABLE_PULL @ENABLE_PULL@)
set(PROMETHEUS_CPP_ENABLE_PUSH @ENABLE_PUSH@)
set(PROMETHEUS_CPP_USE_COMPRESSION @ENABLE_COMPRESSION@)
set(PROMETHEUS_CPP_USE_THIRDPARTY_LIBRARIES @USE_THIRDPARTY_LIBRARIES@)
set(PROMETHEUS_CPP_THIRDPARTY_CIVETWEB_WITH_SSL @THIRDPARTY_CIVETWEB_WITH_SSL@)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_dependency(Threads)
unset(CMAKE_THREAD_PREFER_PTHREAD)

if(PROMETHEUS_CPP_ENABLE_PULL)
if(PROMETHEUS_CPP_USE_THIRDPARTY_LIBRARIES)
if(PROMETHEUS_CPP_THIRDPARTY_CIVETWEB_WITH_SSL)
find_dependency(OpenSSL)
endif()
else()
find_dependency(civetweb)
endif()
find_dependency(civetweb)
endif()

if(PROMETHEUS_CPP_ENABLE_PULL AND PROMETHEUS_CPP_USE_COMPRESSION)
Expand Down
27 changes: 7 additions & 20 deletions pull/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
if(USE_THIRDPARTY_LIBRARIES)
find_package(civetweb-3rdparty CONFIG REQUIRED)
add_library(${PROJECT_NAME}::civetweb ALIAS civetweb)
install(
TARGETS civetweb
EXPORT ${PROJECT_NAME}-targets
# keep embedded civetweb headers scoped to prometheus(-cpp)
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/prometheus
)
else()
find_package(civetweb CONFIG REQUIRED)
find_package(civetweb CONFIG REQUIRED)

# work-around https://github.com/civetweb/civetweb/pull/918
if(WIN32 AND NOT TARGET WINSOCK::WINSOCK)
add_library(WINSOCK::WINSOCK INTERFACE IMPORTED)
target_link_libraries(WINSOCK::WINSOCK INTERFACE ws2_32)
endif()
# work-around https://github.com/civetweb/civetweb/pull/918
if(WIN32 AND NOT TARGET WINSOCK::WINSOCK)
add_library(WINSOCK::WINSOCK INTERFACE IMPORTED)
target_link_libraries(WINSOCK::WINSOCK INTERFACE ws2_32)
endif()

if(ENABLE_COMPRESSION)
Expand Down Expand Up @@ -46,7 +35,7 @@ target_link_libraries(pull
PRIVATE
${PROJECT_NAME}::util
Threads::Threads
$<IF:$<BOOL:${USE_THIRDPARTY_LIBRARIES}>,${PROJECT_NAME}::civetweb,civetweb::civetweb-cpp>
civetweb::civetweb-cpp
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:rt>
$<$<BOOL:${ENABLE_COMPRESSION}>:ZLIB::ZLIB>
)
Expand Down Expand Up @@ -95,9 +84,7 @@ if(GENERATE_PKGCONFIG)
set(PKGCONFIG_LIBS)
set(PKGCONFIG_REQUIRES)

if(NOT USE_THIRDPARTY_LIBRARIES)
string(APPEND PKGCONFIG_LIBS " -lcivetweb-cpp -lcivetweb")
endif()
string(APPEND PKGCONFIG_LIBS " -lcivetweb-cpp -lcivetweb")

if(ENABLE_COMPRESSION)
string(APPEND PKGCONFIG_REQUIRES " zlib")
Expand Down
Loading