diff --git a/conans/client/build/cmake.py b/conans/client/build/cmake.py index 0006d862268..d9a668b37fe 100644 --- a/conans/client/build/cmake.py +++ b/conans/client/build/cmake.py @@ -47,8 +47,14 @@ def __init__(self, conanfile, generator=None, cmake_system_name=True, :param generator_platform: Generator platform name or none to autodetect (-A cmake option) """ if getattr(conanfile, "must_use_new_helpers", None): - raise ConanException("Using the wrong 'CMake' helper. To use CMakeDeps, CMakeToolchain " - "you should use 'from conan.tools.cmake import CMake'") + wrong_helper_msg = "Using the wrong 'CMake' helper. To use CMakeDeps, CMakeToolchain "\ + "you should use 'from conan.tools.cmake import CMake'. "\ + "Set environment variable CONAN_DISABLE_STRICT_MODE=1 to override "\ + "this check (should only be used to build old packages)." + if get_env("CONAN_DISABLE_STRICT_MODE", False): + conanfile.output.warning(wrong_helper_msg) + else: + raise ConanException(wrong_helper_msg) self._append_vcvars = append_vcvars self._conanfile = conanfile self._settings = conanfile.settings diff --git a/conans/client/build/msbuild.py b/conans/client/build/msbuild.py index 778b81a7628..df8b7bee43a 100644 --- a/conans/client/build/msbuild.py +++ b/conans/client/build/msbuild.py @@ -23,9 +23,14 @@ class MSBuild(object): def __init__(self, conanfile): if isinstance(conanfile, ConanFile): if getattr(conanfile, "must_use_new_helpers", None): - raise ConanException( - "Using the wrong 'MSBuild' helper. To use MSBuildDeps, MSBuildToolchain " - "you should use 'from conan.tools.microsoft import MSBuild'") + wrong_helper_msg = "Using the wrong 'MSBuild' helper. To use MSBuildDeps, MSBuildToolchain "\ + "you should use 'from conan.tools.microsoft import MSBuild'. "\ + "Set environment variable CONAN_DISABLE_STRICT_MODE=1 to override "\ + "this check (should only be used to build old packages)." + if get_env("CONAN_DISABLE_STRICT_MODE", False): + conanfile.output.warning(wrong_helper_msg) + else: + raise ConanException(wrong_helper_msg) self._conanfile = conanfile self._settings = self._conanfile.settings self._output = self._conanfile.output