filesystem icon indicating copy to clipboard operation
filesystem copied to clipboard

Fix CMake config mode package finding

Open jnhyatt opened this issue 3 years ago • 2 comments

During a recent build, I realized that find_package was unable to find ghcfilesystem with it installed in my CMake prefix path (on Windows). After some poking around, I nailed it down to the final install directory not matching any of the search patterns in CMake's config mode package finder search procedure. The directory ghc_filesystem-config.cmake should be in must look like one of these in order to be found without special tweaks to the package find procedure:

<prefix-path>/ghc_filesystem-config.cmake
<prefix-path>/cmake/ghc_filesystem-config.cmake
<prefix-path>/ghc_filesystem*/ghc_filesystem-config.cmake
<prefix-path>/ghc_filesystem*/cmake/ghc_filesystem-config.cmake
<prefix-path>/lib/cmake/ghc_filesystem*/ghc_filesystem-config.cmake
<prefix-path>/lib/ghc_filesystem*/ghc_filesystem-config.cmake
<prefix-path>/lib/ghc_filesystem*/cmake/ghc_filesystem-config.cmake
<prefix-path>/ghc_filesystem*/lib/cmake/ghc_filesystem*/ghc_filesystem-config.cmake
<prefix-path>/ghc_filesystem*/lib/ghc_filesystem/ghc_filesystem-config.cmake
<prefix-path>/ghc_filesystem*/lib/ghc_filesystem/cmake/ghc_filesystem-config.cmake

Because the project name was ghcfilesystem, the default path was <prefix-path>/ghcfilesystem/lib/cmake/ghc_filesystem/ghc_filesystem-config.cmake (missing underscore). This problem likely doesn't manifest on Linux due to the way a make install works. Once I fixed the project name, CMake find_package was able to find the package with no problems.

jnhyatt avatar Jun 15 '21 22:06 jnhyatt

Sorry, I didn't react for so long. Was pretty occupied lately. I'll look into it and do some tests. As this will change the project file names for IDEs like Xcode or Visual Studio, I would put this into a new minor version, so the upcoming version will be a v1.6.0 I guess.

gulrak avatar Jul 04 '21 18:07 gulrak

We just ran into this in Fedora Linux. Is this still planned for a 1.6.0 release somewhere in the indefinite future? Thanks!

musicinmybrain avatar Sep 17 '23 15:09 musicinmybrain