Skip to content

Commit

Permalink
(#3997) [Boost::ext].UT / ��t
Browse files Browse the repository at this point in the history
* Add initial [Boost-ext].UT recipe

* Lowercase package name

* Remove non-ascii character from description

* Fix URL

* Use source folder variable and include the Boost license

* Remove CMake generator

* Remove export_sources directive

* Copy the header file to the correct location

* Use explicit test_package name for the test executable target

* Disable C++ compiler extensions

* Remove includedirs property

* Format Python code according to PEP8

* Require minimum compiler versions and at least the C++20 standard

* Rename ut to boost-ext-ut

* Check if the cppstd is set before checking the minimum

* Provide warnings to consumers when compiler checks fail

Code taken from: conan-io/conan#8002

* Rename ut directory to boost-ext-ut

* Chang the minimum C++ standard to 17

Previously, the minimum C++ standard was 20, but only 17 is required.

* Import ConanInvalidConfiguration

* Configure CMake for using find_package

The behavior now models [Boost-ext].UT's current find_package behavior.
A CMake config file is provided with the name ut.
The library can be found with find_package(ut) as expected.
The CMake target, boost::ut, is also provided as expected.
I'm not sure how to remove the global target boost::boost.
I'd hate for this to conflict with the Boost library.

* Shorten line lengths to less that 80 characters for PEP8

* Remove unused import

The glob import was carried over from another header-only package.
Since it is not used here, it has been removed.

* Use the proper identifier for the Boost license

The license was previously "Boost".
This commit switches the license to proper identifier for this license.
The short identifier for the Boost license is BSL-1.0.
This comes from the SPDX specification:
https://spdx.org/licenses/BSL-1.0.html
  • Loading branch information
jwillikers authored Dec 29, 2020
1 parent 9754293 commit bcfa8a2
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/boost-ext-ut/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.1.8":
url: "https:/boost-ext/ut/archive/v1.1.8.tar.gz"
sha256: "3cc426dcf38397637e889efd9567b06d55dd23fb4e65cc0381eb8103a411d104"
72 changes: 72 additions & 0 deletions recipes/boost-ext-ut/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os


class UTConan(ConanFile):
name = "boost-ext-ut"
description = "C++17/20 single header/single module, "
"macro-free micro Unit Testing Framework"
topics = ("conan", "UT", "header-only", "unit-test", "tdd", "bdd")
url = "https:/conan-io/conan-center-index"
homepage = "https://boost-ext.github.io/ut/"
license = "BSL-1.0"
settings = "os", "compiler", "arch", "build_type"
no_copy_source = True

@property
def _minimum_cpp_standard(self):
return 17

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "16",
"gcc": "9",
"clang": "9",
"apple-clang": "11",
}

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

def configure(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(
str(self.settings.compiler))
if not min_version:
self.output.warn("{} recipe lacks information about the {} "
"compiler support.".format(
self.name, self.settings.compiler))
else:
if tools.Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
"{} requires C++{} support. "
"The current compiler {} {} does not support it.".format(
self.name, self._minimum_cpp_standard,
self.settings.compiler,
self.settings.compiler.version))

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("ut-" + self.version, self._source_subfolder)
tools.download("https://www.boost.org/LICENSE_1_0.txt", "LICENSE",
sha256="c9bff75738922193e67fa726fa225535870d2aa1059f914"
"52c411736284ad566")

def package(self):
self.copy("LICENSE", dst="licenses")
self.copy(os.path.join("include", "boost", "ut.hpp"),
src=self._source_subfolder)

def package_id(self):
self.info.header_only()

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "boost"
self.cpp_info.names["cmake_find_package_multi"] = "boost"
self.cpp_info.filenames["cmake_find_package"] = "ut"
self.cpp_info.filenames["cmake_find_package_multi"] = "ut"
self.cpp_info.components["ut"].includedirs = []
14 changes: 14 additions & 0 deletions recipes/boost-ext-ut/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED yes)
set(CMAKE_CXX_EXTENSIONS no)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(ut REQUIRED CONFIG)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package boost::ut)
17 changes: 17 additions & 0 deletions recipes/boost-ext-ut/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
6 changes: 6 additions & 0 deletions recipes/boost-ext-ut/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "boost/ut.hpp"

int main() {
boost::ut::expect(true);
return 0;
}
3 changes: 3 additions & 0 deletions recipes/boost-ext-ut/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.1.8":
folder: "all"

0 comments on commit bcfa8a2

Please sign in to comment.