diff --git a/README.md b/README.md index cf29c0f8..42b86cee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ CMake wrapper for the Conan C and C++ package manager. -> :warning: **Compatibility with Conan 2.0**: please check for experimental support in +> :warning: The recommended production version is Conan 2. This ``cmake-conan`` integration for Conan 1.X is no longer +mantained, please upgrade to the ``cmake-conan`` integration for Conan 2 in the [develop2](https://github.com/conan-io/cmake-conan/tree/develop2) branch. diff --git a/conan.cmake b/conan.cmake index 45793943..abfe7db7 100644 --- a/conan.cmake +++ b/conan.cmake @@ -55,7 +55,7 @@ function(_get_msvc_ide_version result) set(${result} 15 PARENT_SCOPE) elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) set(${result} 16 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS_EQUAL 1940) + elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1950) set(${result} 17 PARENT_SCOPE) else() message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") @@ -146,7 +146,7 @@ macro(_conan_detect_compiler) set(COMPILER_VERSION ${MAJOR}) else() set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() + endif() elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL QCC) set(_CONAN_SETTING_COMPILER qcc) set(COMPILER_VERSION ${MAJOR}.${MINOR}) @@ -180,7 +180,7 @@ macro(_conan_detect_compiler) set(COMPILER_VERSION ${MAJOR}) else() set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() + endif() set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) @@ -190,7 +190,7 @@ macro(_conan_detect_compiler) set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) endif () elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang - AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" + AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC") string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) @@ -203,7 +203,7 @@ macro(_conan_detect_compiler) set(COMPILER_VERSION ${MAJOR}) else() set(COMPILER_VERSION ${MAJOR}.${MINOR}) - endif() + endif() set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) @@ -219,8 +219,8 @@ macro(_conan_detect_compiler) set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) endif () elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC - OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang - AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" + OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang + AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")) set(_VISUAL "Visual Studio") @@ -418,6 +418,7 @@ function(conan_cmake_detect_unix_libcxx result) endfunction() function(conan_cmake_detect_vs_runtime result) + conan_parse_arguments(${ARGV}) if(ARGUMENTS_BUILD_TYPE) set(build_type "${ARGUMENTS_BUILD_TYPE}") @@ -430,52 +431,23 @@ function(conan_cmake_detect_vs_runtime result) if(build_type) string(TOUPPER "${build_type}" build_type) endif() - - set(cmp_ninetyone OLD) - if(POLICY CMP0091) - cmake_policy(GET CMP0091 cmp_ninetyone) - endif() - set(static_runtime OFF) - if(cmp_ninetyone STREQUAL "NEW") - if(NOT "${CMAKE_MSVC_RUNTIME_LIBRARY}" STREQUAL "") - string(STRIP ${CMAKE_MSVC_RUNTIME_LIBRARY} runtime_library) - string(TOUPPER ${CMAKE_MSVC_RUNTIME_LIBRARY} runtime_library_upper) - string(LENGTH ${runtime_library_upper} runtime_library_length) - if(${runtime_library_length} GREATER_EQUAL 3) - math(EXPR runtime_library_begin "${runtime_library_length}-3") - string(SUBSTRING ${runtime_library_upper} ${runtime_library_begin} 3 runtime_library_tail) - if(NOT "${runtime_library_tail}" STREQUAL "DLL") - set(static_runtime ON) + set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) + foreach(variable ${variables}) + if(NOT "${${variable}}" STREQUAL "") + string(REPLACE " " ";" flags "${${variable}}") + foreach (flag ${flags}) + if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") + string(SUBSTRING "${flag}" 1 -1 runtime) + set(${result} "${runtime}" PARENT_SCOPE) + return() endif() - endif() - endif() - else() - set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) - foreach(variable ${variables}) - if(NOT "${${variable}}" STREQUAL "") - string(REPLACE " " ";" flags "${${variable}}") - foreach (flag ${flags}) - if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") - string(SUBSTRING "${flag}" 1 -1 runtime) - set(${result} "${runtime}" PARENT_SCOPE) - return() - endif() - endforeach() - endif() - endforeach() - endif() - if(${static_runtime} STREQUAL "ON") - if("${build_type}" STREQUAL "DEBUG") - set(${result} "MTd" PARENT_SCOPE) - else() - set(${result} "MT" PARENT_SCOPE) + endforeach() endif() + endforeach() + if("${build_type}" STREQUAL "DEBUG") + set(${result} "MDd" PARENT_SCOPE) else() - if("${build_type}" STREQUAL "DEBUG") - set(${result} "MDd" PARENT_SCOPE) - else() - set(${result} "MD" PARENT_SCOPE) - endif() + set(${result} "MD" PARENT_SCOPE) endif() endfunction() @@ -503,7 +475,7 @@ function(conan_cmake_autodetect detected_settings) endfunction() macro(conan_parse_arguments) - set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS + set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD) set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE @@ -684,10 +656,12 @@ function(conan_cmake_install) if(DEFINED NO_IMPORTS) set(NO_IMPORTS --no-imports) endif() - set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} - ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} - ${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} - ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}${CONF} ${CONF_HOST} ${CONF_BUILD}) + set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} + ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} + ${OUTPUT_FOLDER} ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} + ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST} + ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD} + ${CONF} ${CONF_HOST} ${CONF_BUILD}) string(REPLACE ";" " " _install_args "${install_args}") message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") @@ -790,12 +764,12 @@ function(conan_cmake_lock_create) set(BASE --base) endif() set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} - ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} + ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}") message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}") - + if(ARGS_OUTPUT_QUIET) set(OUTPUT_OPT OUTPUT_QUIET) endif() @@ -1007,6 +981,7 @@ macro(conan_check) endif() conan_version(CONAN_DETECTED_VERSION) + if(NOT CONAN_DETECT_QUIET) message(STATUS "Conan: Version found ${CONAN_DETECTED_VERSION}") endif() @@ -1108,7 +1083,7 @@ function(conan_cmake_profile) set(profileMultiValueArgs SETTINGS OPTIONS CONF ENV BUILDENV RUNENV TOOL_REQUIRES) cmake_parse_arguments(ARGS "" "${profileOneValueArgs}" "${profileMultiValueArgs}" ${ARGN}) - if(DEFINED ARGS_FILEPATH) + if(DEFINED ARGS_FILEPATH) set(_FN "${ARGS_FILEPATH}") else() set(_FN "${CMAKE_CURRENT_BINARY_DIR}/profile")