Fix pkg-config paths for absolute install dirs#2198
Conversation
LebedevRI
left a comment
There was a problem hiding this comment.
The description seems AI-generated. It's extremely verbose,
but does not actually explain what specific problem this is fixing,
just explains the diff itself.
| set(namespace "${PROJECT_NAME}::") | ||
|
|
||
| include(CMakePackageConfigHelpers) | ||
| include(GoogleBenchmarkPkgConfig) |
There was a problem hiding this comment.
The name is too generic, i'd just place fn inline here
| endif() | ||
| endif() | ||
|
|
||
| if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") |
There was a problem hiding this comment.
Err, inline the file, not the function.
It is still not clear to me what the problem is. |
| BENCHMARK_PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}" "prefix") | ||
| configure_file("${PROJECT_SOURCE_DIR}/cmake/benchmark.pc.in" "${pkg_config}" @ONLY) |
There was a problem hiding this comment.
Separate with newline please
LebedevRI
left a comment
There was a problem hiding this comment.
Diff is fine, but
It is still not clear to me what the problem is.
Does cmake canonicalize CMAKE_INSTALL_FULL_*DIR?
Are prefix/exec_prefix variables somehow magic in pkg-config?
|
Thanks, the problem is specifically relocatability of the generated
So the intended fix is:
|
| endif() | ||
| endif() | ||
|
|
||
| function(benchmark_make_pkgconfig_path output_var install_dir path_prefix) |
There was a problem hiding this comment.
Please name this _cmake_path and add a fixme for cmake 3.20:
https://cmake.org/cmake/help/latest/command/cmake_path.html#append
| compile_output_test(scoped_pause_test) | ||
| benchmark_add_test(NAME scoped_pause_test COMMAND scoped_pause_test) | ||
|
|
||
| benchmark_add_test( |
There was a problem hiding this comment.
Please drop the test stuff
|
Addressed the remaining concrete review items and pushed 41dbf87:
Local validation:
|
|
@Haihan-Jiang thank you, i'll merge this one. |
Fixes #1396.
CMAKE_INSTALL_FULL_LIBDIR and CMAKE_INSTALL_FULL_INCLUDEDIR always expand to absolute paths when configuring pkg-config files. That makes normal relative installs less relocatable: libdir no longer follows prefix/exec_prefix.
This PR builds pkg-config paths from CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_INCLUDEDIR instead:
benchmark_main.pc gets the same prefix/exec_prefix handling. The test checks the generated .pc files in both relative and absolute install-dir configurations.
Validation: