gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.
MIT License
1.34k stars 173 forks source link

Fix CMake config mode package finding #129

Open jnhyatt opened 3 years ago

jnhyatt commented 3 years ago

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.

gulrak commented 3 years ago

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.

musicinmybrain commented 1 year ago

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