@@ -343,9 +343,7 @@ macro(_conan_detect_compiler)
343
343
AND "${CMAKE_${LANGUAGE} _SIMULATE_ID}" STREQUAL "MSVC" ))
344
344
# Using MSVC compilers.
345
345
346
- conan_version(CONAN_VERSION)
347
- if (${CONAN_VERSION} VERSION_LESS "2.0.0" )
348
- # Conan 1.0
346
+ if (NOT MODE_CONAN_V2)
349
347
# Detect 'Visual Studio' compiler settings.
350
348
351
349
# Detect 'compiler' and 'compiler.version' settings.
@@ -384,7 +382,6 @@ macro(_conan_detect_compiler)
384
382
set (_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET} )
385
383
endif ()
386
384
else ()
387
- # Conan 2.0
388
385
# Detect 'msvc' compiler settings.
389
386
390
387
# Detect 'compiler' and 'compiler.version' settings.
@@ -625,6 +622,21 @@ function(_collect_settings result)
625
622
endfunction ()
626
623
627
624
function (conan_cmake_autodetect detected_settings)
625
+ # Detect whether CONAN_V2 is specified with ON:
626
+ # - If CONAN_V2 is specified with ON, then MODE_CONAN_V2 will be ON.
627
+ # - Otherwise:
628
+ # - If current Conan version is 1.0, then set MODE_CONAN_V2 to OFF.
629
+ # - If current Conan version is 2.0, then set MODE_CONAN_V2 TO ON.
630
+ set (autodetectOneValueArgs CONAN_V2)
631
+ cmake_parse_arguments (MODE "" "${autodetectOneValueArgs} " "" ${ARGV} )
632
+ if (NOT MODE_CONAN_V2)
633
+ conan_version(CONAN_VERSION)
634
+ if (CONAN_VERSION VERSION_LESS "2.0.0" )
635
+ set (MODE_CONAN_V2 OFF )
636
+ else ()
637
+ set (MODE_CONAN_V2 ON )
638
+ endif ()
639
+ endif ()
628
640
_conan_detect_build_type(${ARGV} )
629
641
_conan_check_system_name()
630
642
_conan_check_language()
0 commit comments