1
1
from conan import ConanFile
2
+ from conan .errors import ConanInvalidConfiguration
2
3
from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout
3
4
from conan .tools .files import apply_conandata_patches , copy , export_conandata_patches , get , rmdir
4
- from conan .tools .microsoft import check_min_vs
5
+ from conan .tools .microsoft import check_min_vs , is_msvc , is_msvc_static_runtime
6
+ from conan .tools .env import VirtualBuildEnv
7
+ from conan .tools .scm import Version
5
8
import os
6
9
7
10
required_conan_version = ">=1.53.0"
@@ -14,7 +17,7 @@ class OpusConan(ConanFile):
14
17
url = "https://github.com/conan-io/conan-center-index"
15
18
homepage = "https://opus-codec.org"
16
19
license = "BSD-3-Clause"
17
-
20
+ package_type = "library"
18
21
settings = "os" , "arch" , "compiler" , "build_type"
19
22
options = {
20
23
"shared" : [True , False ],
@@ -29,6 +32,10 @@ class OpusConan(ConanFile):
29
32
"stack_protector" : True ,
30
33
}
31
34
35
+ def build_requirements (self ):
36
+ if Version (self .version ) >= "1.5.2" :
37
+ self .tool_requires ("cmake/[>=3.16 <4]" )
38
+
32
39
def export_sources (self ):
33
40
export_conandata_patches (self )
34
41
@@ -47,15 +54,23 @@ def layout(self):
47
54
48
55
def validate (self ):
49
56
check_min_vs (self , 190 )
57
+ if Version (self .version ) >= "1.5.2" and self .settings .compiler == "gcc" and Version (self .settings .compiler .version ) < "8" :
58
+ raise ConanInvalidConfiguration (f"{ self .ref } GCC-{ self .settings .compiler .version } not supported due to lack of AVX2 support. Use GCC >=8." )
50
59
51
60
def source (self ):
52
61
get (self , ** self .conan_data ["sources" ][self .version ],
53
62
destination = self .source_folder , strip_root = True )
54
63
55
64
def generate (self ):
65
+ if Version (self .version ) >= "1.5.2" :
66
+ env = VirtualBuildEnv (self )
67
+ env .generate ()
56
68
tc = CMakeToolchain (self )
57
- tc .variables ["OPUS_FIXED_POINT" ] = self .options .fixed_point
58
- tc .variables ["OPUS_STACK_PROTECTOR" ] = self .options .stack_protector
69
+ tc .cache_variables ["OPUS_BUILD_SHARED_LIBRARY" ] = self .options .shared
70
+ tc .cache_variables ["OPUS_FIXED_POINT" ] = self .options .fixed_point
71
+ tc .cache_variables ["OPUS_STACK_PROTECTOR" ] = self .options .stack_protector
72
+ if Version (self .version ) >= "1.5.2" and is_msvc (self ):
73
+ tc .cache_variables ["OPUS_STATIC_RUNTIME" ] = is_msvc_static_runtime (self )
59
74
tc .generate ()
60
75
61
76
def build (self ):
0 commit comments