fix: Respect CMAKE_INSTALL_PREFIX and BENCHMARK_ENABLE_INSTALL.#52
fix: Respect CMAKE_INSTALL_PREFIX and BENCHMARK_ENABLE_INSTALL.#52jenskeiner wants to merge 1 commit into
Conversation
Greptile SummaryThis PR fixes two related CMake install issues: the headers install destination was hardcoded to
Confidence Score: 4/5Safe to merge — the install logic is correct and the hardcoded path is properly replaced with prefix-relative variables. The two targeted changes (GNUInstallDirs adoption and BENCHMARK_ENABLE_INSTALL guard) work as intended with no regressions to the build or library targets. The one outstanding gap is that the EXPORT codspeed-targets clause has no matching install(EXPORT …) call, so the CMake package export file is never written at install time, leaving find_package(codspeed) broken for downstream consumers. core/CMakeLists.txt — the install(TARGETS … EXPORT codspeed-targets) block needs a companion install(EXPORT codspeed-targets DESTINATION …) to complete the exported package setup. Important Files Changed
|
| install( | ||
| TARGETS codspeed instrument_hooks | ||
| EXPORT codspeed-targets | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
| ) |
There was a problem hiding this comment.
Missing
install(EXPORT) call for codspeed-targets
The EXPORT codspeed-targets clause on install(TARGETS ...) registers the targets into an export set, but without a matching install(EXPORT codspeed-targets DESTINATION ...) call, no codspeed-targets.cmake file is ever written to disk during installation. Downstream projects relying on find_package(codspeed) after cmake --install won't get the imported-target file they need. Adding install(EXPORT codspeed-targets DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/codspeed") inside the same BENCHMARK_ENABLE_INSTALL guard would complete the export setup.
There was a problem hiding this comment.
Fair point. I would like to note that I think the dangling export was not introduced by the proposed code changes, but may have made reaching it more likely. Still, I think gating install() and honoring an install prefix are valid fixes. Maybe fixing the dangling export makes sense in another PR?
Suggested changes to fix #51.