Skip to content

Commit 5231c6f

Browse files
committed
chaiscript header_only
1 parent 150b7ab commit 5231c6f

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

recipes/chaiscript/all/conanfile.py

+27-12
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ class ChaiScriptConan(ConanFile):
1212
exports_sources = ["CMakeLists.txt"]
1313
generators = "cmake"
1414
settings = "os", "compiler", "build_type", "arch"
15-
options = {"shared": [True, False], "fPIC": [True, False], "dyn_load": [True, False], "use_std_make_shared": [True, False],
16-
"multithread_support": [True, False]}
17-
default_options = {"shared": False, "fPIC": True, "dyn_load": True, "use_std_make_shared": True,
18-
"multithread_support": True}
15+
options = {"shared": [True, False], "fPIC": [True, False],
16+
"dyn_load": [True, False], "use_std_make_shared": [True, False],
17+
"multithread_support": [True, False],
18+
"header_only": [True, False]}
19+
default_options = {"shared": False, "fPIC": True, "dyn_load": True,
20+
"use_std_make_shared": True,
21+
"multithread_support": True,
22+
"header_only": True}
1923

2024
@property
2125
def _source_subfolder(self):
@@ -36,26 +40,37 @@ def config_options(self):
3640

3741
def _configure_cmake(self):
3842
cmake = CMake(self)
43+
cmake.definitions["BUILD_TESTING"] = False
44+
cmake.definitions["BUILD_SAMPLES"] = False
45+
cmake.definitions["BUILD_MODULES"] = True
3946
cmake.definitions["USE_STD_MAKE_SHARED"] = self.options.use_std_make_shared
4047
cmake.definitions["DYNLOAD_ENABLED"] = self.options.dyn_load
4148
cmake.definitions["MULTITHREAD_SUPPORT_ENABLED"] = self.options.multithread_support
4249
cmake.configure(build_folder=self._build_subfolder)
4350
return cmake
4451

4552
def build(self):
46-
cmake = self._configure_cmake()
47-
cmake.build()
53+
if not self.options.header_only:
54+
cmake = self._configure_cmake()
55+
cmake.build()
4856

4957
def package(self):
5058
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
51-
cmake = self._configure_cmake()
52-
cmake.install()
53-
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
54-
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
55-
tools.rmdir(os.path.join(self.package_folder, "share"))
59+
if self.options.header_only:
60+
self.copy(pattern="*.hpp", dst="include",
61+
src=os.path.join(self._source_subfolder, 'include'))
62+
else:
63+
cmake = self._configure_cmake()
64+
cmake.install()
65+
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
66+
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
67+
tools.rmdir(os.path.join(self.package_folder, "share"))
5668

5769
def package_info(self):
58-
self.cpp_info.libs = tools.collect_libs(self)
70+
if self.options.header_only:
71+
self.info.header_only()
72+
else:
73+
self.cpp_info.libs = tools.collect_libs(self)
5974
if self.options.use_std_make_shared:
6075
self.cpp_info.defines.append("CHAISCRIPT_USE_STD_MAKE_SHARED")
6176
if self.settings.os == "Linux":

0 commit comments

Comments
 (0)