|
ferencd@0
|
1 # The MIT License (MIT)
|
|
ferencd@0
|
2
|
|
ferencd@0
|
3 # Copyright (c) 2018 JFrog
|
|
ferencd@0
|
4
|
|
ferencd@0
|
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
ferencd@0
|
6 # of this software and associated documentation files (the "Software"), to deal
|
|
ferencd@0
|
7 # in the Software without restriction, including without limitation the rights
|
|
ferencd@0
|
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
ferencd@0
|
9 # copies of the Software, and to permit persons to whom the Software is
|
|
ferencd@0
|
10 # furnished to do so, subject to the following conditions:
|
|
ferencd@0
|
11
|
|
ferencd@0
|
12 # The above copyright notice and this permission notice shall be included in all
|
|
ferencd@0
|
13 # copies or substantial portions of the Software.
|
|
ferencd@0
|
14
|
|
ferencd@0
|
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
ferencd@0
|
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
ferencd@0
|
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
ferencd@0
|
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
ferencd@0
|
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
ferencd@0
|
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
ferencd@0
|
21 # SOFTWARE.
|
|
ferencd@0
|
22
|
|
ferencd@0
|
23
|
|
ferencd@0
|
24
|
|
ferencd@0
|
25 # This file comes from: https://github.com/conan-io/cmake-conan. Please refer
|
|
ferencd@0
|
26 # to this repository for issues and documentation.
|
|
ferencd@0
|
27
|
|
ferencd@0
|
28 # Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called.
|
|
ferencd@0
|
29 # It will take CMake current settings (os, compiler, compiler version, architecture)
|
|
ferencd@0
|
30 # and translate them to conan settings for installing and retrieving dependencies.
|
|
ferencd@0
|
31
|
|
ferencd@0
|
32 # It is intended to facilitate developers building projects that have conan dependencies,
|
|
ferencd@0
|
33 # but it is only necessary on the end-user side. It is not necessary to create conan
|
|
ferencd@0
|
34 # packages, in fact it shouldn't be use for that. Check the project documentation.
|
|
ferencd@0
|
35
|
|
ferencd@0
|
36
|
|
ferencd@0
|
37 include(CMakeParseArguments)
|
|
ferencd@0
|
38
|
|
ferencd@0
|
39 function(_get_msvc_ide_version result)
|
|
ferencd@0
|
40 set(${result} "" PARENT_SCOPE)
|
|
ferencd@0
|
41 if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500)
|
|
ferencd@0
|
42 set(${result} 8 PARENT_SCOPE)
|
|
ferencd@0
|
43 elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600)
|
|
ferencd@0
|
44 set(${result} 9 PARENT_SCOPE)
|
|
ferencd@0
|
45 elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700)
|
|
ferencd@0
|
46 set(${result} 10 PARENT_SCOPE)
|
|
ferencd@0
|
47 elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800)
|
|
ferencd@0
|
48 set(${result} 11 PARENT_SCOPE)
|
|
ferencd@0
|
49 elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900)
|
|
ferencd@0
|
50 set(${result} 12 PARENT_SCOPE)
|
|
ferencd@0
|
51 elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910)
|
|
ferencd@0
|
52 set(${result} 14 PARENT_SCOPE)
|
|
ferencd@0
|
53 elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920)
|
|
ferencd@0
|
54 set(${result} 15 PARENT_SCOPE)
|
|
ferencd@0
|
55 elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930)
|
|
ferencd@0
|
56 set(${result} 16 PARENT_SCOPE)
|
|
ferencd@0
|
57 else()
|
|
ferencd@0
|
58 message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]")
|
|
ferencd@0
|
59 endif()
|
|
ferencd@0
|
60 endfunction()
|
|
ferencd@0
|
61
|
|
ferencd@0
|
62 function(conan_cmake_settings result)
|
|
ferencd@0
|
63 #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
|
|
ferencd@0
|
64 #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
|
|
ferencd@0
|
65 #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
|
|
ferencd@0
|
66 #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
|
|
ferencd@0
|
67 #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
|
|
ferencd@0
|
68 #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
|
|
ferencd@0
|
69 #message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
|
|
ferencd@0
|
70 #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})
|
|
ferencd@0
|
71
|
|
ferencd@0
|
72 message(STATUS "Conan: Automatic detection of conan settings from cmake")
|
|
ferencd@0
|
73
|
|
ferencd@0
|
74 parse_arguments(${ARGV})
|
|
ferencd@0
|
75
|
|
ferencd@0
|
76 if(ARGUMENTS_BUILD_TYPE)
|
|
ferencd@0
|
77 set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE})
|
|
ferencd@0
|
78 elseif(CMAKE_BUILD_TYPE)
|
|
ferencd@0
|
79 set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE})
|
|
ferencd@0
|
80 else()
|
|
ferencd@0
|
81 message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
|
|
ferencd@0
|
82 endif()
|
|
ferencd@0
|
83
|
|
ferencd@0
|
84 string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER)
|
|
ferencd@0
|
85 if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG")
|
|
ferencd@0
|
86 set(_CONAN_SETTING_BUILD_TYPE "Debug")
|
|
ferencd@0
|
87 elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE")
|
|
ferencd@0
|
88 set(_CONAN_SETTING_BUILD_TYPE "Release")
|
|
ferencd@0
|
89 elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO")
|
|
ferencd@0
|
90 set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo")
|
|
ferencd@0
|
91 elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL")
|
|
ferencd@0
|
92 set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel")
|
|
ferencd@0
|
93 endif()
|
|
ferencd@0
|
94
|
|
ferencd@0
|
95 if(ARGUMENTS_ARCH)
|
|
ferencd@0
|
96 set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
|
|
ferencd@0
|
97 endif()
|
|
ferencd@0
|
98 #handle -s os setting
|
|
ferencd@0
|
99 if(CMAKE_SYSTEM_NAME)
|
|
ferencd@0
|
100 #use default conan os setting if CMAKE_SYSTEM_NAME is not defined
|
|
ferencd@0
|
101 set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
|
|
ferencd@0
|
102 if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
|
ferencd@0
|
103 set(CONAN_SYSTEM_NAME Macos)
|
|
ferencd@0
|
104 endif()
|
|
ferencd@0
|
105 set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore)
|
|
ferencd@0
|
106 list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index)
|
|
ferencd@0
|
107 if (${_index} GREATER -1)
|
|
ferencd@0
|
108 #check if the cmake system is a conan supported one
|
|
ferencd@0
|
109 set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME})
|
|
ferencd@0
|
110 else()
|
|
ferencd@0
|
111 message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}")
|
|
ferencd@0
|
112 endif()
|
|
ferencd@0
|
113 endif()
|
|
ferencd@0
|
114
|
|
ferencd@0
|
115 get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
|
ferencd@0
|
116 if (";${_languages};" MATCHES ";CXX;")
|
|
ferencd@0
|
117 set(LANGUAGE CXX)
|
|
ferencd@0
|
118 set(USING_CXX 1)
|
|
ferencd@0
|
119 elseif (";${_languages};" MATCHES ";C;")
|
|
ferencd@0
|
120 set(LANGUAGE C)
|
|
ferencd@0
|
121 set(USING_CXX 0)
|
|
ferencd@0
|
122 else ()
|
|
ferencd@0
|
123 message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.")
|
|
ferencd@0
|
124 endif()
|
|
ferencd@0
|
125
|
|
ferencd@0
|
126 if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU)
|
|
ferencd@0
|
127 # using GCC
|
|
ferencd@0
|
128 # TODO: Handle other params
|
|
ferencd@0
|
129 string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
|
|
ferencd@0
|
130 list(GET VERSION_LIST 0 MAJOR)
|
|
ferencd@0
|
131 list(GET VERSION_LIST 1 MINOR)
|
|
ferencd@0
|
132 set(COMPILER_VERSION ${MAJOR}.${MINOR})
|
|
ferencd@0
|
133 if(${MAJOR} GREATER 4)
|
|
ferencd@0
|
134 set(COMPILER_VERSION ${MAJOR})
|
|
ferencd@0
|
135 endif()
|
|
ferencd@0
|
136 set(_CONAN_SETTING_COMPILER gcc)
|
|
ferencd@0
|
137 set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})
|
|
ferencd@0
|
138 if (USING_CXX)
|
|
ferencd@0
|
139 conan_cmake_detect_unix_libcxx(_LIBCXX)
|
|
ferencd@0
|
140 set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
|
|
ferencd@0
|
141 endif ()
|
|
ferencd@0
|
142 elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang)
|
|
ferencd@0
|
143 # using AppleClang
|
|
ferencd@0
|
144 string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
|
|
ferencd@0
|
145 list(GET VERSION_LIST 0 MAJOR)
|
|
ferencd@0
|
146 list(GET VERSION_LIST 1 MINOR)
|
|
ferencd@0
|
147 set(_CONAN_SETTING_COMPILER apple-clang)
|
|
ferencd@0
|
148 set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR})
|
|
ferencd@0
|
149 if (USING_CXX)
|
|
ferencd@0
|
150 conan_cmake_detect_unix_libcxx(_LIBCXX)
|
|
ferencd@0
|
151 set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
|
|
ferencd@0
|
152 endif ()
|
|
ferencd@0
|
153 elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang)
|
|
ferencd@0
|
154 string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
|
|
ferencd@0
|
155 list(GET VERSION_LIST 0 MAJOR)
|
|
ferencd@0
|
156 list(GET VERSION_LIST 1 MINOR)
|
|
ferencd@0
|
157 set(_CONAN_SETTING_COMPILER clang)
|
|
ferencd@0
|
158 set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR})
|
|
ferencd@0
|
159 if(APPLE)
|
|
ferencd@0
|
160 cmake_policy(GET CMP0025 APPLE_CLANG_POLICY_ENABLED)
|
|
ferencd@0
|
161 if(NOT APPLE_CLANG_POLICY_ENABLED)
|
|
ferencd@0
|
162 message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it")
|
|
ferencd@0
|
163 set(_CONAN_SETTING_COMPILER apple-clang)
|
|
ferencd@0
|
164 endif()
|
|
ferencd@0
|
165 endif()
|
|
ferencd@0
|
166 if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7)
|
|
ferencd@0
|
167 set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR})
|
|
ferencd@0
|
168 endif()
|
|
ferencd@0
|
169 if (USING_CXX)
|
|
ferencd@0
|
170 conan_cmake_detect_unix_libcxx(_LIBCXX)
|
|
ferencd@0
|
171 set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
|
|
ferencd@0
|
172 endif ()
|
|
ferencd@0
|
173 elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC)
|
|
ferencd@0
|
174 set(_VISUAL "Visual Studio")
|
|
ferencd@0
|
175 _get_msvc_ide_version(_VISUAL_VERSION)
|
|
ferencd@0
|
176 if("${_VISUAL_VERSION}" STREQUAL "")
|
|
ferencd@0
|
177 message(FATAL_ERROR "Conan: Visual Studio not recognized")
|
|
ferencd@0
|
178 else()
|
|
ferencd@0
|
179 set(_CONAN_SETTING_COMPILER ${_VISUAL})
|
|
ferencd@0
|
180 set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION})
|
|
ferencd@0
|
181 endif()
|
|
ferencd@0
|
182
|
|
ferencd@0
|
183 if(NOT _CONAN_SETTING_ARCH)
|
|
ferencd@0
|
184 if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64")
|
|
ferencd@0
|
185 set(_CONAN_SETTING_ARCH x86_64)
|
|
ferencd@0
|
186 elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM")
|
|
ferencd@0
|
187 message(STATUS "Conan: Using default ARM architecture from MSVC")
|
|
ferencd@0
|
188 set(_CONAN_SETTING_ARCH armv6)
|
|
ferencd@0
|
189 elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86")
|
|
ferencd@0
|
190 set(_CONAN_SETTING_ARCH x86)
|
|
ferencd@0
|
191 else ()
|
|
ferencd@0
|
192 message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]")
|
|
ferencd@0
|
193 endif()
|
|
ferencd@0
|
194 endif()
|
|
ferencd@0
|
195
|
|
ferencd@0
|
196 conan_cmake_detect_vs_runtime(_vs_runtime)
|
|
ferencd@0
|
197 message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}")
|
|
ferencd@0
|
198 set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime})
|
|
ferencd@0
|
199
|
|
ferencd@0
|
200 if (CMAKE_GENERATOR_TOOLSET)
|
|
ferencd@0
|
201 set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET})
|
|
ferencd@0
|
202 elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja"))
|
|
ferencd@0
|
203 set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET})
|
|
ferencd@0
|
204 endif()
|
|
ferencd@0
|
205 else()
|
|
ferencd@0
|
206 message(FATAL_ERROR "Conan: compiler setup not recognized")
|
|
ferencd@0
|
207 endif()
|
|
ferencd@0
|
208
|
|
ferencd@0
|
209 # If profile is defined it is used
|
|
ferencd@0
|
210 if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE)
|
|
ferencd@0
|
211 set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE})
|
|
ferencd@0
|
212 elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE)
|
|
ferencd@0
|
213 set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE})
|
|
ferencd@0
|
214 elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE)
|
|
ferencd@0
|
215 set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE})
|
|
ferencd@0
|
216 elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE)
|
|
ferencd@0
|
217 set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE})
|
|
ferencd@0
|
218 elseif(ARGUMENTS_PROFILE)
|
|
ferencd@0
|
219 set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE})
|
|
ferencd@0
|
220 endif()
|
|
ferencd@0
|
221
|
|
ferencd@0
|
222 foreach(ARG ${_APPLIED_PROFILES})
|
|
ferencd@0
|
223 set(_SETTINGS ${_SETTINGS} -pr ${ARG})
|
|
ferencd@0
|
224 endforeach()
|
|
ferencd@0
|
225
|
|
ferencd@0
|
226 if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL")
|
|
ferencd@0
|
227 set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version
|
|
ferencd@0
|
228 compiler.runtime compiler.libcxx compiler.toolset)
|
|
ferencd@0
|
229 endif()
|
|
ferencd@0
|
230
|
|
ferencd@0
|
231 # Automatic from CMake
|
|
ferencd@0
|
232 foreach(ARG ${ARGUMENTS_PROFILE_AUTO})
|
|
ferencd@0
|
233 string(TOUPPER ${ARG} _arg_name)
|
|
ferencd@0
|
234 string(REPLACE "." "_" _arg_name ${_arg_name})
|
|
ferencd@0
|
235 if(_CONAN_SETTING_${_arg_name})
|
|
ferencd@0
|
236 set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}})
|
|
ferencd@0
|
237 endif()
|
|
ferencd@0
|
238 endforeach()
|
|
ferencd@0
|
239
|
|
ferencd@0
|
240 foreach(ARG ${ARGUMENTS_SETTINGS})
|
|
ferencd@0
|
241 set(_SETTINGS ${_SETTINGS} -s ${ARG})
|
|
ferencd@0
|
242 endforeach()
|
|
ferencd@0
|
243
|
|
ferencd@0
|
244 message(STATUS "Conan: Settings= ${_SETTINGS}")
|
|
ferencd@0
|
245
|
|
ferencd@0
|
246 set(${result} ${_SETTINGS} PARENT_SCOPE)
|
|
ferencd@0
|
247 endfunction()
|
|
ferencd@0
|
248
|
|
ferencd@0
|
249
|
|
ferencd@0
|
250 function(conan_cmake_detect_unix_libcxx result)
|
|
ferencd@0
|
251 # Take into account any -stdlib in compile options
|
|
ferencd@0
|
252 get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS)
|
|
ferencd@0
|
253
|
|
ferencd@0
|
254 # Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions
|
|
ferencd@0
|
255 get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
|
ferencd@0
|
256 foreach(define ${defines})
|
|
ferencd@0
|
257 if(define MATCHES "_GLIBCXX_USE_CXX11_ABI")
|
|
ferencd@0
|
258 if(define MATCHES "^-D")
|
|
ferencd@0
|
259 set(compile_options ${compile_options} "${define}")
|
|
ferencd@0
|
260 else()
|
|
ferencd@0
|
261 set(compile_options ${compile_options} "-D${define}")
|
|
ferencd@0
|
262 endif()
|
|
ferencd@0
|
263 endif()
|
|
ferencd@0
|
264 endforeach()
|
|
ferencd@0
|
265
|
|
ferencd@0
|
266 execute_process(
|
|
ferencd@0
|
267 COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
|
|
ferencd@0
|
268 COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM -
|
|
ferencd@0
|
269 OUTPUT_VARIABLE string_defines
|
|
ferencd@0
|
270 )
|
|
ferencd@0
|
271
|
|
ferencd@0
|
272 if(string_defines MATCHES "#define __GLIBCXX__")
|
|
ferencd@0
|
273 # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake
|
|
ferencd@0
|
274 if(DEFINED _GLIBCXX_USE_CXX11_ABI)
|
|
ferencd@0
|
275 if(_GLIBCXX_USE_CXX11_ABI)
|
|
ferencd@0
|
276 set(${result} libstdc++11 PARENT_SCOPE)
|
|
ferencd@0
|
277 return()
|
|
ferencd@0
|
278 else()
|
|
ferencd@0
|
279 set(${result} libstdc++ PARENT_SCOPE)
|
|
ferencd@0
|
280 return()
|
|
ferencd@0
|
281 endif()
|
|
ferencd@0
|
282 endif()
|
|
ferencd@0
|
283
|
|
ferencd@0
|
284 if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n")
|
|
ferencd@0
|
285 set(${result} libstdc++11 PARENT_SCOPE)
|
|
ferencd@0
|
286 else()
|
|
ferencd@0
|
287 # Either the compiler is missing the define because it is old, and so
|
|
ferencd@0
|
288 # it can't use the new abi, or the compiler was configured to use the
|
|
ferencd@0
|
289 # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS)
|
|
ferencd@0
|
290 set(${result} libstdc++ PARENT_SCOPE)
|
|
ferencd@0
|
291 endif()
|
|
ferencd@0
|
292 else()
|
|
ferencd@0
|
293 set(${result} libc++ PARENT_SCOPE)
|
|
ferencd@0
|
294 endif()
|
|
ferencd@0
|
295 endfunction()
|
|
ferencd@0
|
296
|
|
ferencd@0
|
297 function(conan_cmake_detect_vs_runtime result)
|
|
ferencd@0
|
298 string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
|
|
ferencd@0
|
299 set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
|
|
ferencd@0
|
300 foreach(variable ${variables})
|
|
ferencd@0
|
301 string(REPLACE " " ";" flags ${${variable}})
|
|
ferencd@0
|
302 foreach (flag ${flags})
|
|
ferencd@0
|
303 if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd")
|
|
ferencd@0
|
304 string(SUBSTRING ${flag} 1 -1 runtime)
|
|
ferencd@0
|
305 set(${result} ${runtime} PARENT_SCOPE)
|
|
ferencd@0
|
306 return()
|
|
ferencd@0
|
307 endif()
|
|
ferencd@0
|
308 endforeach()
|
|
ferencd@0
|
309 endforeach()
|
|
ferencd@0
|
310 if(${build_type} STREQUAL "DEBUG")
|
|
ferencd@0
|
311 set(${result} "MDd" PARENT_SCOPE)
|
|
ferencd@0
|
312 else()
|
|
ferencd@0
|
313 set(${result} "MD" PARENT_SCOPE)
|
|
ferencd@0
|
314 endif()
|
|
ferencd@0
|
315 endfunction()
|
|
ferencd@0
|
316
|
|
ferencd@0
|
317
|
|
ferencd@0
|
318 macro(parse_arguments)
|
|
ferencd@0
|
319 set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS)
|
|
ferencd@0
|
320 set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND)
|
|
ferencd@0
|
321 set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE
|
|
ferencd@0
|
322 PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO
|
|
ferencd@0
|
323 INSTALL_ARGS)
|
|
ferencd@0
|
324 cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
ferencd@0
|
325 endmacro()
|
|
ferencd@0
|
326
|
|
ferencd@0
|
327 function(conan_cmake_install)
|
|
ferencd@0
|
328 # Calls "conan install"
|
|
ferencd@0
|
329 # Argument BUILD is equivalant to --build={missing, PkgName,...} or
|
|
ferencd@0
|
330 # --build when argument is 'BUILD all' (which builds all packages from source)
|
|
ferencd@0
|
331 # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source
|
|
ferencd@0
|
332 # cmake does not identify conan as command, even if it is +x and it is in the path
|
|
ferencd@0
|
333 parse_arguments(${ARGV})
|
|
ferencd@0
|
334
|
|
ferencd@0
|
335 if(CONAN_CMAKE_MULTI)
|
|
ferencd@0
|
336 set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi)
|
|
ferencd@0
|
337 else()
|
|
ferencd@0
|
338 set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake)
|
|
ferencd@0
|
339 endif()
|
|
ferencd@0
|
340
|
|
ferencd@0
|
341 set(CONAN_BUILD_POLICY "")
|
|
ferencd@0
|
342 foreach(ARG ${ARGUMENTS_BUILD})
|
|
ferencd@0
|
343 if(${ARG} STREQUAL "all")
|
|
ferencd@0
|
344 set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build)
|
|
ferencd@0
|
345 break()
|
|
ferencd@0
|
346 else()
|
|
ferencd@0
|
347 set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG})
|
|
ferencd@0
|
348 endif()
|
|
ferencd@0
|
349 endforeach()
|
|
ferencd@0
|
350 if(ARGUMENTS_CONAN_COMMAND)
|
|
ferencd@0
|
351 set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND})
|
|
ferencd@0
|
352 else()
|
|
ferencd@0
|
353 conan_check(REQUIRED)
|
|
ferencd@0
|
354 endif()
|
|
ferencd@0
|
355 set(CONAN_OPTIONS "")
|
|
ferencd@0
|
356 if(ARGUMENTS_CONANFILE)
|
|
ferencd@0
|
357 set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE})
|
|
ferencd@0
|
358 # A conan file has been specified - apply specified options as well if provided
|
|
ferencd@0
|
359 foreach(ARG ${ARGUMENTS_OPTIONS})
|
|
ferencd@0
|
360 set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG})
|
|
ferencd@0
|
361 endforeach()
|
|
ferencd@0
|
362 else()
|
|
ferencd@0
|
363 set(CONANFILE ".")
|
|
ferencd@0
|
364 endif()
|
|
ferencd@0
|
365 if(ARGUMENTS_UPDATE)
|
|
ferencd@0
|
366 set(CONAN_INSTALL_UPDATE --update)
|
|
ferencd@0
|
367 endif()
|
|
ferencd@0
|
368 if(ARGUMENTS_NO_IMPORTS)
|
|
ferencd@0
|
369 set(CONAN_INSTALL_NO_IMPORTS --no-imports)
|
|
ferencd@0
|
370 endif()
|
|
ferencd@0
|
371 set(CONAN_INSTALL_FOLDER "")
|
|
ferencd@0
|
372 if(ARGUMENTS_INSTALL_FOLDER)
|
|
ferencd@0
|
373 set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER})
|
|
ferencd@0
|
374 endif()
|
|
ferencd@0
|
375 foreach(ARG ${ARGUMENTS_GENERATORS})
|
|
ferencd@0
|
376 set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG})
|
|
ferencd@0
|
377 endforeach()
|
|
ferencd@0
|
378 foreach(ARG ${ARGUMENTS_ENV})
|
|
ferencd@0
|
379 set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG})
|
|
ferencd@0
|
380 endforeach()
|
|
ferencd@0
|
381 set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS})
|
|
ferencd@0
|
382
|
|
ferencd@0
|
383 string (REPLACE ";" " " _conan_args "${conan_args}")
|
|
ferencd@0
|
384 message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}")
|
|
ferencd@0
|
385
|
|
ferencd@0
|
386 if(ARGUMENTS_OUTPUT_QUIET)
|
|
ferencd@0
|
387 execute_process(COMMAND ${CONAN_CMD} ${conan_args}
|
|
ferencd@0
|
388 RESULT_VARIABLE return_code
|
|
ferencd@0
|
389 OUTPUT_VARIABLE conan_output
|
|
ferencd@0
|
390 ERROR_VARIABLE conan_output
|
|
ferencd@0
|
391 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
ferencd@0
|
392 else()
|
|
ferencd@0
|
393 execute_process(COMMAND ${CONAN_CMD} ${conan_args}
|
|
ferencd@0
|
394 RESULT_VARIABLE return_code
|
|
ferencd@0
|
395 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
ferencd@0
|
396 endif()
|
|
ferencd@0
|
397
|
|
ferencd@0
|
398 if(NOT "${return_code}" STREQUAL "0")
|
|
ferencd@0
|
399 message(FATAL_ERROR "Conan install failed='${return_code}'")
|
|
ferencd@0
|
400 endif()
|
|
ferencd@0
|
401
|
|
ferencd@0
|
402 endfunction()
|
|
ferencd@0
|
403
|
|
ferencd@0
|
404
|
|
ferencd@0
|
405 function(conan_cmake_setup_conanfile)
|
|
ferencd@0
|
406 parse_arguments(${ARGV})
|
|
ferencd@0
|
407 if(ARGUMENTS_CONANFILE)
|
|
ferencd@0
|
408 get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME)
|
|
ferencd@0
|
409 # configure_file will make sure cmake re-runs when conanfile is updated
|
|
ferencd@0
|
410 configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk)
|
|
ferencd@0
|
411 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk)
|
|
ferencd@0
|
412 else()
|
|
ferencd@0
|
413 conan_cmake_generate_conanfile(${ARGV})
|
|
ferencd@0
|
414 endif()
|
|
ferencd@0
|
415 endfunction()
|
|
ferencd@0
|
416
|
|
ferencd@0
|
417 function(conan_cmake_generate_conanfile)
|
|
ferencd@0
|
418 # Generate, writing in disk a conanfile.txt with the requires, options, and imports
|
|
ferencd@0
|
419 # specified as arguments
|
|
ferencd@0
|
420 # This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR)
|
|
ferencd@0
|
421 parse_arguments(${ARGV})
|
|
ferencd@0
|
422 set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt")
|
|
ferencd@0
|
423
|
|
ferencd@0
|
424 file(WRITE ${_FN} "[generators]\ncmake\n\n[requires]\n")
|
|
ferencd@0
|
425 foreach(ARG ${ARGUMENTS_REQUIRES})
|
|
ferencd@0
|
426 file(APPEND ${_FN} ${ARG} "\n")
|
|
ferencd@0
|
427 endforeach()
|
|
ferencd@0
|
428
|
|
ferencd@0
|
429 file(APPEND ${_FN} ${ARG} "\n[options]\n")
|
|
ferencd@0
|
430 foreach(ARG ${ARGUMENTS_OPTIONS})
|
|
ferencd@0
|
431 file(APPEND ${_FN} ${ARG} "\n")
|
|
ferencd@0
|
432 endforeach()
|
|
ferencd@0
|
433
|
|
ferencd@0
|
434 file(APPEND ${_FN} ${ARG} "\n[imports]\n")
|
|
ferencd@0
|
435 foreach(ARG ${ARGUMENTS_IMPORTS})
|
|
ferencd@0
|
436 file(APPEND ${_FN} ${ARG} "\n")
|
|
ferencd@0
|
437 endforeach()
|
|
ferencd@0
|
438 endfunction()
|
|
ferencd@0
|
439
|
|
ferencd@0
|
440
|
|
ferencd@0
|
441 macro(conan_load_buildinfo)
|
|
ferencd@0
|
442 if(CONAN_CMAKE_MULTI)
|
|
ferencd@0
|
443 set(_CONANBUILDINFO conanbuildinfo_multi.cmake)
|
|
ferencd@0
|
444 else()
|
|
ferencd@0
|
445 set(_CONANBUILDINFO conanbuildinfo.cmake)
|
|
ferencd@0
|
446 endif()
|
|
ferencd@0
|
447 if(ARGUMENTS_INSTALL_FOLDER)
|
|
ferencd@0
|
448 set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER})
|
|
ferencd@0
|
449 else()
|
|
ferencd@0
|
450 set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR})
|
|
ferencd@0
|
451 endif()
|
|
ferencd@0
|
452 # Checks for the existence of conanbuildinfo.cmake, and loads it
|
|
ferencd@0
|
453 # important that it is macro, so variables defined at parent scope
|
|
ferencd@0
|
454 if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}")
|
|
ferencd@0
|
455 message(STATUS "Conan: Loading ${_CONANBUILDINFO}")
|
|
ferencd@0
|
456 include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO})
|
|
ferencd@0
|
457 else()
|
|
ferencd@0
|
458 message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}")
|
|
ferencd@0
|
459 endif()
|
|
ferencd@0
|
460 endmacro()
|
|
ferencd@0
|
461
|
|
ferencd@0
|
462
|
|
ferencd@0
|
463 macro(conan_cmake_run)
|
|
ferencd@0
|
464 parse_arguments(${ARGV})
|
|
ferencd@0
|
465
|
|
ferencd@0
|
466 if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED
|
|
ferencd@0
|
467 AND NOT ARGUMENTS_BUILD_TYPE)
|
|
ferencd@0
|
468 set(CONAN_CMAKE_MULTI ON)
|
|
ferencd@0
|
469 message(STATUS "Conan: Using cmake-multi generator")
|
|
ferencd@0
|
470 else()
|
|
ferencd@0
|
471 set(CONAN_CMAKE_MULTI OFF)
|
|
ferencd@0
|
472 endif()
|
|
ferencd@0
|
473
|
|
ferencd@0
|
474 if(NOT CONAN_EXPORTED)
|
|
ferencd@0
|
475 conan_cmake_setup_conanfile(${ARGV})
|
|
ferencd@0
|
476 if(CONAN_CMAKE_MULTI)
|
|
ferencd@0
|
477 foreach(CMAKE_BUILD_TYPE "Release" "Debug")
|
|
ferencd@0
|
478 set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE})
|
|
ferencd@0
|
479 conan_cmake_settings(settings ${ARGV})
|
|
ferencd@0
|
480 conan_cmake_install(SETTINGS ${settings} ${ARGV})
|
|
ferencd@0
|
481 endforeach()
|
|
ferencd@0
|
482 set(CMAKE_BUILD_TYPE)
|
|
ferencd@0
|
483 else()
|
|
ferencd@0
|
484 conan_cmake_settings(settings ${ARGV})
|
|
ferencd@0
|
485 conan_cmake_install(SETTINGS ${settings} ${ARGV})
|
|
ferencd@0
|
486 endif()
|
|
ferencd@0
|
487 endif()
|
|
ferencd@0
|
488
|
|
ferencd@0
|
489 if (NOT ARGUMENTS_NO_LOAD)
|
|
ferencd@0
|
490 conan_load_buildinfo()
|
|
ferencd@0
|
491 endif()
|
|
ferencd@0
|
492
|
|
ferencd@0
|
493 if(ARGUMENTS_BASIC_SETUP)
|
|
ferencd@0
|
494 foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS)
|
|
ferencd@0
|
495 if(ARGUMENTS_${_option})
|
|
ferencd@0
|
496 if(${_option} STREQUAL "CMAKE_TARGETS")
|
|
ferencd@0
|
497 list(APPEND _setup_options "TARGETS")
|
|
ferencd@0
|
498 else()
|
|
ferencd@0
|
499 list(APPEND _setup_options ${_option})
|
|
ferencd@0
|
500 endif()
|
|
ferencd@0
|
501 endif()
|
|
ferencd@0
|
502 endforeach()
|
|
ferencd@0
|
503 conan_basic_setup(${_setup_options})
|
|
ferencd@0
|
504 endif()
|
|
ferencd@0
|
505 endmacro()
|
|
ferencd@0
|
506
|
|
ferencd@0
|
507 macro(conan_check)
|
|
ferencd@0
|
508 # Checks conan availability in PATH
|
|
ferencd@0
|
509 # Arguments REQUIRED and VERSION are optional
|
|
ferencd@0
|
510 # Example usage:
|
|
ferencd@0
|
511 # conan_check(VERSION 1.0.0 REQUIRED)
|
|
ferencd@0
|
512 message(STATUS "Conan: checking conan executable")
|
|
ferencd@0
|
513 set(options REQUIRED)
|
|
ferencd@0
|
514 set(oneValueArgs VERSION)
|
|
ferencd@0
|
515 cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN})
|
|
ferencd@0
|
516
|
|
ferencd@0
|
517 find_program(CONAN_CMD conan)
|
|
ferencd@0
|
518 if(NOT CONAN_CMD AND CONAN_REQUIRED)
|
|
ferencd@0
|
519 message(FATAL_ERROR "Conan executable not found!")
|
|
ferencd@0
|
520 endif()
|
|
ferencd@0
|
521 message(STATUS "Conan: Found program ${CONAN_CMD}")
|
|
ferencd@0
|
522 execute_process(COMMAND ${CONAN_CMD} --version
|
|
ferencd@0
|
523 OUTPUT_VARIABLE CONAN_VERSION_OUTPUT
|
|
ferencd@0
|
524 ERROR_VARIABLE CONAN_VERSION_OUTPUT)
|
|
ferencd@0
|
525 message(STATUS "Conan: Version found ${CONAN_VERSION_OUTPUT}")
|
|
ferencd@0
|
526
|
|
ferencd@0
|
527 if(DEFINED CONAN_VERSION)
|
|
ferencd@0
|
528 string(REGEX MATCH ".*Conan version ([0-9]+\.[0-9]+\.[0-9]+)" FOO
|
|
ferencd@0
|
529 "${CONAN_VERSION_OUTPUT}")
|
|
ferencd@0
|
530 if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION})
|
|
ferencd@0
|
531 message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \
|
|
ferencd@0
|
532 required: ${CONAN_VERSION}. Consider updating via 'pip \
|
|
ferencd@0
|
533 install conan==${CONAN_VERSION}'.")
|
|
ferencd@0
|
534 endif()
|
|
ferencd@0
|
535 endif()
|
|
ferencd@0
|
536 endmacro()
|
|
ferencd@0
|
537
|
|
ferencd@0
|
538 function(conan_add_remote)
|
|
ferencd@0
|
539 # Adds a remote
|
|
ferencd@0
|
540 # Arguments URL and NAME are required, INDEX and COMMAND are optional
|
|
ferencd@0
|
541 # Example usage:
|
|
ferencd@0
|
542 # conan_add_remote(NAME bincrafters INDEX 1
|
|
ferencd@0
|
543 # URL https://api.bintray.com/conan/bincrafters/public-conan)
|
|
ferencd@0
|
544 set(oneValueArgs URL NAME INDEX COMMAND)
|
|
ferencd@0
|
545 cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN})
|
|
ferencd@0
|
546
|
|
ferencd@0
|
547 if(DEFINED CONAN_INDEX)
|
|
ferencd@0
|
548 set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}")
|
|
ferencd@0
|
549 endif()
|
|
ferencd@0
|
550 if(CONAN_COMMAND)
|
|
ferencd@0
|
551 set(CONAN_CMD ${CONAN_COMMAND})
|
|
ferencd@0
|
552 else()
|
|
ferencd@0
|
553 conan_check(REQUIRED)
|
|
ferencd@0
|
554 endif()
|
|
ferencd@0
|
555 message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL})")
|
|
ferencd@0
|
556 execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_URL}
|
|
ferencd@0
|
557 ${CONAN_INDEX_ARG} -f)
|
|
ferencd@0
|
558 endfunction()
|