hooks icon indicating copy to clipboard operation
hooks copied to clipboard

[conan-center] Validate cmake,cmake_find_package[_multi] for test package

Open uilianries opened this issue 4 years ago • 3 comments

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.

uilianries avatar Aug 05 '21 13:08 uilianries

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_package function - 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"]

SSE4 avatar Aug 06 '21 13:08 SSE4

with https://github.com/conan-io/conan-center-index/pull/7153 there are some changes to the policy:

  • CONAN_LIBS should be never recommended (will disappear in conan 2.0)
  • CONAN_PKG:: should be never recommended (will disappear in conan 2.0)
  • cmake generator should be never recommended (will disappear in conan 2.0)

SSE4 avatar Sep 03 '21 10:09 SSE4

  • cmake generator 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.

jgsogo avatar Dec 30 '21 15:12 jgsogo