@@ -12,10 +12,14 @@ class ChaiScriptConan(ConanFile):
12
12
exports_sources = ["CMakeLists.txt" ]
13
13
generators = "cmake"
14
14
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 }
19
23
20
24
@property
21
25
def _source_subfolder (self ):
@@ -36,26 +40,37 @@ def config_options(self):
36
40
37
41
def _configure_cmake (self ):
38
42
cmake = CMake (self )
43
+ cmake .definitions ["BUILD_TESTING" ] = False
44
+ cmake .definitions ["BUILD_SAMPLES" ] = False
45
+ cmake .definitions ["BUILD_MODULES" ] = True
39
46
cmake .definitions ["USE_STD_MAKE_SHARED" ] = self .options .use_std_make_shared
40
47
cmake .definitions ["DYNLOAD_ENABLED" ] = self .options .dyn_load
41
48
cmake .definitions ["MULTITHREAD_SUPPORT_ENABLED" ] = self .options .multithread_support
42
49
cmake .configure (build_folder = self ._build_subfolder )
43
50
return cmake
44
51
45
52
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 ()
48
56
49
57
def package (self ):
50
58
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" ))
56
68
57
69
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 )
59
74
if self .options .use_std_make_shared :
60
75
self .cpp_info .defines .append ("CHAISCRIPT_USE_STD_MAKE_SHARED" )
61
76
if self .settings .os == "Linux" :
0 commit comments