ferencd@0: # The MIT License (MIT) ferencd@0: ferencd@0: # Copyright (c) 2018 JFrog ferencd@0: ferencd@0: # Permission is hereby granted, free of charge, to any person obtaining a copy ferencd@0: # of this software and associated documentation files (the "Software"), to deal ferencd@0: # in the Software without restriction, including without limitation the rights ferencd@0: # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ferencd@0: # copies of the Software, and to permit persons to whom the Software is ferencd@0: # furnished to do so, subject to the following conditions: ferencd@0: ferencd@0: # The above copyright notice and this permission notice shall be included in all ferencd@0: # copies or substantial portions of the Software. ferencd@0: ferencd@0: # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ferencd@0: # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ferencd@0: # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ferencd@0: # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ferencd@0: # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ferencd@0: # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ferencd@0: # SOFTWARE. ferencd@0: ferencd@0: ferencd@0: ferencd@0: # This file comes from: https://github.com/conan-io/cmake-conan. Please refer ferencd@0: # to this repository for issues and documentation. ferencd@0: ferencd@0: # Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called. ferencd@0: # It will take CMake current settings (os, compiler, compiler version, architecture) ferencd@0: # and translate them to conan settings for installing and retrieving dependencies. ferencd@0: ferencd@0: # It is intended to facilitate developers building projects that have conan dependencies, ferencd@0: # but it is only necessary on the end-user side. It is not necessary to create conan ferencd@0: # packages, in fact it shouldn't be use for that. Check the project documentation. ferencd@0: ferencd@0: ferencd@0: include(CMakeParseArguments) ferencd@0: ferencd@0: function(_get_msvc_ide_version result) ferencd@0: set(${result} "" PARENT_SCOPE) ferencd@0: if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) ferencd@0: set(${result} 8 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) ferencd@0: set(${result} 9 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) ferencd@0: set(${result} 10 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) ferencd@0: set(${result} 11 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) ferencd@0: set(${result} 12 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) ferencd@0: set(${result} 14 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) ferencd@0: set(${result} 15 PARENT_SCOPE) ferencd@0: elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) ferencd@0: set(${result} 16 PARENT_SCOPE) ferencd@0: else() ferencd@0: message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") ferencd@0: endif() ferencd@0: endfunction() ferencd@0: ferencd@0: function(conan_cmake_settings result) ferencd@0: #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER}) ferencd@0: #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID}) ferencd@0: #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION}) ferencd@0: #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS}) ferencd@0: #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) ferencd@0: #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE}) ferencd@0: #message(STATUS "GENERATOR " ${CMAKE_GENERATOR}) ferencd@0: #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64}) ferencd@0: ferencd@0: message(STATUS "Conan: Automatic detection of conan settings from cmake") ferencd@0: ferencd@0: parse_arguments(${ARGV}) ferencd@0: ferencd@0: if(ARGUMENTS_BUILD_TYPE) ferencd@0: set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE}) ferencd@0: elseif(CMAKE_BUILD_TYPE) ferencd@0: set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE}) ferencd@0: else() ferencd@0: message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") ferencd@0: endif() ferencd@0: ferencd@0: string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER) ferencd@0: if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG") ferencd@0: set(_CONAN_SETTING_BUILD_TYPE "Debug") ferencd@0: elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE") ferencd@0: set(_CONAN_SETTING_BUILD_TYPE "Release") ferencd@0: elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") ferencd@0: set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo") ferencd@0: elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL") ferencd@0: set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel") ferencd@0: endif() ferencd@0: ferencd@0: if(ARGUMENTS_ARCH) ferencd@0: set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH}) ferencd@0: endif() ferencd@0: #handle -s os setting ferencd@0: if(CMAKE_SYSTEM_NAME) ferencd@0: #use default conan os setting if CMAKE_SYSTEM_NAME is not defined ferencd@0: set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) ferencd@0: if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") ferencd@0: set(CONAN_SYSTEM_NAME Macos) ferencd@0: endif() ferencd@0: set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore) ferencd@0: list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index) ferencd@0: if (${_index} GREATER -1) ferencd@0: #check if the cmake system is a conan supported one ferencd@0: set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME}) ferencd@0: else() ferencd@0: message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}") ferencd@0: endif() ferencd@0: endif() ferencd@0: ferencd@0: get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) ferencd@0: if (";${_languages};" MATCHES ";CXX;") ferencd@0: set(LANGUAGE CXX) ferencd@0: set(USING_CXX 1) ferencd@0: elseif (";${_languages};" MATCHES ";C;") ferencd@0: set(LANGUAGE C) ferencd@0: set(USING_CXX 0) ferencd@0: else () ferencd@0: message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.") ferencd@0: endif() ferencd@0: ferencd@0: if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) ferencd@0: # using GCC ferencd@0: # TODO: Handle other params ferencd@0: string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) ferencd@0: list(GET VERSION_LIST 0 MAJOR) ferencd@0: list(GET VERSION_LIST 1 MINOR) ferencd@0: set(COMPILER_VERSION ${MAJOR}.${MINOR}) ferencd@0: if(${MAJOR} GREATER 4) ferencd@0: set(COMPILER_VERSION ${MAJOR}) ferencd@0: endif() ferencd@0: set(_CONAN_SETTING_COMPILER gcc) ferencd@0: set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) ferencd@0: if (USING_CXX) ferencd@0: conan_cmake_detect_unix_libcxx(_LIBCXX) ferencd@0: set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) ferencd@0: endif () ferencd@0: elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang) ferencd@0: # using AppleClang ferencd@0: string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) ferencd@0: list(GET VERSION_LIST 0 MAJOR) ferencd@0: list(GET VERSION_LIST 1 MINOR) ferencd@0: set(_CONAN_SETTING_COMPILER apple-clang) ferencd@0: set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) ferencd@0: if (USING_CXX) ferencd@0: conan_cmake_detect_unix_libcxx(_LIBCXX) ferencd@0: set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) ferencd@0: endif () ferencd@0: elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang) ferencd@0: string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) ferencd@0: list(GET VERSION_LIST 0 MAJOR) ferencd@0: list(GET VERSION_LIST 1 MINOR) ferencd@0: set(_CONAN_SETTING_COMPILER clang) ferencd@0: set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) ferencd@0: if(APPLE) ferencd@0: cmake_policy(GET CMP0025 APPLE_CLANG_POLICY_ENABLED) ferencd@0: if(NOT APPLE_CLANG_POLICY_ENABLED) ferencd@0: message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it") ferencd@0: set(_CONAN_SETTING_COMPILER apple-clang) ferencd@0: endif() ferencd@0: endif() ferencd@0: if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7) ferencd@0: set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}) ferencd@0: endif() ferencd@0: if (USING_CXX) ferencd@0: conan_cmake_detect_unix_libcxx(_LIBCXX) ferencd@0: set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) ferencd@0: endif () ferencd@0: elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC) ferencd@0: set(_VISUAL "Visual Studio") ferencd@0: _get_msvc_ide_version(_VISUAL_VERSION) ferencd@0: if("${_VISUAL_VERSION}" STREQUAL "") ferencd@0: message(FATAL_ERROR "Conan: Visual Studio not recognized") ferencd@0: else() ferencd@0: set(_CONAN_SETTING_COMPILER ${_VISUAL}) ferencd@0: set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION}) ferencd@0: endif() ferencd@0: ferencd@0: if(NOT _CONAN_SETTING_ARCH) ferencd@0: if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64") ferencd@0: set(_CONAN_SETTING_ARCH x86_64) ferencd@0: elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM") ferencd@0: message(STATUS "Conan: Using default ARM architecture from MSVC") ferencd@0: set(_CONAN_SETTING_ARCH armv6) ferencd@0: elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86") ferencd@0: set(_CONAN_SETTING_ARCH x86) ferencd@0: else () ferencd@0: message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]") ferencd@0: endif() ferencd@0: endif() ferencd@0: ferencd@0: conan_cmake_detect_vs_runtime(_vs_runtime) ferencd@0: message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}") ferencd@0: set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime}) ferencd@0: ferencd@0: if (CMAKE_GENERATOR_TOOLSET) ferencd@0: set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) ferencd@0: elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja")) ferencd@0: set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) ferencd@0: endif() ferencd@0: else() ferencd@0: message(FATAL_ERROR "Conan: compiler setup not recognized") ferencd@0: endif() ferencd@0: ferencd@0: # If profile is defined it is used ferencd@0: if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE) ferencd@0: set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE}) ferencd@0: elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE) ferencd@0: set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE}) ferencd@0: elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE) ferencd@0: set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE}) ferencd@0: elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE) ferencd@0: set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE}) ferencd@0: elseif(ARGUMENTS_PROFILE) ferencd@0: set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE}) ferencd@0: endif() ferencd@0: ferencd@0: foreach(ARG ${_APPLIED_PROFILES}) ferencd@0: set(_SETTINGS ${_SETTINGS} -pr ${ARG}) ferencd@0: endforeach() ferencd@0: ferencd@0: if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") ferencd@0: set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version ferencd@0: compiler.runtime compiler.libcxx compiler.toolset) ferencd@0: endif() ferencd@0: ferencd@0: # Automatic from CMake ferencd@0: foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) ferencd@0: string(TOUPPER ${ARG} _arg_name) ferencd@0: string(REPLACE "." "_" _arg_name ${_arg_name}) ferencd@0: if(_CONAN_SETTING_${_arg_name}) ferencd@0: set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}}) ferencd@0: endif() ferencd@0: endforeach() ferencd@0: ferencd@0: foreach(ARG ${ARGUMENTS_SETTINGS}) ferencd@0: set(_SETTINGS ${_SETTINGS} -s ${ARG}) ferencd@0: endforeach() ferencd@0: ferencd@0: message(STATUS "Conan: Settings= ${_SETTINGS}") ferencd@0: ferencd@0: set(${result} ${_SETTINGS} PARENT_SCOPE) ferencd@0: endfunction() ferencd@0: ferencd@0: ferencd@0: function(conan_cmake_detect_unix_libcxx result) ferencd@0: # Take into account any -stdlib in compile options ferencd@0: get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) ferencd@0: ferencd@0: # Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions ferencd@0: get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) ferencd@0: foreach(define ${defines}) ferencd@0: if(define MATCHES "_GLIBCXX_USE_CXX11_ABI") ferencd@0: if(define MATCHES "^-D") ferencd@0: set(compile_options ${compile_options} "${define}") ferencd@0: else() ferencd@0: set(compile_options ${compile_options} "-D${define}") ferencd@0: endif() ferencd@0: endif() ferencd@0: endforeach() ferencd@0: ferencd@0: execute_process( ferencd@0: COMMAND ${CMAKE_COMMAND} -E echo "#include " ferencd@0: COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM - ferencd@0: OUTPUT_VARIABLE string_defines ferencd@0: ) ferencd@0: ferencd@0: if(string_defines MATCHES "#define __GLIBCXX__") ferencd@0: # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake ferencd@0: if(DEFINED _GLIBCXX_USE_CXX11_ABI) ferencd@0: if(_GLIBCXX_USE_CXX11_ABI) ferencd@0: set(${result} libstdc++11 PARENT_SCOPE) ferencd@0: return() ferencd@0: else() ferencd@0: set(${result} libstdc++ PARENT_SCOPE) ferencd@0: return() ferencd@0: endif() ferencd@0: endif() ferencd@0: ferencd@0: if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") ferencd@0: set(${result} libstdc++11 PARENT_SCOPE) ferencd@0: else() ferencd@0: # Either the compiler is missing the define because it is old, and so ferencd@0: # it can't use the new abi, or the compiler was configured to use the ferencd@0: # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) ferencd@0: set(${result} libstdc++ PARENT_SCOPE) ferencd@0: endif() ferencd@0: else() ferencd@0: set(${result} libc++ PARENT_SCOPE) ferencd@0: endif() ferencd@0: endfunction() ferencd@0: ferencd@0: function(conan_cmake_detect_vs_runtime result) ferencd@0: string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) ferencd@0: set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) ferencd@0: foreach(variable ${variables}) ferencd@0: string(REPLACE " " ";" flags ${${variable}}) ferencd@0: foreach (flag ${flags}) ferencd@0: if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd") ferencd@0: string(SUBSTRING ${flag} 1 -1 runtime) ferencd@0: set(${result} ${runtime} PARENT_SCOPE) ferencd@0: return() ferencd@0: endif() ferencd@0: endforeach() ferencd@0: endforeach() ferencd@0: if(${build_type} STREQUAL "DEBUG") ferencd@0: set(${result} "MDd" PARENT_SCOPE) ferencd@0: else() ferencd@0: set(${result} "MD" PARENT_SCOPE) ferencd@0: endif() ferencd@0: endfunction() ferencd@0: ferencd@0: ferencd@0: macro(parse_arguments) ferencd@0: set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS) ferencd@0: set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND) ferencd@0: set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE ferencd@0: PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO ferencd@0: INSTALL_ARGS) ferencd@0: cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) ferencd@0: endmacro() ferencd@0: ferencd@0: function(conan_cmake_install) ferencd@0: # Calls "conan install" ferencd@0: # Argument BUILD is equivalant to --build={missing, PkgName,...} or ferencd@0: # --build when argument is 'BUILD all' (which builds all packages from source) ferencd@0: # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source ferencd@0: # cmake does not identify conan as command, even if it is +x and it is in the path ferencd@0: parse_arguments(${ARGV}) ferencd@0: ferencd@0: if(CONAN_CMAKE_MULTI) ferencd@0: set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) ferencd@0: else() ferencd@0: set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) ferencd@0: endif() ferencd@0: ferencd@0: set(CONAN_BUILD_POLICY "") ferencd@0: foreach(ARG ${ARGUMENTS_BUILD}) ferencd@0: if(${ARG} STREQUAL "all") ferencd@0: set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) ferencd@0: break() ferencd@0: else() ferencd@0: set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) ferencd@0: endif() ferencd@0: endforeach() ferencd@0: if(ARGUMENTS_CONAN_COMMAND) ferencd@0: set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND}) ferencd@0: else() ferencd@0: conan_check(REQUIRED) ferencd@0: endif() ferencd@0: set(CONAN_OPTIONS "") ferencd@0: if(ARGUMENTS_CONANFILE) ferencd@0: set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) ferencd@0: # A conan file has been specified - apply specified options as well if provided ferencd@0: foreach(ARG ${ARGUMENTS_OPTIONS}) ferencd@0: set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) ferencd@0: endforeach() ferencd@0: else() ferencd@0: set(CONANFILE ".") ferencd@0: endif() ferencd@0: if(ARGUMENTS_UPDATE) ferencd@0: set(CONAN_INSTALL_UPDATE --update) ferencd@0: endif() ferencd@0: if(ARGUMENTS_NO_IMPORTS) ferencd@0: set(CONAN_INSTALL_NO_IMPORTS --no-imports) ferencd@0: endif() ferencd@0: set(CONAN_INSTALL_FOLDER "") ferencd@0: if(ARGUMENTS_INSTALL_FOLDER) ferencd@0: set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) ferencd@0: endif() ferencd@0: foreach(ARG ${ARGUMENTS_GENERATORS}) ferencd@0: set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) ferencd@0: endforeach() ferencd@0: foreach(ARG ${ARGUMENTS_ENV}) ferencd@0: set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) ferencd@0: endforeach() ferencd@0: 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: ferencd@0: string (REPLACE ";" " " _conan_args "${conan_args}") ferencd@0: message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}") ferencd@0: ferencd@0: if(ARGUMENTS_OUTPUT_QUIET) ferencd@0: execute_process(COMMAND ${CONAN_CMD} ${conan_args} ferencd@0: RESULT_VARIABLE return_code ferencd@0: OUTPUT_VARIABLE conan_output ferencd@0: ERROR_VARIABLE conan_output ferencd@0: WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ferencd@0: else() ferencd@0: execute_process(COMMAND ${CONAN_CMD} ${conan_args} ferencd@0: RESULT_VARIABLE return_code ferencd@0: WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ferencd@0: endif() ferencd@0: ferencd@0: if(NOT "${return_code}" STREQUAL "0") ferencd@0: message(FATAL_ERROR "Conan install failed='${return_code}'") ferencd@0: endif() ferencd@0: ferencd@0: endfunction() ferencd@0: ferencd@0: ferencd@0: function(conan_cmake_setup_conanfile) ferencd@0: parse_arguments(${ARGV}) ferencd@0: if(ARGUMENTS_CONANFILE) ferencd@0: get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) ferencd@0: # configure_file will make sure cmake re-runs when conanfile is updated ferencd@0: configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) ferencd@0: file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) ferencd@0: else() ferencd@0: conan_cmake_generate_conanfile(${ARGV}) ferencd@0: endif() ferencd@0: endfunction() ferencd@0: ferencd@0: function(conan_cmake_generate_conanfile) ferencd@0: # Generate, writing in disk a conanfile.txt with the requires, options, and imports ferencd@0: # specified as arguments ferencd@0: # This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) ferencd@0: parse_arguments(${ARGV}) ferencd@0: set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") ferencd@0: ferencd@0: file(WRITE ${_FN} "[generators]\ncmake\n\n[requires]\n") ferencd@0: foreach(ARG ${ARGUMENTS_REQUIRES}) ferencd@0: file(APPEND ${_FN} ${ARG} "\n") ferencd@0: endforeach() ferencd@0: ferencd@0: file(APPEND ${_FN} ${ARG} "\n[options]\n") ferencd@0: foreach(ARG ${ARGUMENTS_OPTIONS}) ferencd@0: file(APPEND ${_FN} ${ARG} "\n") ferencd@0: endforeach() ferencd@0: ferencd@0: file(APPEND ${_FN} ${ARG} "\n[imports]\n") ferencd@0: foreach(ARG ${ARGUMENTS_IMPORTS}) ferencd@0: file(APPEND ${_FN} ${ARG} "\n") ferencd@0: endforeach() ferencd@0: endfunction() ferencd@0: ferencd@0: ferencd@0: macro(conan_load_buildinfo) ferencd@0: if(CONAN_CMAKE_MULTI) ferencd@0: set(_CONANBUILDINFO conanbuildinfo_multi.cmake) ferencd@0: else() ferencd@0: set(_CONANBUILDINFO conanbuildinfo.cmake) ferencd@0: endif() ferencd@0: if(ARGUMENTS_INSTALL_FOLDER) ferencd@0: set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) ferencd@0: else() ferencd@0: set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) ferencd@0: endif() ferencd@0: # Checks for the existence of conanbuildinfo.cmake, and loads it ferencd@0: # important that it is macro, so variables defined at parent scope ferencd@0: if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") ferencd@0: message(STATUS "Conan: Loading ${_CONANBUILDINFO}") ferencd@0: include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) ferencd@0: else() ferencd@0: message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") ferencd@0: endif() ferencd@0: endmacro() ferencd@0: ferencd@0: ferencd@0: macro(conan_cmake_run) ferencd@0: parse_arguments(${ARGV}) ferencd@0: ferencd@0: if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED ferencd@0: AND NOT ARGUMENTS_BUILD_TYPE) ferencd@0: set(CONAN_CMAKE_MULTI ON) ferencd@0: message(STATUS "Conan: Using cmake-multi generator") ferencd@0: else() ferencd@0: set(CONAN_CMAKE_MULTI OFF) ferencd@0: endif() ferencd@0: ferencd@0: if(NOT CONAN_EXPORTED) ferencd@0: conan_cmake_setup_conanfile(${ARGV}) ferencd@0: if(CONAN_CMAKE_MULTI) ferencd@0: foreach(CMAKE_BUILD_TYPE "Release" "Debug") ferencd@0: set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) ferencd@0: conan_cmake_settings(settings ${ARGV}) ferencd@0: conan_cmake_install(SETTINGS ${settings} ${ARGV}) ferencd@0: endforeach() ferencd@0: set(CMAKE_BUILD_TYPE) ferencd@0: else() ferencd@0: conan_cmake_settings(settings ${ARGV}) ferencd@0: conan_cmake_install(SETTINGS ${settings} ${ARGV}) ferencd@0: endif() ferencd@0: endif() ferencd@0: ferencd@0: if (NOT ARGUMENTS_NO_LOAD) ferencd@0: conan_load_buildinfo() ferencd@0: endif() ferencd@0: ferencd@0: if(ARGUMENTS_BASIC_SETUP) ferencd@0: foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS) ferencd@0: if(ARGUMENTS_${_option}) ferencd@0: if(${_option} STREQUAL "CMAKE_TARGETS") ferencd@0: list(APPEND _setup_options "TARGETS") ferencd@0: else() ferencd@0: list(APPEND _setup_options ${_option}) ferencd@0: endif() ferencd@0: endif() ferencd@0: endforeach() ferencd@0: conan_basic_setup(${_setup_options}) ferencd@0: endif() ferencd@0: endmacro() ferencd@0: ferencd@0: macro(conan_check) ferencd@0: # Checks conan availability in PATH ferencd@0: # Arguments REQUIRED and VERSION are optional ferencd@0: # Example usage: ferencd@0: # conan_check(VERSION 1.0.0 REQUIRED) ferencd@0: message(STATUS "Conan: checking conan executable") ferencd@0: set(options REQUIRED) ferencd@0: set(oneValueArgs VERSION) ferencd@0: cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) ferencd@0: ferencd@0: find_program(CONAN_CMD conan) ferencd@0: if(NOT CONAN_CMD AND CONAN_REQUIRED) ferencd@0: message(FATAL_ERROR "Conan executable not found!") ferencd@0: endif() ferencd@0: message(STATUS "Conan: Found program ${CONAN_CMD}") ferencd@0: execute_process(COMMAND ${CONAN_CMD} --version ferencd@0: OUTPUT_VARIABLE CONAN_VERSION_OUTPUT ferencd@0: ERROR_VARIABLE CONAN_VERSION_OUTPUT) ferencd@0: message(STATUS "Conan: Version found ${CONAN_VERSION_OUTPUT}") ferencd@0: ferencd@0: if(DEFINED CONAN_VERSION) ferencd@0: string(REGEX MATCH ".*Conan version ([0-9]+\.[0-9]+\.[0-9]+)" FOO ferencd@0: "${CONAN_VERSION_OUTPUT}") ferencd@0: if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) ferencd@0: message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ ferencd@0: required: ${CONAN_VERSION}. Consider updating via 'pip \ ferencd@0: install conan==${CONAN_VERSION}'.") ferencd@0: endif() ferencd@0: endif() ferencd@0: endmacro() ferencd@0: ferencd@0: function(conan_add_remote) ferencd@0: # Adds a remote ferencd@0: # Arguments URL and NAME are required, INDEX and COMMAND are optional ferencd@0: # Example usage: ferencd@0: # conan_add_remote(NAME bincrafters INDEX 1 ferencd@0: # URL https://api.bintray.com/conan/bincrafters/public-conan) ferencd@0: set(oneValueArgs URL NAME INDEX COMMAND) ferencd@0: cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) ferencd@0: ferencd@0: if(DEFINED CONAN_INDEX) ferencd@0: set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") ferencd@0: endif() ferencd@0: if(CONAN_COMMAND) ferencd@0: set(CONAN_CMD ${CONAN_COMMAND}) ferencd@0: else() ferencd@0: conan_check(REQUIRED) ferencd@0: endif() ferencd@0: message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL})") ferencd@0: execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_URL} ferencd@0: ${CONAN_INDEX_ARG} -f) ferencd@0: endfunction()