Skip to content

Commit

Permalink
Add CONAN_DISABLE_STRICT_MODE to be able to build old packages (#13037)…
Browse files Browse the repository at this point in the history
… (#13039)

* Add CONAN_DISABLE_STRICT_MODE to be able to build old packages (#13037)

* Mention override in warning message (#13037)
  • Loading branch information
stevn committed Feb 8, 2023
1 parent f87402d commit 6709318
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions conans/client/build/cmake.py
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions conans/client/build/msbuild.py
Expand Up @@ -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
Expand Down

0 comments on commit 6709318

Please sign in to comment.