Skip to content

Commit

Permalink
Merge pull request #3827 from Rohde-Schwarz/feature/allow_disabling_c…
Browse files Browse the repository at this point in the history
…make

Allow disabling installation of CMake configuration
  • Loading branch information
reneme authored Dec 11, 2023
2 parents c34da79 + 2ff1de9 commit 2bcccc8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
15 changes: 12 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,11 @@ def process_command_line(args):
build_group.add_option('--without-pkg-config', dest='with_pkg_config', action='store_false',
help=optparse.SUPPRESS_HELP)

build_group.add_option('--with-cmake-config', action='store_true', default=True,
help=optparse.SUPPRESS_HELP)
build_group.add_option('--without-cmake-config', dest='with_cmake_config', action='store_false',
help=optparse.SUPPRESS_HELP)

docs_group = optparse.OptionGroup(parser, 'Documentation Options')

docs_group.add_option('--with-documentation', action='store_true',
Expand Down Expand Up @@ -2299,6 +2304,9 @@ def test_exe_extra_ldflags():

if options.with_pkg_config:
variables['botan_pkgconfig'] = os.path.join(build_paths.build_dir, 'botan-%d.pc' % (Version.major()))
if options.with_cmake_config:
variables['botan_cmake_config'] = os.path.join(build_paths.build_dir, 'cmake', 'botan-config.cmake')
variables['botan_cmake_version_config'] = os.path.join(build_paths.build_dir, 'cmake', 'botan-config-version.cmake')

# The name is always set because Windows build needs it
variables['static_lib_name'] = '%s%s.%s' % (variables['lib_prefix'], variables['libname'],
Expand Down Expand Up @@ -3346,9 +3354,10 @@ def in_build_module_info(p):
write_template(in_build_dir('build.h'), in_build_data('buildh.in'))
write_template(in_build_dir('botan.doxy'), in_build_data('botan.doxy.in'))

robust_makedirs(in_build_dir("cmake"))
write_template(in_build_dir('cmake/botan-config.cmake'), in_build_data('botan-config.cmake.in'))
write_template(in_build_dir('cmake/botan-config-version.cmake'), in_build_data('botan-config-version.cmake.in'))
if options.with_cmake_config:
robust_makedirs(in_build_dir("cmake"))
write_template(in_build_dir('cmake/botan-config.cmake'), in_build_data('botan-config.cmake.in'))
write_template(in_build_dir('cmake/botan-config-version.cmake'), in_build_data('botan-config-version.cmake.in'))

if 'botan_pkgconfig' in template_vars:
write_template(template_vars['botan_pkgconfig'], in_build_data('botan.pc.in'))
Expand Down
15 changes: 15 additions & 0 deletions doc/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,21 @@ is less of a problem - only the developer needs to worry about it. As
long as they can remember where they installed Botan, they just have
to set the appropriate flags in their Makefile/project file.

CMake
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Starting in Botan 3.3.0 we provide a ``botan-config.cmake`` module to
discover the installed library binaries and headers. This hooks into
CMake's ``find_package()`` and comes with common features like version
detection. Also, library consumers may specify which botan modules they
require in ``find_package()``.

Examples::

find_package(Botan 3.3.0)
find_package(Botan 3.3.0 COMPONENTS rsa ecdsa tls13)
find_package(Botan 3.3.0 OPTIONAL_COMPONENTS tls13_pqc)

Language Wrappers
----------------------------------------

Expand Down
13 changes: 13 additions & 0 deletions doc/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ releases and packages.
Any value set with ``--distribution-info`` flag will be included in the version
string, and can read through the ``BOTAN_DISTRIBUTION_INFO`` macro.

CMake Integration
-----------------

Starting in Botan 3.3.0, we ship ``botan-config.cmake`` files. While this config
file is somewhat relocatable, it assumes the default installation directory
structure as generated by ``make install``. If your distribution changes the
directory layout of the installed files you might want to either adapt the final
``botan-config.cmake`` file accordingly or leave it out entirely using
``--without-cmake-config``.

Please don't hesitate to give your feedback on this new feature by opening a
ticket on the upstream GitHub.

Minimize Distribution Patches
------------------------------

Expand Down
3 changes: 2 additions & 1 deletion src/scripts/ci_check_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def main(args=None):
if not verify_library(build_config):
return 1

if not verify_cmake_package(build_config):
has_cmake = 'botan_cmake_config' in build_config and 'botan_cmake_version_config' in build_config
if has_cmake and not verify_cmake_package(build_config):
return 1

return 0
Expand Down
13 changes: 7 additions & 6 deletions src/scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ def copy_executable(src, dst):
copy_file(cfg['botan_pkgconfig'],
prepend_destdir(os.path.join(pkgconfig_dir, os.path.basename(cfg['botan_pkgconfig']))))

cmake_dir = os.path.join(prefix, lib_dir, cmake_dir, 'Botan-%s' % cfg["version"])
makedirs(prepend_destdir(cmake_dir))
copy_file('build/cmake/botan-config.cmake',
prepend_destdir(os.path.join(cmake_dir, 'botan-config.cmake')))
copy_file('build/cmake/botan-config-version.cmake',
prepend_destdir(os.path.join(cmake_dir, 'botan-config-version.cmake')))
if 'botan_cmake_config' in cfg and 'botan_cmake_version_config' in cfg:
cmake_dir = os.path.join(prefix, lib_dir, cmake_dir, 'Botan-%s' % cfg["version"])
makedirs(prepend_destdir(cmake_dir))
copy_file(cfg['botan_cmake_config'],
prepend_destdir(os.path.join(cmake_dir, os.path.basename(cfg['botan_cmake_config']))))
copy_file(cfg['botan_cmake_version_config'],
prepend_destdir(os.path.join(cmake_dir, os.path.basename(cfg['botan_cmake_version_config']))))

if 'ffi' in cfg['mod_list'] and cfg['build_shared_lib'] is True and cfg['install_python_module'] is True:
for ver in cfg['python_version'].split(','):
Expand Down

0 comments on commit 2bcccc8

Please sign in to comment.