2
2
from conan import ConanFile
3
3
from conan .tools .build import check_min_cppstd
4
4
from conan .tools .files import copy
5
- from conan .tools .cmake import CMakeToolchain , CMakeDeps , CMake
5
+ from conan .tools .cmake import CMakeToolchain , CMakeDeps , CMake , cmake_layout
6
+ from conan .tools .files import (
7
+ apply_conandata_patches , export_conandata_patches , get , copy
8
+ )
9
+ from conan .tools .scm import Version
6
10
7
11
8
12
class OpenDocumentCoreConan (ConanFile ):
9
13
name = "odrcore"
10
- version = ""
11
- url = ""
12
- homepage = "https://github.com/opendocument-app/OpenDocument.core"
14
+ url = "https://github.com/opendocument-app/OpenDocument.core"
15
+ homepage = "https://opendocument.app/"
13
16
description = "C++ library that translates office documents to HTML"
14
17
topics = "open document" , "openoffice xml" , "open document reader"
15
18
license = "GPL 3.0"
@@ -26,7 +29,24 @@ class OpenDocumentCoreConan(ConanFile):
26
29
27
30
exports_sources = ["cli/*" , "cmake/*" , "src/*" , "CMakeLists.txt" ]
28
31
32
+ def export_sources (self ):
33
+ export_conandata_patches (self )
34
+
35
+ def config_options (self ):
36
+ if self .settings .os == "Windows" :
37
+ del self .options .fPIC
38
+
39
+ def configure (self ):
40
+ if self .options .shared :
41
+ self .options .rm_safe ("fPIC" )
42
+
43
+ def layout (self ):
44
+ cmake_layout (self , src_folder = "src" )
45
+
29
46
def requirements (self ):
47
+ if Version (self .version ) <= "2.0.0" :
48
+ return
49
+
30
50
self .requires ("pugixml/1.14" )
31
51
self .requires ("cryptopp/8.8.0" )
32
52
self .requires ("miniz/3.0.2" )
@@ -36,23 +56,36 @@ def requirements(self):
36
56
self .requires ("utfcpp/4.0.4" )
37
57
38
58
def build_requirements (self ):
59
+ if Version (self .version ) <= "2.0.0" :
60
+ return
61
+
39
62
self .test_requires ("gtest/1.14.0" )
40
63
41
64
def validate_build (self ):
42
65
if self .settings .get_safe ("compiler.cppstd" ):
43
66
check_min_cppstd (self , 17 )
44
67
68
+ def source (self ):
69
+ get (self , ** self .conan_data ["sources" ][self .version ]["source" ], strip_root = True )
70
+
45
71
def generate (self ):
46
72
tc = CMakeToolchain (self )
47
73
tc .variables ["CMAKE_PROJECT_VERSION" ] = self .version
48
74
tc .variables ["BUILD_SHARED_LIBS" ] = self .options .shared
49
75
tc .variables ["ODR_TEST" ] = False
76
+ if Version (self .version ) < "4.0.0" :
77
+ tc .variables ["CONAN_EXPORTED" ] = True
50
78
tc .generate ()
51
79
52
80
deps = CMakeDeps (self )
53
81
deps .generate ()
54
82
83
+ def _patch_sources (self ):
84
+ apply_conandata_patches (self )
85
+
55
86
def build (self ):
87
+ self ._patch_sources ()
88
+
56
89
cmake = CMake (self )
57
90
cmake .configure ()
58
91
cmake .build ()
0 commit comments