Line 0
Link Here
|
|
|
1 |
--- cmake-proxies/cmake-modules/AudacityDependencies.cmake.orig 2021-08-27 22:30:37 UTC |
2 |
+++ cmake-proxies/cmake-modules/AudacityDependencies.cmake |
3 |
@@ -1,11 +1,14 @@ |
4 |
# Load Conan |
5 |
-include( conan ) |
6 |
|
7 |
-conan_add_remote(NAME audacity |
8 |
- URL https://artifactory.audacityteam.org/artifactory/api/conan/conan-local |
9 |
- VERIFY_SSL True |
10 |
-) |
11 |
+if( ${_OPT}conan_enabled ) |
12 |
+ include( conan ) |
13 |
|
14 |
+ conan_add_remote(NAME audacity |
15 |
+ URL https://artifactory.audacityteam.org/artifactory/api/conan/conan-local |
16 |
+ VERIFY_SSL True |
17 |
+ ) |
18 |
+endif() |
19 |
+ |
20 |
set( CONAN_BUILD_REQUIRES ) |
21 |
set( CONAN_REQUIRES ) |
22 |
set( CONAN_PACKAGE_OPTIONS ) |
23 |
@@ -13,24 +16,30 @@ set( CONAN_ONLY_DEBUG_RELEASE ) |
24 |
set( CONAN_CONFIG_OPTIONS ) |
25 |
set( CONAN_RESOLVE_LIST ) |
26 |
|
27 |
-# Add a Conan dependency |
28 |
-# Example usage: |
29 |
-# add_conan_lib( |
30 |
-# wxWdidget |
31 |
-# wxwidgets/3.1.3-audacity |
32 |
-# OPTION_NAME wxwidgets |
33 |
-# SYMBOL WXWIDGET |
34 |
-# REQUIRED |
35 |
-# ALWAYS_ALLOW_CONAN_FALLBACK |
36 |
-# PKG_CONFIG "wxwidgets >= 3.1.3" |
37 |
-# FIND_PACKAGE_OPTIONS COMPONENTS adv base core html qa xml |
38 |
-# INTERFACE_NAME wxwidgets::wxwidgets |
39 |
-# HAS_ONLY_DEBUG_RELEASE |
40 |
-# CONAN_OPTIONS |
41 |
-# wxwidgets:shared=True |
42 |
-# ) |
43 |
+#[[ |
44 |
+Add a Conan dependency |
45 |
|
46 |
+Example usage: |
47 |
|
48 |
+add_conan_lib( |
49 |
+ wxWdidget |
50 |
+ wxwidgets/3.1.3-audacity |
51 |
+ OPTION_NAME wxwidgets |
52 |
+ SYMBOL WXWIDGET |
53 |
+ REQUIRED |
54 |
+ ALWAYS_ALLOW_CONAN_FALLBACK |
55 |
+ PKG_CONFIG "wxwidgets >= 3.1.3" |
56 |
+ FIND_PACKAGE_OPTIONS COMPONENTS adv base core html qa xml |
57 |
+ INTERFACE_NAME wxwidgets::wxwidgets |
58 |
+ HAS_ONLY_DEBUG_RELEASE |
59 |
+ CONAN_OPTIONS |
60 |
+ wxwidgets:shared=True |
61 |
+) |
62 |
+ |
63 |
+PKG_CONFIG accepts a list of possible package configurations. |
64 |
+add_conan_lib will iterate over it one by one until the library is found. |
65 |
+]] |
66 |
+ |
67 |
function (add_conan_lib package conan_package_name ) |
68 |
# Extract the list of packages from the function args |
69 |
list( SUBLIST ARGV 2 -1 options ) |
70 |
@@ -54,6 +63,8 @@ function (add_conan_lib package conan_package_name ) |
71 |
set( list_mode on ) |
72 |
set( allow_find_package on ) |
73 |
set( current_var "find_package_options" ) |
74 |
+ elseif ( opt STREQUAL "ALLOW_FIND_PACKAGE" ) |
75 |
+ set ( allow_find_package on ) |
76 |
elseif ( opt STREQUAL "CONAN_OPTIONS" ) |
77 |
set( list_mode on ) |
78 |
set( current_var "conan_package_options" ) |
79 |
@@ -93,14 +104,23 @@ function (add_conan_lib package conan_package_name ) |
80 |
|
81 |
set( option_desc "local" ) |
82 |
|
83 |
- if( pkg_config_options OR allow_find_package ) |
84 |
+ if( pkg_config_options OR allow_find_package OR NOT ${_OPT}conan_enabled ) |
85 |
set( sysopt "system" ) |
86 |
string( PREPEND option_desc "system (if available), " ) |
87 |
- set( default "${${_OPT}lib_preference}" ) |
88 |
+ |
89 |
+ if( ${_OPT}conan_enabled ) |
90 |
+ set( default "${${_OPT}lib_preference}" ) |
91 |
+ else() |
92 |
+ set( default "system" ) |
93 |
+ endif() |
94 |
else() |
95 |
set( default "local" ) |
96 |
endif() |
97 |
|
98 |
+ if( ${_OPT}conan_enabled ) |
99 |
+ set( localopt "local" ) |
100 |
+ endif() |
101 |
+ |
102 |
if( NOT required ) |
103 |
set( reqopt "off" ) |
104 |
string( APPEND option_desc ", off" ) |
105 |
@@ -109,7 +129,7 @@ function (add_conan_lib package conan_package_name ) |
106 |
cmd_option( ${option_name} |
107 |
"Use ${option_name_base} library [${option_desc}]" |
108 |
"${default}" |
109 |
- STRINGS ${sysopt} "local" ${reqopt} |
110 |
+ STRINGS ${sysopt} ${localopt} ${reqopt} |
111 |
) |
112 |
|
113 |
# Early bail out |
114 |
@@ -129,26 +149,28 @@ function (add_conan_lib package conan_package_name ) |
115 |
return() |
116 |
endif() |
117 |
|
118 |
- if( ${option_name} STREQUAL "system" ) |
119 |
+ if( ${option_name} STREQUAL "system" OR NOT ${_OPT}conan_enabled ) |
120 |
if( pkg_config_options ) |
121 |
- pkg_check_modules( PKG_${package} ${pkg_config_options} ) |
122 |
+ foreach(variant ${pkg_config_options}) |
123 |
+ pkg_check_modules( PKG_${package} ${variant} ) |
124 |
|
125 |
- if( PKG_${package}_FOUND ) |
126 |
- message( STATUS "Using '${package}' system library" ) |
127 |
- |
128 |
- # Create the target interface library |
129 |
- add_library( ${interface_name} INTERFACE IMPORTED GLOBAL) |
130 |
+ if( PKG_${package}_FOUND ) |
131 |
+ message( STATUS "Using '${package}' system library" ) |
132 |
|
133 |
- # Retrieve the package information |
134 |
- get_package_interface( PKG_${package} ) |
135 |
- |
136 |
- # And add it to our target |
137 |
- target_include_directories( ${interface_name} INTERFACE ${INCLUDES} ) |
138 |
- target_link_libraries( ${interface_name} INTERFACE ${LIBRARIES} ) |
139 |
+ # Create the target interface library |
140 |
+ add_library( ${interface_name} INTERFACE IMPORTED GLOBAL) |
141 |
+ |
142 |
+ # Retrieve the package information |
143 |
+ get_package_interface( PKG_${package} ) |
144 |
+ |
145 |
+ # And add it to our target |
146 |
+ target_include_directories( ${interface_name} INTERFACE ${INCLUDES} ) |
147 |
+ target_link_libraries( ${interface_name} INTERFACE ${LIBRARIES} ) |
148 |
|
149 |
- message(STATUS "Added inteface ${interface_name} ${INCLUDES} ${LIBRARIES}") |
150 |
- return() |
151 |
- endif() |
152 |
+ message(STATUS "Added inteface ${interface_name} ${INCLUDES} ${LIBRARIES}") |
153 |
+ return() |
154 |
+ endif() |
155 |
+ endforeach() |
156 |
endif() |
157 |
|
158 |
if( allow_find_package ) |
159 |
@@ -160,7 +182,7 @@ function (add_conan_lib package conan_package_name ) |
160 |
endif() |
161 |
endif() |
162 |
|
163 |
- if( system_only ) |
164 |
+ if( system_only OR NOT ${_OPT}conan_enabled ) |
165 |
message( FATAL_ERROR "Failed to find the system package ${package}" ) |
166 |
else() |
167 |
set( ${option_name} "local" ) |
168 |
@@ -237,34 +259,36 @@ function ( _conan_install build_type ) |
169 |
endfunction() |
170 |
|
171 |
macro( resolve_conan_dependencies ) |
172 |
- message(STATUS |
173 |
- "Executing Conan: \ |
174 |
- REQUIRES ${CONAN_REQUIRES} |
175 |
- GENERATORS cmake_find_package_multi |
176 |
- BUILD_REQUIRES ${CONAN_BUILD_REQUIRES} |
177 |
- ${CONAN_CONFIG_OPTIONS} |
178 |
- OPTIONS ${CONAN_PACKAGE_OPTIONS} |
179 |
- ") |
180 |
+ if( ${_OPT}conan_enabled ) |
181 |
+ message(STATUS |
182 |
+ "Executing Conan: \ |
183 |
+ REQUIRES ${CONAN_REQUIRES} |
184 |
+ GENERATORS cmake_find_package_multi |
185 |
+ BUILD_REQUIRES ${CONAN_BUILD_REQUIRES} |
186 |
+ ${CONAN_CONFIG_OPTIONS} |
187 |
+ OPTIONS ${CONAN_PACKAGE_OPTIONS} |
188 |
+ ") |
189 |
|
190 |
- if(MSVC OR XCODE) |
191 |
- foreach(TYPE ${CMAKE_CONFIGURATION_TYPES}) |
192 |
- _conan_install(${TYPE}) |
193 |
- endforeach() |
194 |
- else() |
195 |
- _conan_install(${CMAKE_BUILD_TYPE}) |
196 |
- endif() |
197 |
+ if(MSVC OR XCODE) |
198 |
+ foreach(TYPE ${CMAKE_CONFIGURATION_TYPES}) |
199 |
+ _conan_install(${TYPE}) |
200 |
+ endforeach() |
201 |
+ else() |
202 |
+ _conan_install(${CMAKE_BUILD_TYPE}) |
203 |
+ endif() |
204 |
|
205 |
- list( REMOVE_DUPLICATES CONAN_REQUIRES ) |
206 |
+ list( REMOVE_DUPLICATES CONAN_REQUIRES ) |
207 |
|
208 |
- foreach( package ${CONAN_RESOLVE_LIST} ) |
209 |
- message(STATUS "Resolving Conan library ${package}") |
210 |
+ foreach( package ${CONAN_RESOLVE_LIST} ) |
211 |
+ message(STATUS "Resolving Conan library ${package}") |
212 |
|
213 |
- find_package(${package} CONFIG) |
214 |
+ find_package(${package} CONFIG) |
215 |
|
216 |
- if (NOT ${package}_FOUND) |
217 |
- message( FATAL_ERROR "Failed to find the conan package ${package}" ) |
218 |
- endif() |
219 |
- endforeach() |
220 |
+ if (NOT ${package}_FOUND) |
221 |
+ message( FATAL_ERROR "Failed to find the conan package ${package}" ) |
222 |
+ endif() |
223 |
+ endforeach() |
224 |
+ endif() |
225 |
|
226 |
file(GLOB dependency_helpers "${AUDACITY_MODULE_PATH}/dependencies/*.cmake") |
227 |
|