Repository: conan-io/conan-center-index

Issue:
[request] celero/2.8.0
### Package Details
  * Package Name/Version: **celero/2.8.0**
  * Changelog: **https://github.com/DigitalInBlue/Celero/releases/tag/v2.8.0**

The above mentioned version is newly released by the upstream project and not yet available as a recipe. Please add this version.



Discussion:

Resolving patch:
diff --git a/recipes/celero/all/conanfile.py b/recipes/celero/all/conanfile.py
--- a/recipes/celero/all/conanfile.py
+++ b/recipes/celero/all/conanfile.py
@@ -1,9 +1,9 @@
 import os
-
+import textwrap
 from conans import ConanFile, CMake, tools
 from conans.errors import ConanInvalidConfiguration
 
-required_conan_version = ">=1.28.0"
+required_conan_version = ">=1.33.0"
 
 class CeleroConan(ConanFile):
     name = "celero"
@@ -49,8 +49,7 @@ def configure(self):
             raise ConanInvalidConfiguration("celero requires C++14, which your compiler does not support.")
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version])
-        os.rename("Celero-" + self.version, self._source_subfolder)
+        tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
 
     def _configure_cmake(self):
         if self._cmake:
@@ -76,17 +75,44 @@ def package(self):
         cmake = self._configure_cmake()
         cmake.install()
         tools.rmdir(os.path.join(self.package_folder, "share"))
+        self._create_cmake_module_alias_targets(
+            os.path.join(self.package_folder, self._module_file_rel_path),
+            {"celero": "celero::celero"}
+        )
+
+    @staticmethod
+    def _create_cmake_module_alias_targets(module_file, targets):
+        content = ""
+        for alias, aliased in targets.items():
+            content += textwrap.dedent("""\
+                if(TARGET {aliased} AND NOT TARGET {alias})
+                    add_library({alias} INTERFACE IMPORTED)
+                    set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
+                endif()
+            """.format(alias=alias, aliased=aliased))
+        tools.save(module_file, content)
+
+    @property
+    def _module_subfolder(self):
+        return os.path.join("lib", "cmake")
+
+    @property
+    def _module_file_rel_path(self):
+        return os.path.join(self._module_subfolder,
+                            "conan-official-{}-targets.cmake".format(self.name))
 
     def package_info(self):
-        # FIXME: official CMake target is exported without namespace
         self.cpp_info.filenames["cmake_find_package"] = "Celero"
         self.cpp_info.filenames["cmake_find_package_multi"] = "Celero"
         self.cpp_info.names["cmake_find_package"] = "celero"
         self.cpp_info.names["cmake_find_package_multi"] = "celero"
         self.cpp_info.libs = tools.collect_libs(self)
+        self.cpp_info.builddirs.append(self._module_subfolder)
+        self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
+        self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
         if not self.options.shared:
             self.cpp_info.defines = ["CELERO_STATIC"]
-        if self.settings.os == "Linux":
+        if self.settings.os in ("FreeBSD", "Linux"):
             self.cpp_info.system_libs = ["pthread"]
         elif self.settings.os == "Windows":
             self.cpp_info.system_libs = ["powrprof", "psapi"]


Test patch:
diff --git a/recipes/celero/all/test_package/CMakeLists.txt b/recipes/celero/all/test_package/CMakeLists.txt
--- a/recipes/celero/all/test_package/CMakeLists.txt
+++ b/recipes/celero/all/test_package/CMakeLists.txt
@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.1)
 project(test_package)
 
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-conan_basic_setup()
+conan_basic_setup(TARGETS)
 
 find_package(Celero REQUIRED CONFIG)
 
 add_executable(${PROJECT_NAME} test_package.cpp)
-target_link_libraries(${PROJECT_NAME} celero::celero)
+target_link_libraries(${PROJECT_NAME} celero)
 set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)