[conan-center] Validate cmake,cmake_find_package[_multi] for test package
Related to https://github.com/conan-io/conan-center-index/issues/6681
Add a new Hook base which follows the correct usage for Cmake.
It will be complicated filtering the official module names as it requires internet connection.
potential list of patterns to be scanned in hook:
.names["cmake_find_package"].names["cmake_find_package_multi"].filenames["cmake_find_package"].filenames["cmake_find_package_multi"]set_property("cmake_target_name"set_property("cmake_file_name"tools.rmdir(os.path.join(self.package_folder), "lib", "cmake")tools.rmdir(os.path.join(self.package_folder), "share", "cmake")(unlikely to be encountered in the wild)
potential list of things to check in the hook and show a warning (if one or more previous patterns were encountered):
- usage of
CONAN_LIBS(and similar vars, if any) - not recommended - usage of
CONAN_PKG::targets - not recommended - usage of
find_packagefunction - recommended - usage of
cmake_find_package[_multi]generator - recommended
UPD : usage of build modules for cmake might be an additional indicator, as these modules are needed to create alias targets or variables, e.g.:
.build_modules["cmake_find_package"].build_modules["cmake_find_package_multi"]
with https://github.com/conan-io/conan-center-index/pull/7153 there are some changes to the policy:
CONAN_LIBSshould be never recommended (will disappear in conan 2.0)CONAN_PKG::should be never recommended (will disappear in conan 2.0)cmakegenerator should be never recommended (will disappear in conan 2.0)
cmakegenerator should be never recommended (will disappear in conan 2.0)
(Talking about the recipe, not the test_package:)
cmake generator is needed for cmake_find_package[_multi] ones. A recipe cannot get rid of these generators until all its dependencies are already using set_properties (if needed) to populate the right target names for CMakeDeps generator. At that moment, the recipe can change and start using CMakeDeps+CMakeToolchain to build the binaries...
So, we will probably see cmake generator around for several months.