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 incorrect absolute include/lib paths tracking issue #144170
Comments
Fixes a "double prefix" issue, where parts of the include files for hhvm where located in `$out/$out/include` instead of `$out/include`.
Linking from #81091 (comment) the upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/19568 @jtojnar Do you understand the upstream MRs that closed that issue? |
The cmake project is more general but has some similar issues: https://github.com/NixOS/nixpkgs/projects/32 |
The usptream cmake feature that closed that issue is cmake_path (available starting with cmake 3.20) |
The upstream PR basically allows us to simplify the example code in https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files to: cmake_path(APPEND libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/my-project.pc.in"
"${PROJECT_BINARY_DIR}/my-project.pc"
@ONLY) The downside, as observed above, is that it is only available in CMake 3.20, while projects often have For that reason, using the The
So it might accidentally preserve drive letter ( project(my-library)
include(GNUInstallDirs)
cmake_path(APPEND pkglibdir ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_LIBDIR} ${PROJECT_NAME}) Or the other way round, on Linux, it will happily append Though, to be fair, the function from cmake-snips avoided the first issue by only supporting Unix paths and suffered from the second issue as well. |
I also found a similar issue in paths in I added these to the issue description. |
The bpp-* issues are apparently due to them setting their INTERFACE_INCLUDE_DIRECTORIES to |
#172347 adds a hook to catch broken |
Fixes NixOS#192617. The breakage is introduced by a glslang update. Now `${glslang}/lib/cmake/OSDependentTargets.cmake` points to `${glslang}/share/glslang/glslang-targets.cmake`. The latter requires the `SPIRV-Tools-opt` target. So the two lines in patch should be moved before `OSDependentTargets.cmake`. This also fixes a breakage introduced by cmake described in NixOS#144170.
Fixes: ``` slang> Broken paths found in a .pc file! /nix/store/23f6pl4nhwl4xx1h35hs64d1kqh9g5sk-slang-1.0g20221020_fdf27a0/share/pkgconfig/sv-lang.pc slang> The following lines have issues (specifically '//' in paths). slang> 2:includedir="${prefix}//nix/store/23f6pl4nhwl4xx1h35hs64d1kqh9g5sk-slang-1.0g20221020_fdf27a0/include" slang> 3:libdir="${prefix}//nix/store/23f6pl4nhwl4xx1h35hs64d1kqh9g5sk-slang-1.0g20221020_fdf27a0/lib" slang> It is very likely that paths are being joined improperly. slang> ex: "${prefix}/@CMAKE_INSTALL_LIBDIR@" should be "@CMAKE_INSTALL_FULL_LIBDIR@" slang> Please see NixOS/nixpkgs#144170 for more details. error: builder for '/nix/store/4w5nq781aw161b9lrk1f59j914ibk368-slang-1.0g20221020_fdf27a0.drv' failed with exit code 1; ```
258: Fix CMake install dir usage in pkgconfig, honour CMAKE_INSTALL_INCLUDEDIR r=AlanGriffiths a=OPNA2608 1. Current assumption about `CMAKE_INSTALL_<dir>` being relative to `CMAKE_INSTALL_PREFIX` is wrong. ``` Broken paths found in a .pc file! /nix/store/0lfs3w5mgjh5rdlrzwm4h18g2jpmmygx-wlcs-1.4.0/lib/pkgconfig/wlcs.pc The following lines have issues (specifically '//' in paths). 2:exec_prefix=${prefix}//nix/store/0lfs3w5mgjh5rdlrzwm4h18g2jpmmygx-wlcs-1.4.0/bin 3:libexecdir=${prefix}//nix/store/0lfs3w5mgjh5rdlrzwm4h18g2jpmmygx-wlcs-1.4.0/libexec It is very likely that paths are being joined improperly. ex: "${prefix}/`@CMAKE_INSTALL_LIBDIR@"` should be "`@CMAKE_INSTALL_FULL_LIBDIR@"` Please see NixOS/nixpkgs#144170 for more details. ``` `CMAKE_INSTALL_<dir>` must not be assumed to be relative to `CMAKE_INSTALL_PREFIX`, [according to the CMake documentation](https://cmake.org/cmake/help/v3.25/module/GNUInstallDirs.html?highlight=gnuinstalldirs): > It should typically be a path relative to the installation prefix so that it can be converted to an absolute path in a relocatable way (see `CMAKE_INSTALL_FULL_<dir>`). **However, an absolute path is also allowed.** CMake has special `_FULL_` variants of the variables which apply the prefix when needed: > The absolute path generated from the corresponding `CMAKE_INSTALL_<dir>` value. If the value is not already an absolute path, an absolute path is constructed typically by prepending the value of the [`CMAKE_INSTALL_PREFIX`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html#variable:CMAKE_INSTALL_PREFIX) variable. --- 2. `CMAKE_INSTALL_INCLUDEDIR` isn't honoured. CMake has `CMAKE_INSTALL_INCLUDEDIR` for specifying where header files shall be installed to. It defaults to `include` (relative to `CMAKE_INSTALL_PREFIX`) so when not specifying an include dir, this is functionally identical to the current hardcoding. Co-authored-by: OPNA2608 <christoph.neidahl@gmail.com>
For others running into this, slapping this into the derivation code worked for my issue:
It should be pretty robust against false-positives, although it only works when the prefix is literally "prefix" |
fix: sha256 didn't match 1.23.1 version (matched 1.8.0) - now matches 1.23.2. fix: 1.23.x failed at install phase NixOS#144170.
I encountered one of these when setting up installing CMake config for one of my own projects today. That project is not in nixpkgs but might as well describe it here in case anyone else has to deal with something similar: It happens for libraries (like this one) that install headers via FILE_SET HEADERS and also install exported targets (the CMake-native mechanism, not pkgconfig). The generated *Targets.cmake file will have a section setting up the file set, which will look something like this, with the wrong paths (should be
A workaround I found is to just set CMAKE_INSTALL_INCLUDEDIR to be relative to CMAKE_INSTALL_PREFIX if it's an absolute path. (This might actually be a bug in how CMake generates the file set section of the targets file, since it should probably leave away the |
According to NixOS/nixpkgs#144170, replace STRING(APPEND ...) by CMAKE_PATH(APPEND ...) Remove unnecessary cmakeFlags
This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170
This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170
Found a couple more instances of similar issues just out of the files that weren't garbage collected on my laptop:
not sure about this one:
from what I've seen, most false positives were either "file://" URLs or cases where the prefix was indeed prepended to an absolute path, but was empty instead of "/nix/store/...". Would it make sense to further increase the checking to all text files? This would be quite a far reaching change |
This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170
This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170
* Add Python bindings for WASM * Update Python bindings for m68k * Update Python bindings for mos65xx * Update Python bindings for x86 * Add Python bindings for SH * Update CS_* constants in Python bindings * Update constants from ARM auto-sync patch * Fixing TriCore disasm instructions (#2088) * allow absolute CMAKE_INSTALL_*DIR (#2134) This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170 --------- Co-authored-by: Peace-Maker <peace-maker@wcfan.de> Co-authored-by: Bastian Koppelmann <bkoppelmann@users.noreply.github.com> Co-authored-by: chayleaf <chayleaf@protonmail.com>
* Add Python bindings for WASM * Update Python bindings for m68k * Update Python bindings for mos65xx * Update Python bindings for x86 * Add Python bindings for SH * Update CS_* constants in Python bindings * Update constants from ARM auto-sync patch * Fixing TriCore disasm instructions (#2088) * allow absolute CMAKE_INSTALL_*DIR (#2134) This patch fixes Capstone 5 build on NixOS. NixOS's build infrastructure sets CMAKE_INSTALL_{LIB,INCLUDE}DIR to absolute paths. If you append it to ${prefix}, you get the wrong path. NixOS automatically detects it and links this issue: NixOS/nixpkgs#144170 * Disable swift binding const generate * update bindings const * update capstone version * update ChangeLog --------- Co-authored-by: Peace-Maker <peace-maker@wcfan.de> Co-authored-by: Bastian Koppelmann <bkoppelmann@users.noreply.github.com> Co-authored-by: chayleaf <chayleaf@protonmail.com>
There are various issues where
cmake
does not work with nix store paths given asprefix
es, generating invalid paths intopkg-config
.pc
files and others.This issue is to track such cases and their workarounds, so that we can ideally find a general solution, and to figure out whether it's the cmake usage in the upstream packages that's wrong, or something else.
If you find such a case, please post here.
The wrong paths look like this:
NIX_PATH=nixpkgs=. nix-shell -p libyamlcpp -p pkg-config --run 'pkg-config --cflags yaml-cpp'
Note the concatenation of a store path
/nix/store/bq106wng1cqk8r4y1y7yh5h7cz49jxpv-libyaml-cpp-0.7.0/
and the same store path again, and then/include
.Cases
Include/library paths:
hhvm
: 029c3f9srt
: srt: Fix wrongsrt.pc
include path #71669exiv2
: exiv2: fix exiv2.pc file #81091.cmake
paths (see #144170 (comment)):bpp-seq
bpp-core
bpp-phyl
bpp-popgen
The text was updated successfully, but these errors were encountered: