Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 14 additions & 1 deletion tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down