Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppbenchmark: add 1.0.3.0, support conan v2 #15389

Merged
merged 2 commits into from
Jan 31, 2023
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
25 changes: 0 additions & 25 deletions recipes/cppbenchmark/all/CMakeLists.txt

This file was deleted.

23 changes: 16 additions & 7 deletions recipes/cppbenchmark/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
patches:
"1.0.0.0":
- patch_file: "patches/00001-update-cmakelists.patch"
base_path: "source_subfolder"
"cci.20201029":
- patch_file: "patches/00001-update-cmakelists.patch"
base_path: "source_subfolder"
sources:
"1.0.3.0":
url: "https://github.com/chronoxor/CppBenchmark/archive/1.0.3.0.tar.gz"
sha256: "6a62cfdb2aacf91523f74c6d0e42a3e2388ff94a2b7b983bec543c88554cc3e9"
"1.0.0.0":
url: "https://github.com/chronoxor/CppBenchmark/archive/1.0.0.0.tar.gz"
sha256: "8c043731e979ef570e3744484e6644de6e47db228b9543ec6433401e4e2f09b8"
"cci.20201029":
url: "https://github.com/chronoxor/CppBenchmark/archive/8605a8e886647e964180cb7a622424404a1da01f.tar.gz"
sha256: "f0b88802b4418b13c04ae4dfdb859b2cb81142a47ca473ad447a8be087e0adee"
patches:
"1.0.3.0":
- patch_file: "patches/1.0.3.0-0001-fix-cmake.patch"
patch_description: "fix install path, use cci packages, disable tests"
patch_type: "conan"
"1.0.0.0":
- patch_file: "patches/1.0.0.0-0001-fix-cmake.patch"
patch_description: "fix install path, use cci packages, disable tests"
patch_type: "conan"
"cci.20201029":
- patch_file: "patches/1.0.0.0-0001-fix-cmake.patch"
patch_description: "fix install path, use cci packages, disable tests"
patch_type: "conan"
119 changes: 69 additions & 50 deletions recipes/cppbenchmark/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,89 +1,108 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
import os
import glob

required_conan_version = ">=1.53.0"

class CppBenchmark(ConanFile):
name = "cppbenchmark"
description = "Performance benchmark framework for C++ with nanoseconds measure precision."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/chronoxor/CppBenchmark"
description = "Performance benchmark framework for C++ with nanoseconds measure precision."
topics = ("conan", "utils", "library", "benchmark")
settings = "os", "compiler", "build_type", "arch"
options = {"fPIC": [True, False],
"shared": [True, False]}
default_options = {"fPIC": True,
"shared": False}
requires = ["hdrhistogram-c/0.11.1", "cpp-optparse/cci.20171104"]
generators = "cmake"
exports_sources = ["patches/**", "CMakeLists.txt"]
_cmake = None
topics = ("utils", "library", "benchmark")
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"shared": [True, False],
}
default_options = {
"fPIC": True,
"shared": False,
}

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def _min_cppstd(self):
return 17
@property
def _compilers_minimum_version(self):
return {
"apple-clang": 10,
"clang": 6,
"gcc": 7,
"Visual Studio": 16,
"msvc": 191,
}

def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)
self._cmake.definitions["CPPBENCHMARK_MODULE"] = "OFF"
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def _patch(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob("CppBenchmark-*")[0]
os.rename(extracted_dir, self._source_subfolder)
def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "17")
def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("hdrhistogram-c/0.11.1")
self.requires("cpp-optparse/cci.20171104")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version:
if tools.Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration("cppbenchmark requires C++17, which your compiler does not support.")
else:
self.output.warn("cppbenchmark requires C++17. Your compiler is unknown. Assuming it supports C++17.")
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def _cmake_new_enough(self, required_version):
try:
import re
from io import StringIO
output = StringIO()
self.run("cmake --version", output=output)
m = re.search(r'cmake version (\d+\.\d+\.\d+)', output.getvalue())
return Version(m.group(1)) >= required_version
except:
return False

def build_requirements(self):
if not self._cmake_new_enough("3.20"):
self.tool_requires("cmake/3.25.1")

def build(self):
self._patch()
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["CPPBENCHMARK_MODULE"] = "OFF"
tc.generate()

cmake = self._configure_cmake()
deps = CMakeDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = self._configure_cmake()
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = ["cppbenchmark"]
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
Original file line number Diff line number Diff line change
@@ -1,89 +1,82 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1db1778..1e19e9f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,25 +18,25 @@ if(DOXYGEN_FOUND)
diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt
index 1db1778..0343a94 100644
--- a/a/CMakeLists.txt
+++ b/b/CMakeLists.txt
@@ -17,41 +17,41 @@ if(DOXYGEN_FOUND)
endif()
endif()

# CMake module path
-# CMake module path
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+# set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Compiler features
-
-# Compiler features
-include(SetCompilerFeatures)
-include(SetCompilerWarnings)
-include(SetPlatformFeatures)
-include(SystemInformation)
+# include(SetCompilerFeatures)
+# include(SetCompilerWarnings)
+# include(SetPlatformFeatures)
+# include(SystemInformation)

-
# External packages
find_package(Threads REQUIRED)

# Modules
-# Modules
-add_subdirectory("modules")
+# add_subdirectory("modules")

-
# Link libraries
list(APPEND LINKLIBS Threads::Threads)

# System directories
-# System directories
-include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/modules")
+# include_directories(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/modules")

-
# Library
+find_package(hdr_histogram REQUIRED CONFIG)
+if(TARGET hdr_histogram::hdr_histogram)
+ list(APPEND LINKLIBS hdr_histogram::hdr_histogram)
+else()
+ list(APPEND LINKLIBS hdr_histogram::hdr_histogram_static)
+endif()
+
+find_package(cpp-optparse REQUIRED CONFIG)
+list(APPEND LINKLIBS cpp-optparse::cpp-optparse)
+
+
file(GLOB_RECURSE LIB_HEADER_FILES "include/*.h")
@@ -45,14 +45,14 @@ file(GLOB_RECURSE LIB_SOURCE_FILES "source/*.cpp")
file(GLOB_RECURSE LIB_INLINE_FILES "include/*.inl")
file(GLOB_RECURSE LIB_SOURCE_FILES "source/*.cpp")
add_library(cppbenchmark ${LIB_HEADER_FILES} ${LIB_INLINE_FILES} ${LIB_SOURCE_FILES})
set_target_properties(cppbenchmark PROPERTIES COMPILE_FLAGS "${PEDANTIC_COMPILE_FLAGS}" FOLDER "libraries")
target_include_directories(cppbenchmark PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
-target_link_libraries(cppbenchmark ${LINKLIBS} cpp-optparse HdrHistogram)
+target_compile_definitions(cppbenchmark PUBLIC _CRT_SECURE_NO_WARNINGS)
+target_compile_features(cppbenchmark PUBLIC cxx_std_17)
+set_target_properties(cppbenchmark PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+target_link_libraries(cppbenchmark ${LINKLIBS})
list(APPEND INSTALL_TARGETS cppbenchmark)
list(APPEND LINKLIBS cppbenchmark)

# Additional module components: benchmarks, examples, plugins, tests, tools and install
if(NOT CPPBENCHMARK_MODULE)

- # Examples
+if(FALSE)
+ if(0)
# Examples
file(GLOB EXAMPLE_HEADER_FILES "examples/*.h")
file(GLOB EXAMPLE_INLINE_FILES "examples/*.inl")
file(GLOB EXAMPLE_SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/examples" "examples/*.cpp")
@@ -65,8 +65,8 @@ if(NOT CPPBENCHMARK_MODULE)
list(APPEND INSTALL_TARGETS ${EXAMPLE_TARGET})
list(APPEND INSTALL_TARGETS_PDB ${EXAMPLE_TARGET})
endforeach()
-
- # Tests
+endif()
+if(FALSE)
file(GLOB TESTS_HEADER_FILES "tests/*.h")
file(GLOB TESTS_INLINE_FILES "tests/*.inl")
file(GLOB TESTS_SOURCE_FILES "tests/*.cpp")
@@ -80,17 +80,17 @@ if(NOT CPPBENCHMARK_MODULE)
@@ -80,12 +80,16 @@ if(NOT CPPBENCHMARK_MODULE)
# CTest
enable_testing()
add_test(cppbenchmark-tests cppbenchmark-tests --durations yes --order lex)
-
+endif()
+ endif()
# Install
install(TARGETS ${INSTALL_TARGETS}
- RUNTIME DESTINATION "${PROJECT_SOURCE_DIR}/bin"
- LIBRARY DESTINATION "${PROJECT_SOURCE_DIR}/bin"
- ARCHIVE DESTINATION "${PROJECT_SOURCE_DIR}/bin")
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+ install(FILES ${LIB_HEADER_FILES} ${LIB_INLINE_FILES}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/benchmark)

# Install *.pdb files
- if(MSVC)
+ if(MSVC AND FALSE)
foreach(INSTALL_TARGET_PDB ${INSTALL_TARGETS_PDB})
- install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGET_PDB}> DESTINATION "${PROJECT_SOURCE_DIR}/bin")
+ install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGET_PDB}> DESTINATION bin OPTIONAL)
endforeach()
endif()

if(MSVC)
Loading