From b89e43b2bc2e133c411348ad6fbe09c72205901f Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Thu, 31 Oct 2024 13:10:52 -0400 Subject: [PATCH] find_package: Start implementing CPS search Teach find_package to search CPS search paths, and to look for CPS file names. Modify the set of file names to also include the file type (CPS or CMake-script). Modify the search function to allow specifying which file type(s) to consider. During full path search, each possible path is searched for only one of the two possible file types. However, subsequent runs, or when considering a user-specified path (_DIR), CMake will look for both file types. Note that this only adds the new path search logic as described above; CMake does not yet know how to read CPS files, and there is a high likelihood that Bad Things will happen if it tries. However, this seemed like a good place to checkpoint. --- Help/command/find_package.rst | 50 ++++-- Source/cmFindPackageCommand.cxx | 260 +++++++++++++++++++++++++------- Source/cmFindPackageCommand.h | 39 ++++- 3 files changed, 280 insertions(+), 69 deletions(-) diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 3ffabacecf..99763f59c3 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -313,11 +313,19 @@ Each entry is meant for installation trees following Windows (``W``), UNIX ==================================================================== ========== Entry Convention ==================================================================== ========== + ``//cps/`` [#p2]_ W + ``//*/cps/`` [#p2]_ W + ``/cps//`` [#p2]_ W + ``/cps//*/`` [#p2]_ W + ``/cps/`` [#p2]_ W ``/`` W ``/(cmake|CMake)/`` W ``/*/`` W ``/*/(cmake|CMake)/`` W - ``/*/(cmake|CMake)/*/`` [#]_ W + ``/*/(cmake|CMake)/*/`` [#p1]_ W + ``/(lib/|lib*|share)/cps//`` [#p2]_ U + ``/(lib/|lib*|share)/cps//*/`` [#p2]_ U + ``/(lib/|lib*|share)/cps/`` [#p2]_ U ``/(lib/|lib*|share)/cmake/*/`` U ``/(lib/|lib*|share)/*/`` U ``/(lib/|lib*|share)/*/(cmake|CMake)/`` U @@ -326,22 +334,34 @@ Each entry is meant for installation trees following Windows (``W``), UNIX ``/*/(lib/|lib*|share)/*/(cmake|CMake)/`` W/U ==================================================================== ========== -.. [#] .. versionadded:: 3.25 +.. [#p1] .. versionadded:: 3.25 + +.. [#p2] .. versionadded:: 3.32 On systems supporting macOS :prop_tgt:`FRAMEWORK` and :prop_tgt:`BUNDLE`, the following directories are searched for Frameworks or Application Bundles containing a configuration file: -=========================================================== ========== - Entry Convention -=========================================================== ========== - ``/.framework/Resources/`` A - ``/.framework/Resources/CMake/`` A - ``/.framework/Versions/*/Resources/`` A - ``/.framework/Versions/*/Resources/CMake/`` A - ``/.app/Contents/Resources/`` A - ``/.app/Contents/Resources/CMake/`` A -=========================================================== ========== +=============================================================== ========== + Entry Convention +=============================================================== ========== + ``/.framework/Versions/*/Resources/CPS/`` [#p3]_ A + ``/.framework/Resources/CPS/`` [#p3]_ A + ``/.framework/Resources/`` A + ``/.framework/Resources/CMake/`` A + ``/.framework/Versions/*/Resources/`` A + ``/.framework/Versions/*/Resources/CMake/`` A + ``/.app/Contents/Resources/CPS/`` [#p3]_ A + ``/.app/Contents/Resources/`` A + ``/.app/Contents/Resources/CMake/`` A +=============================================================== ========== + +.. [#p3] .. versionadded:: 3.32 + +When searching the above paths, ``find_package`` will only look for ``.cps`` +files in search paths which contain ``/cps/``, and will only look for +``.cmake`` files otherwise. (This only applies to the paths as specified and +does not consider the contents of ```` or ````.) In all cases the ```` is treated as case-insensitive and corresponds to any of the names specified (```` or names given by ``NAMES``). @@ -395,6 +415,12 @@ intended for installations on Apple platforms. The :variable:`CMAKE_FIND_FRAMEWORK` and :variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of preference. +.. warning:: + + Setting :variable:`CMAKE_FIND_FRAMEWORK` or :variable:`CMAKE_FIND_APPBUNDLE` + to values other than ``FIRST`` (the default) will cause CMake searching for + CPS files in an order that is different from the order specified by CPS. + The set of installation prefixes is constructed using the following steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are enabled. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index da29b9e97d..41974c7e59 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -57,6 +57,8 @@ class cmExecutionStatus; namespace { +using pdt = cmFindPackageCommand::PackageDescriptionType; + template