| 1 |
# The MIT License (MIT) |
| 2 |
|
| 3 |
# Copyright (c) 2018 JFrog |
| 4 |
|
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 |
# of this software and associated documentation files (the "Software"), to deal |
| 7 |
# in the Software without restriction, including without limitation the rights |
| 8 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
# copies of the Software, and to permit persons to whom the Software is |
| 10 |
# furnished to do so, subject to the following conditions: |
| 11 |
|
| 12 |
# The above copyright notice and this permission notice shall be included in all |
| 13 |
# copies or substantial portions of the Software. |
| 14 |
|
| 15 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
# SOFTWARE. |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
# This file comes from: https://github.com/conan-io/cmake-conan. Please refer |
| 26 |
# to this repository for issues and documentation. |
| 27 |
|
| 28 |
# Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called. |
| 29 |
# It will take CMake current settings (os, compiler, compiler version, architecture) |
| 30 |
# and translate them to conan settings for installing and retrieving dependencies. |
| 31 |
|
| 32 |
# It is intended to facilitate developers building projects that have conan dependencies, |
| 33 |
# but it is only necessary on the end-user side. It is not necessary to create conan |
| 34 |
# packages, in fact it shouldn't be use for that. Check the project documentation. |
| 35 |
|
| 36 |
# version: 0.18.1 |
| 37 |
|
| 38 |
include(CMakeParseArguments) |
| 39 |
|
| 40 |
function(_get_msvc_ide_version result) |
| 41 |
set(${result} "" PARENT_SCOPE) |
| 42 |
if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) |
| 43 |
set(${result} 8 PARENT_SCOPE) |
| 44 |
elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) |
| 45 |
set(${result} 9 PARENT_SCOPE) |
| 46 |
elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) |
| 47 |
set(${result} 10 PARENT_SCOPE) |
| 48 |
elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) |
| 49 |
set(${result} 11 PARENT_SCOPE) |
| 50 |
elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) |
| 51 |
set(${result} 12 PARENT_SCOPE) |
| 52 |
elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) |
| 53 |
set(${result} 14 PARENT_SCOPE) |
| 54 |
elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) |
| 55 |
set(${result} 15 PARENT_SCOPE) |
| 56 |
elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) |
| 57 |
set(${result} 16 PARENT_SCOPE) |
| 58 |
elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1950) |
| 59 |
set(${result} 17 PARENT_SCOPE) |
| 60 |
else() |
| 61 |
message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") |
| 62 |
endif() |
| 63 |
endfunction() |
| 64 |
|
| 65 |
macro(_conan_detect_build_type) |
| 66 |
conan_parse_arguments(${ARGV}) |
| 67 |
|
| 68 |
if(ARGUMENTS_BUILD_TYPE) |
| 69 |
set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE}) |
| 70 |
elseif(CMAKE_BUILD_TYPE) |
| 71 |
set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE}) |
| 72 |
else() |
| 73 |
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") |
| 74 |
endif() |
| 75 |
|
| 76 |
string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER) |
| 77 |
if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG") |
| 78 |
set(_CONAN_SETTING_BUILD_TYPE "Debug") |
| 79 |
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE") |
| 80 |
set(_CONAN_SETTING_BUILD_TYPE "Release") |
| 81 |
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") |
| 82 |
set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo") |
| 83 |
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL") |
| 84 |
set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel") |
| 85 |
endif() |
| 86 |
endmacro() |
| 87 |
|
| 88 |
macro(_conan_check_system_name) |
| 89 |
#handle -s os setting |
| 90 |
if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") |
| 91 |
#use default conan os setting if CMAKE_SYSTEM_NAME is not defined |
| 92 |
set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) |
| 93 |
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") |
| 94 |
set(CONAN_SYSTEM_NAME Macos) |
| 95 |
endif() |
| 96 |
if(${CMAKE_SYSTEM_NAME} STREQUAL "QNX") |
| 97 |
set(CONAN_SYSTEM_NAME Neutrino) |
| 98 |
endif() |
| 99 |
set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore WindowsCE watchOS tvOS FreeBSD SunOS AIX Arduino Emscripten Neutrino) |
| 100 |
list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index) |
| 101 |
if (${_index} GREATER -1) |
| 102 |
#check if the cmake system is a conan supported one |
| 103 |
set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME}) |
| 104 |
else() |
| 105 |
message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}") |
| 106 |
endif() |
| 107 |
endif() |
| 108 |
endmacro() |
| 109 |
|
| 110 |
macro(_conan_check_language) |
| 111 |
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) |
| 112 |
if (";${_languages};" MATCHES ";CXX;") |
| 113 |
set(LANGUAGE CXX) |
| 114 |
set(USING_CXX 1) |
| 115 |
elseif (";${_languages};" MATCHES ";C;") |
| 116 |
set(LANGUAGE C) |
| 117 |
set(USING_CXX 0) |
| 118 |
else () |
| 119 |
message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.") |
| 120 |
endif() |
| 121 |
endmacro() |
| 122 |
|
| 123 |
macro(_conan_detect_compiler) |
| 124 |
|
| 125 |
conan_parse_arguments(${ARGV}) |
| 126 |
|
| 127 |
if(ARGUMENTS_ARCH) |
| 128 |
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH}) |
| 129 |
endif() |
| 130 |
|
| 131 |
if(USING_CXX) |
| 132 |
set(_CONAN_SETTING_COMPILER_CPPSTD ${CMAKE_CXX_STANDARD}) |
| 133 |
endif() |
| 134 |
|
| 135 |
if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) |
| 136 |
# using GCC |
| 137 |
# TODO: Handle other params |
| 138 |
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) |
| 139 |
list(GET VERSION_LIST 0 MAJOR) |
| 140 |
list(GET VERSION_LIST 1 MINOR) |
| 141 |
set(COMPILER_VERSION ${MAJOR}.${MINOR}) |
| 142 |
if(${MAJOR} GREATER 4) |
| 143 |
set(COMPILER_VERSION ${MAJOR}) |
| 144 |
endif() |
| 145 |
set(_CONAN_SETTING_COMPILER gcc) |
| 146 |
set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) |
| 147 |
if (USING_CXX) |
| 148 |
conan_cmake_detect_unix_libcxx(_LIBCXX) |
| 149 |
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) |
| 150 |
endif () |
| 151 |
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Intel) |
| 152 |
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) |
| 153 |
list(GET VERSION_LIST 0 MAJOR) |
| 154 |
list(GET VERSION_LIST 1 MINOR) |
| 155 |
set(COMPILER_VERSION ${MAJOR}.${MINOR}) |
| 156 |
set(_CONAN_SETTING_COMPILER intel) |
| 157 |
set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) |
| 158 |
if (USING_CXX) |
| 159 |
conan_cmake_detect_unix_libcxx(_LIBCXX) |
| 160 |
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) |
| 161 |
endif () |
| 162 |
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang) |
| 163 |
# using AppleClang |
| 164 |
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) |
| 165 |
list(GET VERSION_LIST 0 MAJOR) |
| 166 |
list(GET VERSION_LIST 1 MINOR) |
| 167 |
set(_CONAN_SETTING_COMPILER apple-clang) |
| 168 |
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) |
| 169 |
if (USING_CXX) |
| 170 |
conan_cmake_detect_unix_libcxx(_LIBCXX) |
| 171 |
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) |
| 172 |
endif () |
| 173 |
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang |
| 174 |
AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" |
| 175 |
AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC") |
| 176 |
|
| 177 |
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) |
| 178 |
list(GET VERSION_LIST 0 MAJOR) |
| 179 |
list(GET VERSION_LIST 1 MINOR) |
| 180 |
set(_CONAN_SETTING_COMPILER clang) |
| 181 |
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) |
| 182 |
if(APPLE) |
| 183 |
cmake_policy(GET CMP0025 APPLE_CLANG_POLICY) |
| 184 |
if(NOT APPLE_CLANG_POLICY STREQUAL NEW) |
| 185 |
message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it") |
| 186 |
set(_CONAN_SETTING_COMPILER apple-clang) |
| 187 |
endif() |
| 188 |
endif() |
| 189 |
if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7) |
| 190 |
set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}) |
| 191 |
endif() |
| 192 |
if (USING_CXX) |
| 193 |
conan_cmake_detect_unix_libcxx(_LIBCXX) |
| 194 |
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) |
| 195 |
endif () |
| 196 |
elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC |
| 197 |
OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang |
| 198 |
AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" |
| 199 |
AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")) |
| 200 |
|
| 201 |
set(_VISUAL "Visual Studio") |
| 202 |
_get_msvc_ide_version(_VISUAL_VERSION) |
| 203 |
if("${_VISUAL_VERSION}" STREQUAL "") |
| 204 |
message(FATAL_ERROR "Conan: Visual Studio not recognized") |
| 205 |
else() |
| 206 |
set(_CONAN_SETTING_COMPILER ${_VISUAL}) |
| 207 |
set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION}) |
| 208 |
endif() |
| 209 |
|
| 210 |
if(NOT _CONAN_SETTING_ARCH) |
| 211 |
if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64") |
| 212 |
set(_CONAN_SETTING_ARCH x86_64) |
| 213 |
elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM") |
| 214 |
message(STATUS "Conan: Using default ARM architecture from MSVC") |
| 215 |
set(_CONAN_SETTING_ARCH armv6) |
| 216 |
elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86") |
| 217 |
set(_CONAN_SETTING_ARCH x86) |
| 218 |
else () |
| 219 |
message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]") |
| 220 |
endif() |
| 221 |
endif() |
| 222 |
|
| 223 |
conan_cmake_detect_vs_runtime(_vs_runtime ${ARGV}) |
| 224 |
message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}") |
| 225 |
set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime}) |
| 226 |
|
| 227 |
if (CMAKE_GENERATOR_TOOLSET) |
| 228 |
set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) |
| 229 |
elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja")) |
| 230 |
set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) |
| 231 |
endif() |
| 232 |
else() |
| 233 |
message(FATAL_ERROR "Conan: compiler setup not recognized") |
| 234 |
endif() |
| 235 |
|
| 236 |
endmacro() |
| 237 |
|
| 238 |
function(conan_cmake_settings result) |
| 239 |
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER}) |
| 240 |
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID}) |
| 241 |
#message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION}) |
| 242 |
#message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS}) |
| 243 |
#message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) |
| 244 |
#message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE}) |
| 245 |
#message(STATUS "GENERATOR " ${CMAKE_GENERATOR}) |
| 246 |
#message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64}) |
| 247 |
|
| 248 |
message(STATUS "Conan: Automatic detection of conan settings from cmake") |
| 249 |
|
| 250 |
conan_parse_arguments(${ARGV}) |
| 251 |
|
| 252 |
_conan_detect_build_type(${ARGV}) |
| 253 |
|
| 254 |
_conan_check_system_name() |
| 255 |
|
| 256 |
_conan_check_language() |
| 257 |
|
| 258 |
_conan_detect_compiler(${ARGV}) |
| 259 |
|
| 260 |
# If profile is defined it is used |
| 261 |
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE) |
| 262 |
set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE}) |
| 263 |
elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE) |
| 264 |
set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE}) |
| 265 |
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE) |
| 266 |
set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE}) |
| 267 |
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE) |
| 268 |
set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE}) |
| 269 |
elseif(ARGUMENTS_PROFILE) |
| 270 |
set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE}) |
| 271 |
endif() |
| 272 |
|
| 273 |
foreach(ARG ${_APPLIED_PROFILES}) |
| 274 |
set(_SETTINGS ${_SETTINGS} -pr=${ARG}) |
| 275 |
endforeach() |
| 276 |
foreach(ARG ${ARGUMENTS_PROFILE_BUILD}) |
| 277 |
conan_check(VERSION 1.24.0 REQUIRED DETECT_QUIET) |
| 278 |
set(_SETTINGS ${_SETTINGS} -pr:b=${ARG}) |
| 279 |
endforeach() |
| 280 |
|
| 281 |
if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") |
| 282 |
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version |
| 283 |
compiler.runtime compiler.libcxx compiler.toolset) |
| 284 |
endif() |
| 285 |
|
| 286 |
# remove any manually specified settings from the autodetected settings |
| 287 |
foreach(ARG ${ARGUMENTS_SETTINGS}) |
| 288 |
string(REGEX MATCH "[^=]*" MANUAL_SETTING "${ARG}") |
| 289 |
message(STATUS "Conan: ${MANUAL_SETTING} was added as an argument. Not using the autodetected one.") |
| 290 |
list(REMOVE_ITEM ARGUMENTS_PROFILE_AUTO "${MANUAL_SETTING}") |
| 291 |
endforeach() |
| 292 |
|
| 293 |
# Automatic from CMake |
| 294 |
foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) |
| 295 |
string(TOUPPER ${ARG} _arg_name) |
| 296 |
string(REPLACE "." "_" _arg_name ${_arg_name}) |
| 297 |
if(_CONAN_SETTING_${_arg_name}) |
| 298 |
set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}}) |
| 299 |
endif() |
| 300 |
endforeach() |
| 301 |
|
| 302 |
foreach(ARG ${ARGUMENTS_SETTINGS}) |
| 303 |
set(_SETTINGS ${_SETTINGS} -s ${ARG}) |
| 304 |
endforeach() |
| 305 |
|
| 306 |
message(STATUS "Conan: Settings= ${_SETTINGS}") |
| 307 |
|
| 308 |
set(${result} ${_SETTINGS} PARENT_SCOPE) |
| 309 |
endfunction() |
| 310 |
|
| 311 |
|
| 312 |
function(conan_cmake_detect_unix_libcxx result) |
| 313 |
# Take into account any -stdlib in compile options |
| 314 |
get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) |
| 315 |
string(GENEX_STRIP "${compile_options}" compile_options) |
| 316 |
|
| 317 |
# Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions |
| 318 |
get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) |
| 319 |
string(GENEX_STRIP "${defines}" defines) |
| 320 |
|
| 321 |
foreach(define ${defines}) |
| 322 |
if(define MATCHES "_GLIBCXX_USE_CXX11_ABI") |
| 323 |
if(define MATCHES "^-D") |
| 324 |
set(compile_options ${compile_options} "${define}") |
| 325 |
else() |
| 326 |
set(compile_options ${compile_options} "-D${define}") |
| 327 |
endif() |
| 328 |
endif() |
| 329 |
endforeach() |
| 330 |
|
| 331 |
# add additional compiler options ala cmRulePlaceholderExpander::ExpandRuleVariable |
| 332 |
set(EXPAND_CXX_COMPILER ${CMAKE_CXX_COMPILER}) |
| 333 |
if(CMAKE_CXX_COMPILER_ARG1) |
| 334 |
# CMake splits CXX="foo bar baz" into CMAKE_CXX_COMPILER="foo", CMAKE_CXX_COMPILER_ARG1="bar baz" |
| 335 |
# without this, ccache, winegcc, or other wrappers might lose all their arguments |
| 336 |
separate_arguments(SPLIT_CXX_COMPILER_ARG1 NATIVE_COMMAND ${CMAKE_CXX_COMPILER_ARG1}) |
| 337 |
list(APPEND EXPAND_CXX_COMPILER ${SPLIT_CXX_COMPILER_ARG1}) |
| 338 |
endif() |
| 339 |
|
| 340 |
if(CMAKE_CXX_COMPILE_OPTIONS_TARGET AND CMAKE_CXX_COMPILER_TARGET) |
| 341 |
# without --target= we may be calling the wrong underlying GCC |
| 342 |
list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}") |
| 343 |
endif() |
| 344 |
|
| 345 |
if(CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN AND CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) |
| 346 |
list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") |
| 347 |
endif() |
| 348 |
|
| 349 |
if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT) |
| 350 |
# without --sysroot= we may find the wrong #include <string> |
| 351 |
if(CMAKE_SYSROOT_COMPILE) |
| 352 |
list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}") |
| 353 |
elseif(CMAKE_SYSROOT) |
| 354 |
list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}") |
| 355 |
endif() |
| 356 |
endif() |
| 357 |
|
| 358 |
separate_arguments(SPLIT_CXX_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS}) |
| 359 |
|
| 360 |
if(CMAKE_OSX_SYSROOT) |
| 361 |
set(xcode_sysroot_option "--sysroot=${CMAKE_OSX_SYSROOT}") |
| 362 |
endif() |
| 363 |
|
| 364 |
execute_process( |
| 365 |
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>" |
| 366 |
COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${xcode_sysroot_option} ${compile_options} -E -dM - |
| 367 |
OUTPUT_VARIABLE string_defines |
| 368 |
) |
| 369 |
|
| 370 |
if(string_defines MATCHES "#define __GLIBCXX__") |
| 371 |
# Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake |
| 372 |
if(DEFINED _GLIBCXX_USE_CXX11_ABI) |
| 373 |
if(_GLIBCXX_USE_CXX11_ABI) |
| 374 |
set(${result} libstdc++11 PARENT_SCOPE) |
| 375 |
return() |
| 376 |
else() |
| 377 |
set(${result} libstdc++ PARENT_SCOPE) |
| 378 |
return() |
| 379 |
endif() |
| 380 |
endif() |
| 381 |
|
| 382 |
if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") |
| 383 |
set(${result} libstdc++11 PARENT_SCOPE) |
| 384 |
else() |
| 385 |
# Either the compiler is missing the define because it is old, and so |
| 386 |
# it can't use the new abi, or the compiler was configured to use the |
| 387 |
# old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) |
| 388 |
set(${result} libstdc++ PARENT_SCOPE) |
| 389 |
endif() |
| 390 |
else() |
| 391 |
set(${result} libc++ PARENT_SCOPE) |
| 392 |
endif() |
| 393 |
endfunction() |
| 394 |
|
| 395 |
function(conan_cmake_detect_vs_runtime result) |
| 396 |
|
| 397 |
conan_parse_arguments(${ARGV}) |
| 398 |
if(ARGUMENTS_BUILD_TYPE) |
| 399 |
set(build_type "${ARGUMENTS_BUILD_TYPE}") |
| 400 |
elseif(CMAKE_BUILD_TYPE) |
| 401 |
set(build_type "${CMAKE_BUILD_TYPE}") |
| 402 |
else() |
| 403 |
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") |
| 404 |
endif() |
| 405 |
|
| 406 |
if(build_type) |
| 407 |
string(TOUPPER "${build_type}" build_type) |
| 408 |
endif() |
| 409 |
set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) |
| 410 |
foreach(variable ${variables}) |
| 411 |
if(NOT "${${variable}}" STREQUAL "") |
| 412 |
string(REPLACE " " ";" flags "${${variable}}") |
| 413 |
foreach (flag ${flags}) |
| 414 |
if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") |
| 415 |
string(SUBSTRING "${flag}" 1 -1 runtime) |
| 416 |
set(${result} "${runtime}" PARENT_SCOPE) |
| 417 |
return() |
| 418 |
endif() |
| 419 |
endforeach() |
| 420 |
endif() |
| 421 |
endforeach() |
| 422 |
if("${build_type}" STREQUAL "DEBUG") |
| 423 |
set(${result} "MDd" PARENT_SCOPE) |
| 424 |
else() |
| 425 |
set(${result} "MD" PARENT_SCOPE) |
| 426 |
endif() |
| 427 |
endfunction() |
| 428 |
|
| 429 |
function(_collect_settings result) |
| 430 |
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version |
| 431 |
compiler.runtime compiler.libcxx compiler.toolset |
| 432 |
compiler.cppstd) |
| 433 |
foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) |
| 434 |
string(TOUPPER ${ARG} _arg_name) |
| 435 |
string(REPLACE "." "_" _arg_name ${_arg_name}) |
| 436 |
if(_CONAN_SETTING_${_arg_name}) |
| 437 |
set(detected_setings ${detected_setings} ${ARG}=${_CONAN_SETTING_${_arg_name}}) |
| 438 |
endif() |
| 439 |
endforeach() |
| 440 |
set(${result} ${detected_setings} PARENT_SCOPE) |
| 441 |
endfunction() |
| 442 |
|
| 443 |
function(conan_cmake_autodetect detected_settings) |
| 444 |
_conan_detect_build_type(${ARGV}) |
| 445 |
_conan_check_system_name() |
| 446 |
_conan_check_language() |
| 447 |
_conan_detect_compiler(${ARGV}) |
| 448 |
_collect_settings(collected_settings) |
| 449 |
set(${detected_settings} ${collected_settings} PARENT_SCOPE) |
| 450 |
endfunction() |
| 451 |
|
| 452 |
macro(conan_parse_arguments) |
| 453 |
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD) |
| 454 |
set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) |
| 455 |
set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE |
| 456 |
PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO |
| 457 |
INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) |
| 458 |
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
| 459 |
endmacro() |
| 460 |
|
| 461 |
function(old_conan_cmake_install) |
| 462 |
# Calls "conan install" |
| 463 |
# Argument BUILD is equivalant to --build={missing, PkgName,...} or |
| 464 |
# --build when argument is 'BUILD all' (which builds all packages from source) |
| 465 |
# Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source |
| 466 |
# cmake does not identify conan as command, even if it is +x and it is in the path |
| 467 |
conan_parse_arguments(${ARGV}) |
| 468 |
|
| 469 |
if(CONAN_CMAKE_MULTI) |
| 470 |
set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) |
| 471 |
else() |
| 472 |
set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) |
| 473 |
endif() |
| 474 |
|
| 475 |
set(CONAN_BUILD_POLICY "") |
| 476 |
foreach(ARG ${ARGUMENTS_BUILD}) |
| 477 |
if(${ARG} STREQUAL "all") |
| 478 |
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) |
| 479 |
break() |
| 480 |
else() |
| 481 |
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) |
| 482 |
endif() |
| 483 |
endforeach() |
| 484 |
if(ARGUMENTS_CONAN_COMMAND) |
| 485 |
set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND}) |
| 486 |
else() |
| 487 |
conan_check(REQUIRED) |
| 488 |
endif() |
| 489 |
set(CONAN_OPTIONS "") |
| 490 |
if(ARGUMENTS_CONANFILE) |
| 491 |
if(IS_ABSOLUTE ${ARGUMENTS_CONANFILE}) |
| 492 |
set(CONANFILE ${ARGUMENTS_CONANFILE}) |
| 493 |
else() |
| 494 |
set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) |
| 495 |
endif() |
| 496 |
else() |
| 497 |
set(CONANFILE ".") |
| 498 |
endif() |
| 499 |
foreach(ARG ${ARGUMENTS_OPTIONS}) |
| 500 |
set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) |
| 501 |
endforeach() |
| 502 |
if(ARGUMENTS_UPDATE) |
| 503 |
set(CONAN_INSTALL_UPDATE --update) |
| 504 |
endif() |
| 505 |
if(ARGUMENTS_NO_IMPORTS) |
| 506 |
set(CONAN_INSTALL_NO_IMPORTS --no-imports) |
| 507 |
endif() |
| 508 |
set(CONAN_INSTALL_FOLDER "") |
| 509 |
if(ARGUMENTS_INSTALL_FOLDER) |
| 510 |
set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) |
| 511 |
endif() |
| 512 |
set(CONAN_OUTPUT_FOLDER "") |
| 513 |
if(ARGUMENTS_OUTPUT_FOLDER) |
| 514 |
set(CONAN_OUTPUT_FOLDER -of=${ARGUMENTS_OUTPUT_FOLDER}) |
| 515 |
endif() |
| 516 |
foreach(ARG ${ARGUMENTS_GENERATORS}) |
| 517 |
set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) |
| 518 |
endforeach() |
| 519 |
foreach(ARG ${ARGUMENTS_ENV}) |
| 520 |
set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) |
| 521 |
endforeach() |
| 522 |
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}) |
| 523 |
|
| 524 |
string (REPLACE ";" " " _conan_args "${conan_args}") |
| 525 |
message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}") |
| 526 |
|
| 527 |
if(ARGUMENTS_OUTPUT_QUIET) |
| 528 |
execute_process(COMMAND ${CONAN_CMD} ${conan_args} |
| 529 |
RESULT_VARIABLE return_code |
| 530 |
OUTPUT_VARIABLE conan_output |
| 531 |
ERROR_VARIABLE conan_output |
| 532 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 533 |
else() |
| 534 |
execute_process(COMMAND ${CONAN_CMD} ${conan_args} |
| 535 |
RESULT_VARIABLE return_code |
| 536 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 537 |
endif() |
| 538 |
|
| 539 |
if(NOT "${return_code}" STREQUAL "0") |
| 540 |
message(FATAL_ERROR "Conan install failed='${return_code}'") |
| 541 |
endif() |
| 542 |
|
| 543 |
endfunction() |
| 544 |
|
| 545 |
function(conan_cmake_install) |
| 546 |
if(DEFINED CONAN_COMMAND) |
| 547 |
set(CONAN_CMD ${CONAN_COMMAND}) |
| 548 |
else() |
| 549 |
conan_check(REQUIRED) |
| 550 |
endif() |
| 551 |
|
| 552 |
set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET) |
| 553 |
set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER OUTPUT_FOLDER) |
| 554 |
set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE |
| 555 |
PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) |
| 556 |
cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN}) |
| 557 |
foreach(arg ${installOptions}) |
| 558 |
if(ARGS_${arg}) |
| 559 |
set(${arg} ${${arg}} ${ARGS_${arg}}) |
| 560 |
endif() |
| 561 |
endforeach() |
| 562 |
foreach(arg ${installOneValueArgs}) |
| 563 |
if(DEFINED ARGS_${arg}) |
| 564 |
if("${arg}" STREQUAL "REMOTE") |
| 565 |
set(flag "--remote") |
| 566 |
elseif("${arg}" STREQUAL "LOCKFILE") |
| 567 |
set(flag "--lockfile") |
| 568 |
elseif("${arg}" STREQUAL "LOCKFILE_OUT") |
| 569 |
set(flag "--lockfile-out") |
| 570 |
elseif("${arg}" STREQUAL "LOCKFILE_NODE_ID") |
| 571 |
set(flag "--lockfile-node-id") |
| 572 |
elseif("${arg}" STREQUAL "INSTALL_FOLDER") |
| 573 |
set(flag "--install-folder") |
| 574 |
elseif("${arg}" STREQUAL "OUTPUT_FOLDER") |
| 575 |
set(flag "--output-folder") |
| 576 |
endif() |
| 577 |
set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) |
| 578 |
endif() |
| 579 |
endforeach() |
| 580 |
foreach(arg ${installMultiValueArgs}) |
| 581 |
if(DEFINED ARGS_${arg}) |
| 582 |
if("${arg}" STREQUAL "GENERATOR") |
| 583 |
set(flag "--generator") |
| 584 |
elseif("${arg}" STREQUAL "BUILD") |
| 585 |
set(flag "--build") |
| 586 |
elseif("${arg}" STREQUAL "ENV") |
| 587 |
set(flag "--env") |
| 588 |
elseif("${arg}" STREQUAL "ENV_HOST") |
| 589 |
set(flag "--env:host") |
| 590 |
elseif("${arg}" STREQUAL "ENV_BUILD") |
| 591 |
set(flag "--env:build") |
| 592 |
elseif("${arg}" STREQUAL "OPTIONS") |
| 593 |
set(flag "--options") |
| 594 |
elseif("${arg}" STREQUAL "OPTIONS_HOST") |
| 595 |
set(flag "--options:host") |
| 596 |
elseif("${arg}" STREQUAL "OPTIONS_BUILD") |
| 597 |
set(flag "--options:build") |
| 598 |
elseif("${arg}" STREQUAL "PROFILE") |
| 599 |
set(flag "--profile") |
| 600 |
elseif("${arg}" STREQUAL "PROFILE_HOST") |
| 601 |
set(flag "--profile:host") |
| 602 |
elseif("${arg}" STREQUAL "PROFILE_BUILD") |
| 603 |
set(flag "--profile:build") |
| 604 |
elseif("${arg}" STREQUAL "SETTINGS") |
| 605 |
set(flag "--settings") |
| 606 |
elseif("${arg}" STREQUAL "SETTINGS_HOST") |
| 607 |
set(flag "--settings:host") |
| 608 |
elseif("${arg}" STREQUAL "SETTINGS_BUILD") |
| 609 |
set(flag "--settings:build") |
| 610 |
endif() |
| 611 |
list(LENGTH ARGS_${arg} numargs) |
| 612 |
foreach(item ${ARGS_${arg}}) |
| 613 |
if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") |
| 614 |
set(${arg} "--build") |
| 615 |
break() |
| 616 |
endif() |
| 617 |
set(${arg} ${${arg}} ${flag} ${item}) |
| 618 |
endforeach() |
| 619 |
endif() |
| 620 |
endforeach() |
| 621 |
if(DEFINED UPDATE) |
| 622 |
set(UPDATE --update) |
| 623 |
endif() |
| 624 |
if(DEFINED NO_IMPORTS) |
| 625 |
set(NO_IMPORTS --no-imports) |
| 626 |
endif() |
| 627 |
set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} ${OUTPUT_FOLDER} |
| 628 |
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} |
| 629 |
${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) |
| 630 |
|
| 631 |
string(REPLACE ";" " " _install_args "${install_args}") |
| 632 |
message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") |
| 633 |
|
| 634 |
if(ARGS_OUTPUT_QUIET) |
| 635 |
set(OUTPUT_OPT OUTPUT_QUIET) |
| 636 |
endif() |
| 637 |
if(ARGS_ERROR_QUIET) |
| 638 |
set(ERROR_OPT ERROR_QUIET) |
| 639 |
endif() |
| 640 |
|
| 641 |
execute_process(COMMAND ${CONAN_CMD} ${install_args} |
| 642 |
RESULT_VARIABLE return_code |
| 643 |
${OUTPUT_OPT} |
| 644 |
${ERROR_OPT} |
| 645 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 646 |
|
| 647 |
if(NOT "${return_code}" STREQUAL "0") |
| 648 |
if (ARGS_ERROR_QUIET) |
| 649 |
message(WARNING "Conan install failed='${return_code}'") |
| 650 |
else() |
| 651 |
message(FATAL_ERROR "Conan install failed='${return_code}'") |
| 652 |
endif() |
| 653 |
endif() |
| 654 |
|
| 655 |
endfunction() |
| 656 |
|
| 657 |
function(conan_cmake_lock_create) |
| 658 |
if(DEFINED CONAN_COMMAND) |
| 659 |
set(CONAN_CMD ${CONAN_COMMAND}) |
| 660 |
else() |
| 661 |
conan_check(REQUIRED) |
| 662 |
endif() |
| 663 |
|
| 664 |
set(lockCreateOptions UPDATE BASE OUTPUT_QUIET ERROR_QUIET) |
| 665 |
set(lockCreateOneValueArgs PATH REFERENCE REMOTE LOCKFILE LOCKFILE_OUT) |
| 666 |
set(lockCreateMultiValueArgs BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE |
| 667 |
PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) |
| 668 |
cmake_parse_arguments(ARGS "${lockCreateOptions}" "${lockCreateOneValueArgs}" "${lockCreateMultiValueArgs}" ${ARGN}) |
| 669 |
foreach(arg ${lockCreateOptions}) |
| 670 |
if(ARGS_${arg}) |
| 671 |
set(${arg} ${${arg}} ${ARGS_${arg}}) |
| 672 |
endif() |
| 673 |
endforeach() |
| 674 |
foreach(arg ${lockCreateOneValueArgs}) |
| 675 |
if(DEFINED ARGS_${arg}) |
| 676 |
if("${arg}" STREQUAL "REMOTE") |
| 677 |
set(flag "--remote") |
| 678 |
elseif("${arg}" STREQUAL "LOCKFILE") |
| 679 |
set(flag "--lockfile") |
| 680 |
elseif("${arg}" STREQUAL "LOCKFILE_OUT") |
| 681 |
set(flag "--lockfile-out") |
| 682 |
endif() |
| 683 |
set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) |
| 684 |
endif() |
| 685 |
endforeach() |
| 686 |
foreach(arg ${lockCreateMultiValueArgs}) |
| 687 |
if(DEFINED ARGS_${arg}) |
| 688 |
if("${arg}" STREQUAL "BUILD") |
| 689 |
set(flag "--build") |
| 690 |
elseif("${arg}" STREQUAL "ENV") |
| 691 |
set(flag "--env") |
| 692 |
elseif("${arg}" STREQUAL "ENV_HOST") |
| 693 |
set(flag "--env:host") |
| 694 |
elseif("${arg}" STREQUAL "ENV_BUILD") |
| 695 |
set(flag "--env:build") |
| 696 |
elseif("${arg}" STREQUAL "OPTIONS") |
| 697 |
set(flag "--options") |
| 698 |
elseif("${arg}" STREQUAL "OPTIONS_HOST") |
| 699 |
set(flag "--options:host") |
| 700 |
elseif("${arg}" STREQUAL "OPTIONS_BUILD") |
| 701 |
set(flag "--options:build") |
| 702 |
elseif("${arg}" STREQUAL "PROFILE") |
| 703 |
set(flag "--profile") |
| 704 |
elseif("${arg}" STREQUAL "PROFILE_HOST") |
| 705 |
set(flag "--profile:host") |
| 706 |
elseif("${arg}" STREQUAL "PROFILE_BUILD") |
| 707 |
set(flag "--profile:build") |
| 708 |
elseif("${arg}" STREQUAL "SETTINGS") |
| 709 |
set(flag "--settings") |
| 710 |
elseif("${arg}" STREQUAL "SETTINGS_HOST") |
| 711 |
set(flag "--settings:host") |
| 712 |
elseif("${arg}" STREQUAL "SETTINGS_BUILD") |
| 713 |
set(flag "--settings:build") |
| 714 |
endif() |
| 715 |
list(LENGTH ARGS_${arg} numargs) |
| 716 |
foreach(item ${ARGS_${arg}}) |
| 717 |
if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") |
| 718 |
set(${arg} "--build") |
| 719 |
break() |
| 720 |
endif() |
| 721 |
set(${arg} ${${arg}} ${flag} ${item}) |
| 722 |
endforeach() |
| 723 |
endif() |
| 724 |
endforeach() |
| 725 |
if(DEFINED UPDATE) |
| 726 |
set(UPDATE --update) |
| 727 |
endif() |
| 728 |
if(DEFINED BASE) |
| 729 |
set(BASE --base) |
| 730 |
endif() |
| 731 |
set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} |
| 732 |
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} |
| 733 |
${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) |
| 734 |
|
| 735 |
string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}") |
| 736 |
message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}") |
| 737 |
|
| 738 |
if(ARGS_OUTPUT_QUIET) |
| 739 |
set(OUTPUT_OPT OUTPUT_QUIET) |
| 740 |
endif() |
| 741 |
if(ARGS_ERROR_QUIET) |
| 742 |
set(ERROR_OPT ERROR_QUIET) |
| 743 |
endif() |
| 744 |
|
| 745 |
execute_process(COMMAND ${CONAN_CMD} ${lock_create_Args} |
| 746 |
RESULT_VARIABLE return_code |
| 747 |
${OUTPUT_OPT} |
| 748 |
${ERROR_OPT} |
| 749 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 750 |
|
| 751 |
if(NOT "${return_code}" STREQUAL "0") |
| 752 |
if (ARGS_ERROR_QUIET) |
| 753 |
message(WARNING "Conan lock create failed='${return_code}'") |
| 754 |
else() |
| 755 |
message(FATAL_ERROR "Conan lock create failed='${return_code}'") |
| 756 |
endif() |
| 757 |
endif() |
| 758 |
endfunction() |
| 759 |
|
| 760 |
function(conan_cmake_setup_conanfile) |
| 761 |
conan_parse_arguments(${ARGV}) |
| 762 |
if(ARGUMENTS_CONANFILE) |
| 763 |
get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) |
| 764 |
# configure_file will make sure cmake re-runs when conanfile is updated |
| 765 |
configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY) |
| 766 |
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) |
| 767 |
else() |
| 768 |
conan_cmake_generate_conanfile(ON ${ARGV}) |
| 769 |
endif() |
| 770 |
endfunction() |
| 771 |
|
| 772 |
function(conan_cmake_configure) |
| 773 |
conan_cmake_generate_conanfile(OFF ${ARGV}) |
| 774 |
endfunction() |
| 775 |
|
| 776 |
# Generate, writing in disk a conanfile.txt with the requires, options, and imports |
| 777 |
# specified as arguments |
| 778 |
# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) |
| 779 |
function(conan_cmake_generate_conanfile DEFAULT_GENERATOR) |
| 780 |
|
| 781 |
conan_parse_arguments(${ARGV}) |
| 782 |
|
| 783 |
set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") |
| 784 |
file(WRITE ${_FN} "") |
| 785 |
|
| 786 |
if(DEFINED ARGUMENTS_REQUIRES) |
| 787 |
file(APPEND ${_FN} "[requires]\n") |
| 788 |
foreach(REQUIRE ${ARGUMENTS_REQUIRES}) |
| 789 |
file(APPEND ${_FN} ${REQUIRE} "\n") |
| 790 |
endforeach() |
| 791 |
endif() |
| 792 |
|
| 793 |
if (DEFAULT_GENERATOR OR DEFINED ARGUMENTS_GENERATORS) |
| 794 |
file(APPEND ${_FN} "[generators]\n") |
| 795 |
if (DEFAULT_GENERATOR) |
| 796 |
file(APPEND ${_FN} "cmake\n") |
| 797 |
endif() |
| 798 |
if (DEFINED ARGUMENTS_GENERATORS) |
| 799 |
foreach(GENERATOR ${ARGUMENTS_GENERATORS}) |
| 800 |
file(APPEND ${_FN} ${GENERATOR} "\n") |
| 801 |
endforeach() |
| 802 |
endif() |
| 803 |
endif() |
| 804 |
|
| 805 |
if(DEFINED ARGUMENTS_BUILD_REQUIRES) |
| 806 |
file(APPEND ${_FN} "[build_requires]\n") |
| 807 |
foreach(BUILD_REQUIRE ${ARGUMENTS_BUILD_REQUIRES}) |
| 808 |
file(APPEND ${_FN} ${BUILD_REQUIRE} "\n") |
| 809 |
endforeach() |
| 810 |
endif() |
| 811 |
|
| 812 |
if(DEFINED ARGUMENTS_IMPORTS) |
| 813 |
file(APPEND ${_FN} "[imports]\n") |
| 814 |
foreach(IMPORTS ${ARGUMENTS_IMPORTS}) |
| 815 |
file(APPEND ${_FN} ${IMPORTS} "\n") |
| 816 |
endforeach() |
| 817 |
endif() |
| 818 |
|
| 819 |
if(DEFINED ARGUMENTS_OPTIONS) |
| 820 |
file(APPEND ${_FN} "[options]\n") |
| 821 |
foreach(OPTION ${ARGUMENTS_OPTIONS}) |
| 822 |
file(APPEND ${_FN} ${OPTION} "\n") |
| 823 |
endforeach() |
| 824 |
endif() |
| 825 |
|
| 826 |
endfunction() |
| 827 |
|
| 828 |
|
| 829 |
macro(conan_load_buildinfo) |
| 830 |
if(CONAN_CMAKE_MULTI) |
| 831 |
set(_CONANBUILDINFO conanbuildinfo_multi.cmake) |
| 832 |
else() |
| 833 |
set(_CONANBUILDINFO conanbuildinfo.cmake) |
| 834 |
endif() |
| 835 |
if(ARGUMENTS_INSTALL_FOLDER) |
| 836 |
set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) |
| 837 |
else() |
| 838 |
set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) |
| 839 |
endif() |
| 840 |
# Checks for the existence of conanbuildinfo.cmake, and loads it |
| 841 |
# important that it is macro, so variables defined at parent scope |
| 842 |
if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") |
| 843 |
message(STATUS "Conan: Loading ${_CONANBUILDINFO}") |
| 844 |
include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) |
| 845 |
else() |
| 846 |
message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") |
| 847 |
endif() |
| 848 |
endmacro() |
| 849 |
|
| 850 |
|
| 851 |
macro(conan_cmake_run) |
| 852 |
conan_parse_arguments(${ARGV}) |
| 853 |
|
| 854 |
if(ARGUMENTS_CONFIGURATION_TYPES AND NOT CMAKE_CONFIGURATION_TYPES) |
| 855 |
message(WARNING "CONFIGURATION_TYPES should only be specified for multi-configuration generators") |
| 856 |
elseif(ARGUMENTS_CONFIGURATION_TYPES AND ARGUMENTS_BUILD_TYPE) |
| 857 |
message(WARNING "CONFIGURATION_TYPES and BUILD_TYPE arguments should not be defined at the same time.") |
| 858 |
endif() |
| 859 |
|
| 860 |
if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED |
| 861 |
AND NOT ARGUMENTS_BUILD_TYPE) |
| 862 |
set(CONAN_CMAKE_MULTI ON) |
| 863 |
if (NOT ARGUMENTS_CONFIGURATION_TYPES) |
| 864 |
set(ARGUMENTS_CONFIGURATION_TYPES "Release;Debug") |
| 865 |
endif() |
| 866 |
message(STATUS "Conan: Using cmake-multi generator") |
| 867 |
else() |
| 868 |
set(CONAN_CMAKE_MULTI OFF) |
| 869 |
endif() |
| 870 |
|
| 871 |
if(NOT CONAN_EXPORTED) |
| 872 |
conan_cmake_setup_conanfile(${ARGV}) |
| 873 |
if(CONAN_CMAKE_MULTI) |
| 874 |
foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES}) |
| 875 |
set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) |
| 876 |
conan_cmake_settings(settings ${ARGV}) |
| 877 |
old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) |
| 878 |
endforeach() |
| 879 |
set(CMAKE_BUILD_TYPE) |
| 880 |
else() |
| 881 |
conan_cmake_settings(settings ${ARGV}) |
| 882 |
old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) |
| 883 |
endif() |
| 884 |
endif() |
| 885 |
|
| 886 |
if (NOT ARGUMENTS_NO_LOAD) |
| 887 |
conan_load_buildinfo() |
| 888 |
endif() |
| 889 |
|
| 890 |
if(ARGUMENTS_BASIC_SETUP) |
| 891 |
foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS SKIP_STD) |
| 892 |
if(ARGUMENTS_${_option}) |
| 893 |
if(${_option} STREQUAL "CMAKE_TARGETS") |
| 894 |
list(APPEND _setup_options "TARGETS") |
| 895 |
else() |
| 896 |
list(APPEND _setup_options ${_option}) |
| 897 |
endif() |
| 898 |
endif() |
| 899 |
endforeach() |
| 900 |
conan_basic_setup(${_setup_options}) |
| 901 |
endif() |
| 902 |
endmacro() |
| 903 |
|
| 904 |
macro(conan_check) |
| 905 |
# Checks conan availability in PATH |
| 906 |
# Arguments REQUIRED, DETECT_QUIET and VERSION are optional |
| 907 |
# Example usage: |
| 908 |
# conan_check(VERSION 1.0.0 REQUIRED) |
| 909 |
set(options REQUIRED DETECT_QUIET) |
| 910 |
set(oneValueArgs VERSION) |
| 911 |
cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) |
| 912 |
if(NOT CONAN_DETECT_QUIET) |
| 913 |
message(STATUS "Conan: checking conan executable") |
| 914 |
endif() |
| 915 |
|
| 916 |
find_program(CONAN_CMD conan) |
| 917 |
if(NOT CONAN_CMD AND CONAN_REQUIRED) |
| 918 |
message(FATAL_ERROR "Conan executable not found! Please install conan.") |
| 919 |
endif() |
| 920 |
if(NOT CONAN_DETECT_QUIET) |
| 921 |
message(STATUS "Conan: Found program ${CONAN_CMD}") |
| 922 |
endif() |
| 923 |
execute_process(COMMAND ${CONAN_CMD} --version |
| 924 |
RESULT_VARIABLE return_code |
| 925 |
OUTPUT_VARIABLE CONAN_VERSION_OUTPUT |
| 926 |
ERROR_VARIABLE CONAN_VERSION_OUTPUT) |
| 927 |
|
| 928 |
if(NOT "${return_code}" STREQUAL "0") |
| 929 |
message(FATAL_ERROR "Conan --version failed='${return_code}'") |
| 930 |
endif() |
| 931 |
|
| 932 |
if(NOT CONAN_DETECT_QUIET) |
| 933 |
string(STRIP "${CONAN_VERSION_OUTPUT}" _CONAN_VERSION_OUTPUT) |
| 934 |
message(STATUS "Conan: Version found ${_CONAN_VERSION_OUTPUT}") |
| 935 |
endif() |
| 936 |
|
| 937 |
if(DEFINED CONAN_VERSION) |
| 938 |
string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO |
| 939 |
"${CONAN_VERSION_OUTPUT}") |
| 940 |
if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) |
| 941 |
message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ |
| 942 |
required: ${CONAN_VERSION}. Consider updating via 'pip \ |
| 943 |
install conan==${CONAN_VERSION}'.") |
| 944 |
endif() |
| 945 |
endif() |
| 946 |
endmacro() |
| 947 |
|
| 948 |
function(conan_add_remote) |
| 949 |
# Adds a remote |
| 950 |
# Arguments URL and NAME are required, INDEX, COMMAND and VERIFY_SSL are optional |
| 951 |
# Example usage: |
| 952 |
# conan_add_remote(NAME bincrafters INDEX 1 |
| 953 |
# URL https://api.bintray.com/conan/bincrafters/public-conan |
| 954 |
# VERIFY_SSL True) |
| 955 |
set(oneValueArgs URL NAME INDEX COMMAND VERIFY_SSL) |
| 956 |
cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) |
| 957 |
|
| 958 |
if(DEFINED CONAN_INDEX) |
| 959 |
set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") |
| 960 |
endif() |
| 961 |
if(DEFINED CONAN_COMMAND) |
| 962 |
set(CONAN_CMD ${CONAN_COMMAND}) |
| 963 |
else() |
| 964 |
conan_check(REQUIRED DETECT_QUIET) |
| 965 |
endif() |
| 966 |
set(CONAN_VERIFY_SSL_ARG "True") |
| 967 |
if(DEFINED CONAN_VERIFY_SSL) |
| 968 |
set(CONAN_VERIFY_SSL_ARG ${CONAN_VERIFY_SSL}) |
| 969 |
endif() |
| 970 |
message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL}) verify ssl (${CONAN_VERIFY_SSL_ARG})") |
| 971 |
execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG} |
| 972 |
RESULT_VARIABLE return_code) |
| 973 |
if(NOT "${return_code}" STREQUAL "0") |
| 974 |
message(FATAL_ERROR "Conan remote failed='${return_code}'") |
| 975 |
endif() |
| 976 |
endfunction() |
| 977 |
|
| 978 |
macro(conan_config_install) |
| 979 |
# install a full configuration from a local or remote zip file |
| 980 |
# Argument ITEM is required, arguments TYPE, SOURCE, TARGET and VERIFY_SSL are optional |
| 981 |
# Example usage: |
| 982 |
# conan_config_install(ITEM https://github.com/conan-io/cmake-conan.git |
| 983 |
# TYPE git SOURCE source-folder TARGET target-folder VERIFY_SSL false) |
| 984 |
set(oneValueArgs ITEM TYPE SOURCE TARGET VERIFY_SSL) |
| 985 |
set(multiValueArgs ARGS) |
| 986 |
cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
| 987 |
|
| 988 |
if(DEFINED CONAN_COMMAND) |
| 989 |
set(CONAN_CMD ${CONAN_COMMAND}) |
| 990 |
else() |
| 991 |
conan_check(REQUIRED) |
| 992 |
endif() |
| 993 |
|
| 994 |
if(DEFINED CONAN_VERIFY_SSL) |
| 995 |
set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}") |
| 996 |
endif() |
| 997 |
|
| 998 |
if(DEFINED CONAN_TYPE) |
| 999 |
set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}") |
| 1000 |
endif() |
| 1001 |
|
| 1002 |
if(DEFINED CONAN_ARGS) |
| 1003 |
set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"") |
| 1004 |
endif() |
| 1005 |
|
| 1006 |
if(DEFINED CONAN_SOURCE) |
| 1007 |
set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}") |
| 1008 |
endif() |
| 1009 |
|
| 1010 |
if(DEFINED CONAN_TARGET) |
| 1011 |
set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}") |
| 1012 |
endif() |
| 1013 |
|
| 1014 |
set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG} |
| 1015 |
${CONAN_TYPE_ARG} |
| 1016 |
${CONAN_ARGS_ARGS} |
| 1017 |
${CONAN_SOURCE_ARGS} |
| 1018 |
${CONAN_TARGET_ARGS}) |
| 1019 |
|
| 1020 |
message(STATUS "Conan: Installing config from ${CONAN_ITEM}") |
| 1021 |
execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS} |
| 1022 |
RESULT_VARIABLE return_code) |
| 1023 |
if(NOT "${return_code}" STREQUAL "0") |
| 1024 |
message(FATAL_ERROR "Conan config failed='${return_code}'") |
| 1025 |
endif() |
| 1026 |
endmacro() |