Skip to content

feat: use CMake's GNUInstallDir - #518

Open
wdconinc wants to merge 6 commits into
JeffersonLab:masterfrom
wdconinc:gnu-install-dirs
Open

wdconinc wants to merge 6 commits into
JeffersonLab:masterfrom
wdconinc:gnu-install-dirs

Conversation

@wdconinc

@wdconinc wdconinc commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

This PR adds GNUInstallDirs for installation destinations (https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html). This makes it easier to override the installation destinations in one place for certain platforms (e.g. WASM, which puts all libs alongside bins).

The only thing that's not replaced by a CMAKE_INSTALL_*DIR is the plain plugins directory in jana-generate.py. This is a gray area in the FHS, but more importantly it's probably not advisable to change this from the current plugins directory under the install prefix for user plugins (JANA2 plugins already end up in lib/JANA/plugins).

Copilot AI lite review requested due to automatic review settings September 19, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Installed helper modules and generated templates introduce GNUInstallDirs-dependent variables (and libdir-sensitive RPATH behavior) without consistently ensuring the correct GNUInstallDirs module usage for downstream consumers.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Medium severity

Open (4)
What changed in this PR

This PR standardizes installation paths across the JANA2 CMake build by adopting CMake’s GNUInstallDirs variables, making it easier to override install destinations (e.g., for non-FHS layouts like WASM).

Changes:

  • Adds include(GNUInstallDirs) and replaces hardcoded bin/, lib/, and include/ install destinations with ${CMAKE_INSTALL_BINDIR}, ${CMAKE_INSTALL_LIBDIR}, and ${CMAKE_INSTALL_INCLUDEDIR}.
  • Updates exported/install interface include paths to follow ${CMAKE_INSTALL_INCLUDEDIR}.
  • Aligns example/tutorial and helper-module installation destinations with the new scheme.
File Description
CMakeLists.txt Includes GNUInstallDirs and updates install destinations for scripts and optional perfetto artifacts.
cmake/​MakeConfig.cmake Moves package config install destination under ${CMAKE_INSTALL_LIBDIR}.
cmake/​MakeJVersionH.cmake Installs generated JVersion.h under ${CMAKE_INSTALL_INCLUDEDIR}.
cmake/​MakeJanaThis.cmake Installs jana-* helper scripts under ${CMAKE_INSTALL_BINDIR}.
cmake/​AddJanaPlugin.cmake Updates plugin install/include destinations to use CMAKE_INSTALL_*DIR variables.
cmake/​AddJanaLibrary.cmake Updates library install/include destinations to use CMAKE_INSTALL_*DIR variables.
cmake/​AddJanaTest.cmake Updates test install destination to ${CMAKE_INSTALL_BINDIR}.
scripts/​jana-generate.py Updates generated CMake snippets to use install-dir variables for includes/bins (keeps plugin dir as plugins).
src/​libraries/​JANA/​CMakeLists.txt Updates core library/header installation and install-interface includes to use CMAKE_INSTALL_*DIR.
src/​programs/​jana/​CMakeLists.txt Installs jana binary into ${CMAKE_INSTALL_BINDIR}.
src/​plugins/​janaview/​CMakeLists.txt Installs ROOT PCM/rootmap artifacts under ${CMAKE_INSTALL_LIBDIR}/JANA/plugins.
src/​external/​tomlplusplus/​CMakeLists.txt Installs vendored headers under ${CMAKE_INSTALL_INCLUDEDIR} and updates install-interface include path.
src/​external/​catch2/​CMakeLists.txt Installs vendored headers under ${CMAKE_INSTALL_INCLUDEDIR} and updates install-interface include path.
src/​examples/​tutorial_with_podio_datamodel/​01_datamodel/​CMakeLists.txt Updates tutorial library/header and ROOT dict artifact install destinations to CMAKE_INSTALL_*DIR.
src/​examples/​tutorial_with_lightweight_datamodel/​01_datamodel/​CMakeLists.txt Updates tutorial datamodel header install destination and install-interface include path to ${CMAKE_INSTALL_INCLUDEDIR}.
src/​examples/​tutorial_with_lightweight_datamodel/​19_wrapper_program/​CMakeLists.txt Installs wrapper binary into ${CMAKE_INSTALL_BINDIR}.
src/​examples/​misc/​SubeventExample/​CMakeLists.txt Installs example binary into ${CMAKE_INSTALL_BINDIR}.
src/​examples/​misc/​SubeventCUDAExample/​CMakeLists.txt Installs CUDA example binary into ${CMAKE_INSTALL_BINDIR}.
src/​examples/​misc/​RootDatamodelExample/​CMakeLists.txt Installs ROOT PCM artifacts under ${CMAKE_INSTALL_LIBDIR}/JANA/plugins.
src/​examples/​misc/​PodioDatamodel/​CMakeLists.txt Updates example library/header and ROOT dict artifact install destinations to CMAKE_INSTALL_*DIR.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmake/AddJanaLibrary.cmake
Comment thread cmake/AddJanaPlugin.cmake
Comment thread cmake/AddJanaTest.cmake
Comment thread scripts/jana-generate.py Outdated
@wdconinc wdconinc changed the title feat: use CMake's GnuInstallDir feat: use CMake's GNUInstallDir Sep 19, 2026
wdconinc and others added 2 commits September 19, 2026 15:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wdconinc

Copy link
Copy Markdown
Member Author

@wdconinc wdconinc mentioned this pull request Sep 19, 2026
Comment thread cmake/AddJanaLibrary.cmake Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not self-consistent now.

Suggested change
INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}"

And others

@veprbl veprbl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread scripts/jana-generate.py

file(GLOB my_headers "*.h*")
install(FILES ${{my_headers}} DESTINATION include/{name})
install(FILES ${{my_headers}} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/{name})

@veprbl veprbl Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if is_standalone=False? Probably can slap an include GNUInstallDirs to every snippet that creates a target?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants