jupp0r / prometheus-cpp

Prometheus Client Library for Modern C++
Other
933 stars 329 forks source link

conan: couldn't find prometheus-cpp-config.cmake #491

Closed alejandro-colomar closed 3 years ago

alejandro-colomar commented 3 years ago

I'm trying to consume prometheus-cpp using conan.

For the configuration I need, there isn't a binary in conan-center:

$ conan install ..
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=10
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

prometheus-cpp/0.12.1: Not found in local cache, looking in remotes...
prometheus-cpp/0.12.1: Trying with 'conan-center'...
Downloading conanmanifest.txt completed [0.17k]                                          
Downloading conanfile.py completed [4.72k]                                               
Downloading conan_export.tgz completed [0.25k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
prometheus-cpp/0.12.1: Downloaded recipe revision 0
WARN: civetweb/1.13: requirement openssl/1.1.1j overridden by prometheus-cpp/0.12.1 to openssl/1.1.1k 
conanfile.txt: Installing package
Requirements
    civetweb/1.13 from 'conan-center' - Cache
    openssl/1.1.1k from 'conan-center' - Cache
    prometheus-cpp/0.12.1 from 'conan-center' - Downloaded
    zlib/1.2.11 from 'conan-center' - Cache
Packages
    civetweb/1.13:ff7d8e313870093398ddb2d084c02f05a627d08d - Cache
    openssl/1.1.1k:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache
    prometheus-cpp/0.12.1:1b05c68ed8a234cca640f590e0ff5c9069c605ba - Missing
    zlib/1.2.11:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache

Installing (downloading, building) binaries...
ERROR: Missing binary: prometheus-cpp/0.12.1:1b05c68ed8a234cca640f590e0ff5c9069c605ba

prometheus-cpp/0.12.1: WARN: Can't find a 'prometheus-cpp/0.12.1' package for the specified settings, options and dependencies:
- Settings: arch=x86_64, build_type=Release, compiler=gcc, compiler.libcxx=libstdc++, compiler.version=10, os=Linux
- Options: fPIC=True, shared=False, with_compression=True, with_pull=True, with_push=False, civetweb:fPIC=True, civetweb:shared=False, civetweb:ssl_dynamic_loading=False, civetweb:with_cxx=True, civetweb:with_ipv6=True, civetweb:with_ssl=True, civetweb:with_websockets=True, openssl:386=False, openssl:fPIC=True, openssl:no_aria=False, openssl:no_asm=False, openssl:no_async=False, openssl:no_bf=False, openssl:no_blake2=False, openssl:no_camellia=False, openssl:no_cast=False, openssl:no_chacha=False, openssl:no_cms=False, openssl:no_comp=False, openssl:no_ct=False, openssl:no_deprecated=False, openssl:no_des=False, openssl:no_dgram=False, openssl:no_dh=False, openssl:no_dsa=False, openssl:no_dso=False, openssl:no_engine=False, openssl:no_filenames=False, openssl:no_gost=False, openssl:no_hmac=False, openssl:no_idea=False, openssl:no_md4=False, openssl:no_md5=False, openssl:no_mdc2=False, openssl:no_ocsp=False, openssl:no_pinshared=False, openssl:no_rc2=False, openssl:no_rmd160=False, openssl:no_rsa=False, openssl:no_sha=False, openssl:no_sm2=False, openssl:no_sm3=False, openssl:no_sm4=False, openssl:no_srp=False, openssl:no_srtp=False, openssl:no_sse2=False, openssl:no_ssl=False, openssl:no_threads=False, openssl:no_ts=False, openssl:no_whirlpool=False, openssl:openssldir=None, openssl:shared=False, zlib:fPIC=True, zlib:minizip=deprecated, zlib:shared=False
- Dependencies: civetweb/1.13, zlib/1.2.11
- Requirements: civetweb/1.Y.Z, zlib/1.Y.Z
- Package ID: 1b05c68ed8a234cca640f590e0ff5c9069c605ba

ERROR: Missing prebuilt package for 'prometheus-cpp/0.12.1'
Try to build from sources with '--build=prometheus-cpp'
Use 'conan search <reference> --table table.html'
Or read 'http://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package'

So I built it myself:

$ conan install .. --build=prometheus-cpp
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=10
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

WARN: civetweb/1.13: requirement openssl/1.1.1j overridden by prometheus-cpp/0.12.1 to openssl/1.1.1k 
prometheus-cpp/0.12.1: Forced build from source
conanfile.txt: Installing package
Requirements
    civetweb/1.13 from 'conan-center' - Cache
    openssl/1.1.1k from 'conan-center' - Cache
    prometheus-cpp/0.12.1 from 'conan-center' - Cache
    zlib/1.2.11 from 'conan-center' - Cache
Packages
    civetweb/1.13:ff7d8e313870093398ddb2d084c02f05a627d08d - Cache
    openssl/1.1.1k:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache
    prometheus-cpp/0.12.1:1b05c68ed8a234cca640f590e0ff5c9069c605ba - Build
    zlib/1.2.11:19729b9559f3ae196cad45cb2b97468ccb75dcd1 - Cache

Installing (downloading, building) binaries...
openssl/1.1.1k: Already installed!
zlib/1.2.11: Already installed!
civetweb/1.13: Already installed!
civetweb/1.13: Appending PATH environment variable: /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/bin
Downloading conan_sources.tgz completed [0.25k]                                          
Decompressing conan_sources.tgz completed [0.00k]                                        
prometheus-cpp/0.12.1: Configuring sources in /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/source
Downloading v0.12.1.tar.gz completed [51.79k]                                            

prometheus-cpp/0.12.1: Copying sources to build folder
prometheus-cpp/0.12.1: Building your package in /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/build/1b05c68ed8a234cca640f590e0ff5c9069c605ba
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created civetweb-config-version.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created civetwebTarget-release.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created civetwebTargets.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created civetweb-config.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created ZLIBConfigVersion.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created ZLIBConfig.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created ZLIBTargets.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created ZLIBTarget-release.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created OpenSSLConfigVersion.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created OpenSSLTarget-release.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created OpenSSLTargets.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package_multi created OpenSSLConfig.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package created Findcivetweb.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package created FindZLIB.cmake
prometheus-cpp/0.12.1: Generator cmake_find_package created FindOpenSSL.cmake
prometheus-cpp/0.12.1: Generator cmake created conanbuildinfo.cmake
prometheus-cpp/0.12.1: Calling build()
cmake: /opt/conan/liblzma.so.5: version `XZ_5.2' not found (required by /lib/x86_64-linux-gnu/libarchive.so.13)
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler GCC>=5, checking major version 10
-- Conan: Checking correct version: 10
-- Conan: C++ stdlib: libstdc++
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Library civetweb-cpp found /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb-cpp.a
-- Found: /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb-cpp.a
-- Library civetweb found /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb.a
-- Found: /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb.a
-- Library civetweb found /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb.a
-- Found: /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb.a
-- Library civetweb-cpp found /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb-cpp.a
-- Found: /home/alx/.conan/data/civetweb/1.13/_/_/package/ff7d8e313870093398ddb2d084c02f05a627d08d/lib/libcivetweb-cpp.a
-- Library ssl found /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libssl.a
-- Found: /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libssl.a
-- Library crypto found /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libcrypto.a
-- Found: /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libcrypto.a
-- Library crypto found /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libcrypto.a
-- Found: /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libcrypto.a
-- Library ssl found /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libssl.a
-- Found: /home/alx/.conan/data/openssl/1.1.1k/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libssl.a
-- Conan: Using autogenerated FindZLIB.cmake
-- Found ZLIB: 1.2.11 (found version "1.2.11") 
-- Library z found /home/alx/.conan/data/zlib/1.2.11/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libz.a
-- Found: /home/alx/.conan/data/zlib/1.2.11/_/_/package/19729b9559f3ae196cad45cb2b97468ccb75dcd1/lib/libz.a
-- The following features have been enabled:

 * Pull, support for pulling metrics
 * Compression, support for zlib compression of metrics

-- The following OPTIONAL packages have been found:

 * Threads

-- The following REQUIRED packages have been found:

 * civetweb
 * ZLIB

-- The following features have been disabled:

 * Push, support for pushing metrics to a push-gateway

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY

-- Build files have been written to: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/build/1b05c68ed8a234cca640f590e0ff5c9069c605ba/build_subfolder
Scanning dependencies of target core
[  5%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/check_names.cc.o
[ 10%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/counter.cc.o
[ 15%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/detail/builder.cc.o
[ 20%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/detail/ckms_quantiles.cc.o
[ 25%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/detail/time_window_quantiles.cc.o
[ 30%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/detail/utils.cc.o
[ 35%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/family.cc.o
[ 40%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/gauge.cc.o
[ 45%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/histogram.cc.o
[ 50%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/registry.cc.o
[ 55%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/serializer.cc.o
[ 60%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/summary.cc.o
[ 65%] Building CXX object source_subfolder/core/CMakeFiles/core.dir/src/text_serializer.cc.o
[ 70%] Linking CXX static library ../../lib/libprometheus-cpp-core.a
[ 70%] Built target core
Scanning dependencies of target pull
[ 80%] Building CXX object source_subfolder/pull/CMakeFiles/pull.dir/src/basic_auth.cc.o
[ 80%] Building CXX object source_subfolder/pull/CMakeFiles/pull.dir/src/endpoint.cc.o
[ 85%] Building CXX object source_subfolder/pull/CMakeFiles/pull.dir/src/exposer.cc.o
[ 90%] Building CXX object source_subfolder/pull/CMakeFiles/pull.dir/src/handler.cc.o
[ 95%] Building CXX object source_subfolder/pull/CMakeFiles/pull.dir/src/metrics_collector.cc.o
[100%] Linking CXX static library ../../lib/libprometheus-cpp-pull.a
[100%] Built target pull
prometheus-cpp/0.12.1: Package '1b05c68ed8a234cca640f590e0ff5c9069c605ba' built
prometheus-cpp/0.12.1: Build folder /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/build/1b05c68ed8a234cca640f590e0ff5c9069c605ba
prometheus-cpp/0.12.1: Generated conaninfo.txt
prometheus-cpp/0.12.1: Generated conanbuildinfo.txt
prometheus-cpp/0.12.1: Generating the package
prometheus-cpp/0.12.1: Package folder /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba
prometheus-cpp/0.12.1: Calling package()
[ 70%] Built target core
[100%] Built target pull
Install the project...
-- Install configuration: "Release"
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/lib/cmake/prometheus-cpp/prometheus-cpp-targets.cmake
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/lib/cmake/prometheus-cpp/prometheus-cpp-targets-release.cmake
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/lib/cmake/prometheus-cpp/prometheus-cpp-config.cmake
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/lib/libprometheus-cpp-core.a
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/metric_type.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/metric_family.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/client_metric.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/family.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/gauge.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/summary.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/text_serializer.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/collectable.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/registry.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/histogram.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/check_names.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/counter.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/time_window_quantiles.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/builder.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/future_std.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/ckms_quantiles.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/utils.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/serializer.h
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/core_export.h
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/lib/libprometheus-cpp-pull.a
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/exposer.h
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus
-- Up-to-date: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail
-- Installing: /home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/detail/pull_export.h
prometheus-cpp/0.12.1 package(): Packaged 1 file: LICENSE
prometheus-cpp/0.12.1 package(): Packaged 2 '.a' files: libprometheus-cpp-pull.a, libprometheus-cpp-core.a
prometheus-cpp/0.12.1 package(): Packaged 21 '.h' files
prometheus-cpp/0.12.1: Package '1b05c68ed8a234cca640f590e0ff5c9069c605ba' created
prometheus-cpp/0.12.1: Created package revision 6b4c35278068722bec81a6a7fef879d7
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator cmake_find_package created Findprometheus-cpp.cmake
conanfile.txt: Generator cmake_find_package created Findcivetweb.cmake
conanfile.txt: Generator cmake_find_package created FindZLIB.cmake
conanfile.txt: Generator cmake_find_package created FindOpenSSL.cmake
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo

But it generates Findprometheus-cpp.cmake, and not prometheus-cpp-config.cmake.

So, if I use the cmake configuration that you suggest in your example , it fails to find it:

find_package(prometheus-cpp CONFIG REQUIRED)
CMake Error at src/xxx/CMakeLists.txt:95 (find_package):
  Could not find a package configuration file provided by "prometheus-cpp"
  with any of the following names:

    prometheus-cppConfig.cmake
    prometheus-cpp-config.cmake

  Add the installation prefix of "prometheus-cpp" to CMAKE_PREFIX_PATH or set
  "prometheus-cpp_DIR" to a directory containing one of the above files.  If
  "prometheus-cpp" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

And if I use

find_package(prometheus-cpp REQUIRED)

It correctly finds Findprometheus-cpp.cmake, but then it fails later:

[ 45%] Building CXX object src/xxx/CMakeFiles/xxx.cpp.o
/usr/local/src/xxx/include/xxx.h:4:10: error: 'prometheus/counter.h' file not found [clang-diagnostic-error]
#include <prometheus/counter.h>
         ^

eventhough I know that header file does exist on my machine:

$ find ~ | grep prometheus/counter.h
/home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/build/1b05c68ed8a234cca640f590e0ff5c9069c605ba/source_subfolder/core/include/prometheus/counter.h
/home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/source/source_subfolder/core/include/prometheus/counter.h
/home/alx/.conan/data/prometheus-cpp/0.12.1/_/_/package/1b05c68ed8a234cca640f590e0ff5c9069c605ba/include/prometheus/counter.h

Am I missing something, or is it a bug in prometheus-cpp?

aleksa2808 commented 3 years ago

Hey, this is not a bug in prometheus-cpp, but an expected behavior of packages found in conan-center. Since Conan aims to be build-system agnostic, it requires recipes in conan-center to remove all build-system specific files such as prometheus-cpp-config.cmake from the resulting packages. Instead, how those packages are meant to be used is through generators that create these integration files themselves. In your case, you used the cmake_find_package generator which created the Findprometheus-cpp.cmake file that gets loaded when you do find_package(prometheus-cpp REQUIRED) (the default mode is MODULE). If you want to use the CONFIG approach, then the cmake_find_package_multi should be the one that's used, since that's the one that generates prometheus-cpp-config.cmake. You can read more about the mentioned conan-center constraint here and about the available CMake generators here.

P.S. You might also want to change the compiler.libcxx in your Conan profile to libstdc++11, since libstdc++ denotes the old gcc ABI used before version 5.1.

alejandro-colomar commented 3 years ago

Hmmm, it's not that I want to use the CONFIG approach, but the default MODULE is not working for me. If there's any way I can fix that, I guess it'll be better than using CONFIG, ain't it? Would you mind helping me fix that? Maybe I should open a separate issue for that?

Thanks! (and thanks too for the remark about libstdc++11 :)

Alex

aleksa2808 commented 3 years ago

Can you share the rest of your CMakeLists.txt file? Specifically the part where you create the library that contains xxx.cpp.

As for the approaches, as far as I can tell they are all evolving, so just use what works for you. I currently use a custom recipe that doesn't delete the original prometheus-cpp-config.cmake file and use the cmake_paths generator to help CMake find it, but last I saw using that generator is a bit discouraged by the Conan devs.

alejandro-colomar commented 3 years ago
add_library(xxx SHARED
    xxx.cpp
    asio.cpp
    time.cpp
    xxxxxx.cpp
    metrics/server.cpp
    kafka/producer.cpp
    )

There's not much there, and between find_package(prometheus-cpp ...) and that, there's 0 code affecting prometheus, there's only code calling other dependencies, similar to how I used prometheus-cpp before trying conan.

I'll show you the diff of my attempt to use conan, so you can see what I had before (which worked) (you'll see here prometheus-cpp 0.11.0, because that's what I use, but I made sure that with 0.12.1 I have the same exact problem):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd99679..3e220d2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,10 +9,12 @@ set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty")

 set(CMAKE_MODULE_PATH
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+   ${CMAKE_BINARY_DIR}
    ${CMAKE_MODULE_PATH}
    "${THIRDPARTY_DIR}/catch2/cmake"
    "${THIRDPARTY_DIR}/CMake-codecov/cmake"
    )
+set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})

 include(Version)

diff --git a/conanfile.txt b/conanfile.txt
new file mode 100644
index 0000000..a1bd07b
--- /dev/null
+++ b/conanfile.txt
@@ -0,0 +1,11 @@
+[requires]
+   openssl/1.1.1k
+   prometheus-cpp/0.11.0
+
+[generators]
+   cmake_find_package
+
+[options]
+   prometheus-cpp:shared=False
+   prometheus-cpp:with_pull=True
+   prometheus-cpp:with_push=False
diff --git a/src/xxx/CMakeLists.txt b/src/xxx/CMakeLists.txt
index ece54d3..ce5e25b 100644
--- a/src/xxx/CMakeLists.txt
+++ b/src/xxx/CMakeLists.txt
@@ -92,31 +92,7 @@ if(NOT asio_POPULATED)
    set(asio_INCLUDE_DIR ${asio_SOURCE_DIR}/asio/include)
 endif()

-ExternalProject_Add(prometheus
-   PREFIX ${THIRDPARTY_DIR}/prometheus
-   GIT_REPOSITORY git@xxxxxxxxxxxxxxxxxx/dependencies/prometheus-cpp.git
-   GIT_TAG v0.11.0
-   GIT_REMOTE_NAME xxxxxxxxx
-   #GIT_PROGRESS ON
-   #GIT_SHALLOW ON # this project cannot be shallow-cloned
-   #INSTALL_COMMAND ""
-   EXCLUDE_FROM_ALL ON
-   CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF --log-level=WARNING -DCMAKE_POSITION_INDEPENDENT_CODE=ON
-    -DENABLE_TESTING=OFF
-   -DENABLE_PULL=ON
-   -DENABLE_PUSH=OFF
-   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-   )
-ExternalProject_Get_property(prometheus SOURCE_DIR)
-ExternalProject_Get_property(prometheus BINARY_DIR)
-set(prometheus_INCLUDE_DIRS ${SOURCE_DIR}/core/include)
-# TODO: Review the prometheus build configurations, this structure seems a bit strange.
-list(APPEND prometheus_INCLUDE_DIRS
-   ${BINARY_DIR}/core/include
-   ${SOURCE_DIR}/pull/include
-   ${BINARY_DIR}/pull/include
-   )
-set(prometheus_LIBRARY_DIR ${BINARY_DIR}/lib)
+find_package(prometheus-cpp 0.11.0 REQUIRED)

 ExternalProject_Add(rdkafka
    PREFIX ${THIRDPARTY_DIR}/rdkafka
@@ -195,7 +171,6 @@ endif()
 add_dependencies(xxx
    spdlog
    rdkafka
-   prometheus
    )

 target_include_directories(xxx PRIVATE
aleksa2808 commented 3 years ago

Do you have a target_link_libraries(xxx prometheus-cpp::core prometheus-cpp::pull) line anywhere? Your compiler can't find prometheus-cpp include dirs so somehow it's not being put on the xxx target compile line. Where were prometheus_INCLUDE_DIRS and prometheus_LIBRARY_DIR used in your CMakeLists.txt before?

alejandro-colomar commented 3 years ago

Ahhh, yes, it was to the end of the file:

$ find -type f | grep -i cmake | xargs pcregrep -Mn '(?s)target_link_libraries.*?\)';
./src/xxx/CMakeLists.txt:200:
target_link_libraries(xxx PRIVATE
    libavrocpp_s.a
    ${json_LIBRARY}
    librdkafka++.a librdkafka.a
    ${OPENSSL_LIBRARIES}
    prometheus-cpp-pull prometheus-cpp-core
    ${spdlog_LIBRARY}
    stdc++fs
    )

I'm new to this project where I need to move the current implementation to use conan; I've always used make & pkg-config & simple POSIX tools, so all this is new to me :).

Thanks for the help!

prometheus_INCLUDE_DIR was/is being used here:

$ find -type f | grep -i cmake | xargs pcregrep -Mn '(?s)target_include_directories.*?\)';
./src/xxx/CMakeLists.txt:176:
target_include_directories(xxx PRIVATE
    ${CMAKE_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}/xxxxxx
    ${asio_INCLUDE_DIR}
    ${avro_INCLUDE_DIR}
    ${Boost_INCLUDE_DIRS}
    ${json_INCLUDE_DIR}
    ${prometheus_INCLUDE_DIRS}
    ${rdkafka_INCLUDE_DIR}
    ${span_INCLUDE_DIR}
    ${spdlog_INCLUDE_DIR}
    )

prometheus_LIBRARY_DIR was/is being used here:

$ find -type f | grep -i cmake | xargs pcregrep -Mn '(?s)target_link_directories.*?\)'
./src/xxx/CMakeLists.txt:190:
target_link_directories(xxx PRIVATE
    ${avro_LIBRARY_DIR}
    ${json_LIBRARY_DIR}
    ${prometheus_LIBRARY_DIR} #libprometheus-cpp-core.a && pull.a
    ${rdkafka_LIBRARY_DIR}/src-cpp #librdkafka++.a
    ${rdkafka_LIBRARY_DIR}/src #librdkafka.a
    ${spdlog_LIBRARY_DIR}
    )
aleksa2808 commented 3 years ago

A couple of things I see:

In general, modern CMake advises always using targets instead of variables. Here's one great talk about all of that if you're relatively new to CMake.

alejandro-colomar commented 3 years ago

Great!

After removing prometheus_*_DIR[S] and replacing prometheus-cpp-* by prometheus-cpp::*, it started finding the headers, and gave a new error in the linking stage.

Then, after replacing compiler.libcxx=libstdc++ by compiler.libcxx=libstdc++11, those linker errors disappeared, and now it works!!

:-)