Skip to content

Refactor: CMake Module now uses mostly hard-coded paths#5402

Merged
reneme merged 4 commits intorandombit:masterfrom
Rohde-Schwarz:chore/rendered_cmake_module
Mar 2, 2026
Merged

Refactor: CMake Module now uses mostly hard-coded paths#5402
reneme merged 4 commits intorandombit:masterfrom
Rohde-Schwarz:chore/rendered_cmake_module

Conversation

@reneme
Copy link
Collaborator

@reneme reneme commented Mar 2, 2026

This is inspired by the CMake modules generated by actual CMake-based projects. Essentially, most of the "discovery logic" is moved out of botan-config.cmake and into configure.py where we have much more information about the target system's installation directory structure. The only thing that is still done within the CMake module itself is to snap onto the "real path" when users are discovering Botan via a symlink as outlined in the code comments. This approach is borrowed from generated CMake module files on my machine.

Also, this adds license notes in the CMake module files (as they are distributed to consumer machines) and introduces a --cmakeconfigdir switch in ./configure.py to allow package maintainers to influence where the CMake module should be placed.

Closes #5030

These files are distributed to consumer machines and should therefore
carry some license information.
@reneme reneme self-assigned this Mar 2, 2026
Copilot AI review requested due to automatic review settings March 2, 2026 11:04
@reneme reneme added infra CI, package management, etc labels Mar 2, 2026
@reneme reneme modified the milestone: Botan 3.11 Mar 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the generated CMake package config modules to rely primarily on install-layout information computed at configure.py time (instead of runtime discovery in botan-config.cmake), adds licensing headers to the distributed CMake module files, and introduces a --cmakeconfigdir option for packagers.

Changes:

  • Add --cmakeconfigdir and plumb its resolved install directory through build_config.json for installation.
  • Rework botan-config.cmake.in to derive prefix via fixed upward traversal and then use precomputed relative install subpaths.
  • Add license headers to botan-config.cmake.in and botan-config-version.cmake.in.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/scripts/install.py Install CMake config files into cmake_install_dir from build_config.json instead of reconstructing the path.
src/build-data/botan-config.cmake.in Replace runtime discovery logic with fixed prefix traversal + configure-time relative paths; adjust DLL path to use computed bin dir.
src/build-data/botan-config-version.cmake.in Add license header to the distributed version file.
configure.py Add --cmakeconfigdir option and generate CMake-install layout variables (cmake_install_dir, relpaths, traversal depth components).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link

coveralls commented Mar 2, 2026

Coverage Status

coverage: 90.317% (-1.6%) from 91.955%
when pulling d473955 on Rohde-Schwarz:chore/rendered_cmake_module
into 1afa1b1 on randombit:master.

@reneme reneme force-pushed the chore/rendered_cmake_module branch from 441448f to 623a830 Compare March 2, 2026 12:40
@reneme reneme requested a review from Copilot March 2, 2026 12:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@reneme reneme force-pushed the chore/rendered_cmake_module branch 2 times, most recently from 971b2df to 18cef9d Compare March 2, 2026 12:58
Copy link
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

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

Couple of super nit comments/suggestions

reneme added 3 commits March 2, 2026 14:22
This allows package maintainers to configure where CMake modules
should be placed during installation.
Instead of trying to figure out the locations of Botan's include and
library files heuristically within the botan-cmake-config.cmake module,
this now leverages the platform knowledge in configure.py. By hard-
coding most of the relevant paths and just handling potential symlink
issues on the target machine, we hopefully get a cleaner and more robust
CMake module.

Closes randombit#5030
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@reneme reneme merged commit fac2691 into randombit:master Mar 2, 2026
49 checks passed
@reneme reneme deleted the chore/rendered_cmake_module branch March 2, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra CI, package management, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

botan-config.cmake: Hard-code installation paths?

4 participants