Skip to content

Commit 4b1413f

Browse files
authored
Merge pull request #517 from cppalliance/develop
2 parents da4fdb3 + 47cb147 commit 4b1413f

File tree

6 files changed

+167
-1
lines changed

6 files changed

+167
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,31 @@ This library is not an official boost library, and is under active development.
1818
# How To Use The Library
1919

2020
This library is header only, and contains no dependencies.
21-
It can either be copied into the directory of your choice, or installed with CMake.
21+
22+
## CMake
23+
24+
````
25+
git clone https://github.com/cppalliance/decimal
26+
cd decimal
27+
mkdir build && cd build
28+
cmake .. OR cmake .. -DCMAKE_INSTALL_PREFIX=/your/custom/path
29+
cmake --install .
30+
````
31+
32+
## vcpkg
33+
34+
````
35+
git clone https://github.com/cppalliance/decimal
36+
cd decimal
37+
vcpkg install decimal --overlay-ports=ports/decimal
38+
````
39+
40+
## Conan
41+
42+
````
43+
git clone https://github.com/cppalliance/decimal
44+
conan create decimal/conan --build missing
45+
````
2246

2347
# Supported Platforms
2448

conan/conanfile.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from conan import ConanFile
2+
from conan.errors import (
3+
ConanException,
4+
ConanInvalidConfiguration,
5+
)
6+
from conan.tools.files import copy
7+
from conan.tools.build import check_min_cppstd
8+
from conan.tools.cmake import (
9+
cmake_layout,
10+
CMake,
11+
CMakeDeps,
12+
CMakeToolchain,
13+
)
14+
from conan.tools.scm import Version
15+
16+
import os
17+
18+
required_conan_version = ">=1.53.0"
19+
20+
class CharconvConan(ConanFile):
21+
name = "boost_decimal"
22+
version = "1.0.0"
23+
description = "Boost provides free peer-reviewed portable C++ source libraries"
24+
url = "https://github.com/cppalliance/decimal"
25+
homepage = "https://github.com/cppalliance/decimal"
26+
license = "BSL-1.0"
27+
topics = ("decimal-binary", "conversion")
28+
29+
settings = "os", "arch", "compiler", "build_type"
30+
31+
options = {
32+
"shared": [True, False],
33+
"fPIC": [True, False],
34+
}
35+
default_options = {
36+
"shared": False,
37+
"fPIC": True,
38+
}
39+
40+
requires = "boost/[>=1.82.0]"
41+
42+
@property
43+
def _min_compiler_version_default_cxx14(self):
44+
return {
45+
"apple-clang": 99,
46+
"gcc": 6,
47+
"clang": 6,
48+
"Visual Studio": 14, # guess
49+
"msvc": 192,
50+
}.get(str(self.settings.compiler))
51+
52+
def config_options(self):
53+
if self.settings.os == "Windows":
54+
del self.options.fPIC
55+
56+
def validate(self):
57+
if self.settings.compiler.get_safe("cppstd"):
58+
check_min_cppstd(self, 14)
59+
else:
60+
version_cxx14_standard_json = self._min_compiler_version_default_cxx14
61+
if not version_cxx14_standard_json:
62+
self.output.warning("Assuming the compiler supports c++14 by default")
63+
elif Version(self.settings.compiler.version) < version_cxx14_standard_json:
64+
raise ConanInvalidConfiguration("Boost.Decimal requires C++14")
65+
66+
def layout(self):
67+
self.folders.root = ".."
68+
cmake_layout(self, build_folder="bin")
69+
70+
def export_sources(self):
71+
src = os.path.join(self.recipe_folder, "..")
72+
copy(self, "CMakeLists.txt", src, self.export_sources_folder)
73+
copy(self, "LICENSE", src, self.export_sources_folder)
74+
copy(self, "include*", src, self.export_sources_folder)
75+
copy(self, "conan/*.cmake", src, self.export_sources_folder)
76+
77+
def generate(self):
78+
boost = self.dependencies["boost"]
79+
80+
tc = CMakeToolchain(self)
81+
tc.variables["BOOST_SUPERPROJECT_VERSION"] = boost.ref.version
82+
tc.variables["CMAKE_PROJECT_boost_decimal_INCLUDE"] = os.path.join(
83+
self.source_folder, "conan", "targets.cmake")
84+
tc.generate()
85+
86+
deps = CMakeDeps(self)
87+
deps.generate()
88+
89+
def build(self):
90+
cmake = CMake(self)
91+
cmake.configure()
92+
cmake.build()
93+
94+
def package(self):
95+
libdir = os.path.join(self.package_folder, "lib")
96+
97+
copy(self, "include/*", self.source_folder, self.package_folder)
98+
99+
copy(self, "LICENSE", self.source_folder, self.package_folder)
100+
101+
def package_info(self):
102+
self.cpp_info.libs = ["boost_decimal"]

conan/targets.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
find_package(Boost)

ports/decimal/b2-options.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2024 Matt Borland
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# https://www.boost.org/LICENSE_1_0.txt
4+
5+
if(APPLE)
6+
list(APPEND B2_OPTIONS cxxstd=14)
7+
endif()

ports/decimal/portfile.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 Matt Borland
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# https://www.boost.org/LICENSE_1_0.txt
4+
#
5+
# See: https://devblogs.microsoft.com/cppblog/registries-bring-your-own-libraries-to-vcpkg/
6+
7+
vcpkg_from_github(
8+
OUT_SOURCE_PATH SOURCE_PATH
9+
REPO cppalliance/decimal
10+
REF v1.0.0
11+
SHA512 73043ea9514b747e519a5365ae57d9c1516d5f55784779d056d7db7266fd68328cd394e144db28125563c898b1d3acb6a4b47588ff319edefc84d35567a40b52
12+
HEAD_REF master
13+
)
14+
15+
file(COPY "${SOURCE_PATH}/include" DESTINATION "${CURRENT_PACKAGES_DIR}")
16+
file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

ports/decimal/vcpkg.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "decimal",
3+
"version": "1.0.0",
4+
"description": "A C++14 implementation of IEEE 754 decimal floating point numbers",
5+
"homepage": "https://github.com/cppalliance/decimal",
6+
"dependencies": [
7+
{
8+
"name": "boost-vcpkg-helpers",
9+
"version>=": "1.81.0"
10+
},
11+
{
12+
"name": "vcpkg-cmake",
13+
"host": true
14+
}
15+
]
16+
}

0 commit comments

Comments
 (0)