-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from cppalliance/packages
Add vcpkg and Conan packages
- Loading branch information
Showing
6 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
from conan import ConanFile | ||
from conan.errors import ( | ||
ConanException, | ||
ConanInvalidConfiguration, | ||
) | ||
from conan.tools.files import copy | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import ( | ||
cmake_layout, | ||
CMake, | ||
CMakeDeps, | ||
CMakeToolchain, | ||
) | ||
from conan.tools.scm import Version | ||
|
||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class CharconvConan(ConanFile): | ||
name = "boost_decimal" | ||
version = "1.0.0" | ||
description = "Boost provides free peer-reviewed portable C++ source libraries" | ||
url = "https://github.com/cppalliance/decimal" | ||
homepage = "https://github.com/cppalliance/decimal" | ||
license = "BSL-1.0" | ||
topics = ("decimal-binary", "conversion") | ||
|
||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
requires = "boost/[>=1.82.0]" | ||
|
||
@property | ||
def _min_compiler_version_default_cxx14(self): | ||
return { | ||
"apple-clang": 99, | ||
"gcc": 6, | ||
"clang": 6, | ||
"Visual Studio": 14, # guess | ||
"msvc": 192, | ||
}.get(str(self.settings.compiler)) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, 14) | ||
else: | ||
version_cxx14_standard_json = self._min_compiler_version_default_cxx14 | ||
if not version_cxx14_standard_json: | ||
self.output.warning("Assuming the compiler supports c++14 by default") | ||
elif Version(self.settings.compiler.version) < version_cxx14_standard_json: | ||
raise ConanInvalidConfiguration("Boost.Decimal requires C++14") | ||
|
||
def layout(self): | ||
self.folders.root = ".." | ||
cmake_layout(self, build_folder="bin") | ||
|
||
def export_sources(self): | ||
src = os.path.join(self.recipe_folder, "..") | ||
copy(self, "CMakeLists.txt", src, self.export_sources_folder) | ||
copy(self, "LICENSE", src, self.export_sources_folder) | ||
copy(self, "include*", src, self.export_sources_folder) | ||
copy(self, "conan/*.cmake", src, self.export_sources_folder) | ||
|
||
def generate(self): | ||
boost = self.dependencies["boost"] | ||
|
||
tc = CMakeToolchain(self) | ||
tc.variables["BOOST_SUPERPROJECT_VERSION"] = boost.ref.version | ||
tc.variables["CMAKE_PROJECT_boost_decimal_INCLUDE"] = os.path.join( | ||
self.source_folder, "conan", "targets.cmake") | ||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
libdir = os.path.join(self.package_folder, "lib") | ||
|
||
copy(self, "include/*", self.source_folder, self.package_folder) | ||
|
||
copy(self, "LICENSE", self.source_folder, self.package_folder) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["boost_decimal"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find_package(Boost) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright 2024 Matt Borland | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# https://www.boost.org/LICENSE_1_0.txt | ||
|
||
if(APPLE) | ||
list(APPEND B2_OPTIONS cxxstd=14) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Matt Borland | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# https://www.boost.org/LICENSE_1_0.txt | ||
# | ||
# See: https://devblogs.microsoft.com/cppblog/registries-bring-your-own-libraries-to-vcpkg/ | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO cppalliance/decimal | ||
REF v1.0.0 | ||
SHA512 73043ea9514b747e519a5365ae57d9c1516d5f55784779d056d7db7266fd68328cd394e144db28125563c898b1d3acb6a4b47588ff319edefc84d35567a40b52 | ||
HEAD_REF master | ||
) | ||
|
||
file(COPY "${SOURCE_PATH}/include" DESTINATION "${CURRENT_PACKAGES_DIR}") | ||
file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "decimal", | ||
"version": "1.0.0", | ||
"description": "A C++14 implementation of IEEE 754 decimal floating point numbers", | ||
"homepage": "https://github.com/cppalliance/decimal", | ||
"dependencies": [ | ||
{ | ||
"name": "boost-vcpkg-helpers", | ||
"version>=": "1.81.0" | ||
}, | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
} | ||
] | ||
} |