diff --git a/conan_provider.cmake b/conan_provider.cmake index c965f237..12644d5a 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -585,14 +585,14 @@ macro(conan_provide_dependency method package_name) construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) - if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") - message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile") + if(NOT "${outfile}" MATCHES ".*CMake(Config)?Deps.*") + message(WARNING "Cmake-conan: CMakeDeps or CMakeConfigDeps generator was not defined in the conanfile") endif() set(generator "") elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt") file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile) - if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") - message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. " + if(NOT "${outfile}" MATCHES ".*CMake(Config)?Deps.*") + message(WARNING "Cmake-conan: CMakeDeps or CMakeConfigDeps generator was not defined in the conanfile. " "Please define the generator as it will be mandatory in the future") endif() set(generator "-g;CMakeDeps") diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 8228d3ad..0e9b8431 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -33,6 +33,11 @@ windows = pytest.mark.skipif(platform.system() != "Windows", reason="Windows only") +def normalize_console_output(output): + # terminals can wrap console output resulting in + # inconsistent levels of whitespace in CMake output + return re.sub(r"\s+", " ", output) + def run(cmd, check=True): subprocess.run(cmd, shell=True, check=check) @@ -768,7 +773,15 @@ def test_no_generator_py(self, capfd, basic_cmake_project, resource_path): self.copy_resource(resource_path, source_dir) run(f'cmake -S {source_dir} -B {binary_dir} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES={conan_provider} -DCMAKE_BUILD_TYPE=Release', check=False) _, err = capfd.readouterr() - assert 'Cmake-conan: CMakeDeps generator was not defined in the conanfile' in err + assert 'Cmake-conan: CMakeDeps or CMakeConfigDeps generator was not defined in the conanfile' in normalize_console_output(err) + + # CMakeConfigDeps generator is declared in the generate() function in conanfile.py + def test_cmakeconfigdeps_generator(self, capfd, basic_cmake_project): + source_dir, binary_dir = basic_cmake_project + self.copy_resource('cmakeconfigdeps_generator', source_dir) + run(f'cmake -S {source_dir} -B {binary_dir} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES={conan_provider} -DCMAKE_BUILD_TYPE=Release') + _, err = capfd.readouterr() + assert 'Cmake-conan: CMakeDeps or CMakeConfigDeps generator was not defined in the conanfile' not in normalize_console_output(err) class TestTryCompile: