-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathconanfile.py
More file actions
102 lines (88 loc) · 3.94 KB
/
Copy pathconanfile.py
File metadata and controls
102 lines (88 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
from conan import ConanFile
from conan.tools.files import copy, load, save
from conan.tools.layout import basic_layout
class LibfnConan(ConanFile):
name = "libfn"
license = "ISC"
author = "Bronek Kozicki, Alex Kremer, Gašper Ažman"
url = "https://github.com/libfn/functional"
homepage = "https://github.com/libfn/functional"
description = (
"Functional programming in C++"
)
topics = ("functional", "header-only", "monadic", "expected", "optional", "cpp23")
package_type = "header-library"
no_copy_source = True
# Settings are needed to read the consumer's compiler in package_info();
# package_id() clears them, so the package stays identical for everyone.
settings = "os", "arch", "compiler", "build_type"
exports = "VERSION"
exports_sources = "include/*", "LICENSE.md", "README.md"
def set_version(self):
self.version = load(self, os.path.join(self.recipe_folder, "VERSION")).strip()
def layout(self):
basic_layout(self)
def package_id(self):
# Intentional: header-only library, so the package is identical for every consumer.
self.info.clear()
def package(self):
copy(
self,
pattern="*.hpp",
src=os.path.join(self.source_folder, "include"),
dst=os.path.join(self.package_folder, "include"),
)
copy(
self,
pattern="LICENSE.md",
src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"),
)
# CMakeDeps synthesizes its own targets and drops the compile features the CMake
# export carries; this build module restores fn_cxx26's language requirement.
save(
self,
os.path.join(self.package_folder, "cmake", "libfn-cxx26.cmake"),
"if(TARGET libfn::fn_cxx26)\n"
" target_compile_features(libfn::fn_cxx26 INTERFACE cxx_std_26)\n"
"endif()\n",
)
def package_info(self):
# find_package(libfn) -> libfn::libfn aggregate target,
# plus libfn::fn, libfn::fn_cxx26 and libfn::pfn component targets.
self.cpp_info.set_property("cmake_file_name", "libfn")
self.cpp_info.set_property("cmake_target_name", "libfn::libfn")
self.cpp_info.set_property("cmake_build_modules", [os.path.join("cmake", "libfn-cxx26.cmake")])
# fn: the main component (headers under include/fn/); built on the pfn polyfills.
fn = self.cpp_info.components["fn"]
fn.set_property("cmake_target_name", "libfn::fn")
fn.bindirs = []
fn.libdirs = []
fn.includedirs = ["include"]
fn.requires = ["pfn"]
# pfn: the C++20 component (headers under include/pfn/).
pfn = self.cpp_info.components["pfn"]
pfn.set_property("cmake_target_name", "libfn::pfn")
pfn.bindirs = []
pfn.libdirs = []
pfn.includedirs = ["include"]
# fn_cxx26: fn with the C++26 mode selected; owns no headers.
# A consumer links exactly one of libfn::fn / libfn::fn_cxx26.
fn_cxx26 = self.cpp_info.components["fn_cxx26"]
fn_cxx26.set_property("cmake_target_name", "libfn::fn_cxx26")
fn_cxx26.bindirs = []
fn_cxx26.libdirs = []
fn_cxx26.includedirs = []
fn_cxx26.requires = ["fn"]
fn_cxx26.defines = ["LIBFN_CXX26"]
# CMakeDeps synthesizes its own targets, so the INTERFACE compile options
# exported by the CMake package do not reach conan consumers; mirror
# cmake/CompilationOptions.cmake (append_compilation_options INTERFACE) here.
compiler = self.settings.get_safe("compiler")
for component in (fn, pfn):
if compiler == "msvc":
component.cxxflags.append("/permissive-")
component.defines.append("_HAS_CXX23")
elif compiler in ("clang", "apple-clang"):
component.cxxflags.append("-Wno-missing-braces")