Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake modules get installed to a wrong path #1152

Closed
lahwaacz opened this issue Oct 26, 2022 · 5 comments · Fixed by #1181 or #1325
Closed

CMake modules get installed to a wrong path #1152

lahwaacz opened this issue Oct 26, 2022 · 5 comments · Fixed by #1181 or #1325
Assignees

Comments

@lahwaacz
Copy link
Contributor

When building the ginkgo-hpc-git AUR package, I noticed that it installs the following cmake files:

ginkgo-hpc-git /usr/lib/cmake/
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/GinkgoConfig.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/GinkgoConfigVersion.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/GinkgoTargets-release.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/GinkgoTargets.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/CudaArchitectureSelector.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/FindHWLOC.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/FindNUMA.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/FindPAPI.cmake
ginkgo-hpc-git /usr/lib/cmake/Ginkgo/Modules/Modules/hwloc_helpers.cmake

The Modules/Modules part is most likely a bug which causes the following error when find_package(Ginkgo) is used in another project:

CMake Error at /usr/lib64/cmake/Ginkgo/GinkgoConfig.cmake:187 (find_package):
  By not providing "FindHWLOC.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "HWLOC", but
  CMake did not find one.

  Could not find a package configuration file provided by "HWLOC" with any of
  the following names:

    HWLOCConfig.cmake
    hwloc-config.cmake

  Add the installation prefix of "HWLOC" to CMAKE_PREFIX_PATH or set
  "HWLOC_DIR" to a directory containing one of the above files.  If "HWLOC"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:55 (find_package)


-- Configuring incomplete, errors occurred!
@lahwaacz
Copy link
Contributor Author

lahwaacz commented Nov 6, 2022

This is still not fixed – the same CMake error appears when one wants to find_package(Ginkgo). The modules now get installed to /usr/lib/cmake/Ginkgo/Modules/ but that path is not searched by find_package by default. I guess you need to set CMAKE_MODULE_PATH from the installed GinkgoConfig.cmake or to install the modules to /usr/share/cmake/Modules/ (and worry about name conflicts with other projects).

@upsj upsj reopened this Nov 6, 2022
@upsj
Copy link
Member

upsj commented Nov 7, 2022

Can you check in more detail where this is failing? I can't reproduce it right now in an archlinux docker container (though I didn't use your package to build it, not familiar enough with Arch to do that). We already add the relevant path to the CMAKE_MODULE_PATH, see GinkgoConfig.cmake.in:105

list(APPEND CMAKE_MODULE_PATH "@CMAKE_MODULE_PATH@" "${GINKGO_INSTALL_MODULE_DIR}")

Useful tools are cmake --trace and cmake --trace-expand to debug the execution.

@lahwaacz
Copy link
Contributor Author

lahwaacz commented Nov 7, 2022

Oh, right. The /usr/lib/cmake/Ginkgo/GinkgoConfig.cmake file in the package I built contains this path:

list(APPEND CMAKE_MODULE_PATH "/build/ginkgo-hpc-git/src/ginkgo/cmake/Modules/" "${GINKGO_INSTALL_MODULE_DIR}")

Now, the first path is wrong – /build/ is the path where the package was built (in a chroot environment) and it does not make sense when the package gets installed. I see you've created #1188 for this.

The "${GINKGO_INSTALL_MODULE_DIR}" path should do the trick, but it does not work. When I manually added message("${CMAKE_MODULE_PATH}"), the variable expanded to

/build/ginkgo-hpc-git/src/ginkgo/cmake/Modules/;/usr/lib64/cmake/Ginkgo/lib/cmake/Ginkgo/Modules

There is string(REPLACE "lib/cmake/Ginkgo" "" GINKGO_INSTALL_PREFIX "${GINKGO_CONFIG_FILE_PATH}") couple of lines above in /usr/lib/cmake/Ginkgo/GinkgoConfig.cmake, but lib64/cmake/Ginkgo should have been stripped...

@upsj upsj self-assigned this Apr 6, 2023
@upsj
Copy link
Member

upsj commented Apr 28, 2023

@lahwaacz if you have a minute, could you try out the linked PR? It should now produce relocatable GinkgoConfig.cmake files

@lahwaacz
Copy link
Contributor Author

@upsj That seems to fix this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants