From 26a1ccf2819ab148aef3cd354e1cbdb70a9fe5b7 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Fri, 16 Feb 2024 13:14:25 +0100 Subject: [PATCH] CMakeLists.txt: eliminate floating dependencies Prior to this, the respective build options would get enabled depending on whether or not these components were found on the build system. I believe it's better to make them strict (add REQUIRED parameter), so that rpm builds are always deterministic, subject to cmake options. Resolves: https://github.com/rpm-software-management/rpm/issues/2855 --- CMakeLists.txt | 31 +++++++++++++++++++++++++------ docs/CMakeLists.txt | 4 +++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6eb16cc4b1..c8a04a5224 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,13 @@ option(WITH_IMAEVM "Build with IMA support" OFF) option(WITH_FAPOLICYD "Build with fapolicyd support" ON) option(WITH_INTERNAL_OPENPGP "Use internal OpenPGP parser (DEPRECATED)" OFF) option(WITH_READLINE "Build with readline support" ON) +option(WITH_BZIP2 "Build with bzip2 support" ON) +option(WITH_ICONV "Build with iconv support" ON) +option(WITH_ZSTD "Build with zstd support" ON) +option(WITH_LIBDW "Build with libdw support" ON) +option(WITH_LIBELF "Build with libelf support" ON) +option(WITH_LIBLZMA "Build with liblzma support" ON) +option(WITH_DOXYGEN "Build with doxygen support" ON) set(RPM_CONFIGDIR "${CMAKE_INSTALL_PREFIX}/lib/rpm" CACHE PATH "rpm home") set(RPM_MACROSDIR "${RPM_CONFIGDIR}/macros.d") @@ -193,8 +200,12 @@ set(REQFUNCS find_package(PkgConfig REQUIRED) find_package(Lua 5.2 REQUIRED) find_package(ZLIB REQUIRED) -find_package(BZip2) -find_package(Iconv) +if (WITH_BZIP2) + find_package(BZip2 REQUIRED) +endif() +if (WITH_ICONV) + find_package(Iconv REQUIRED) +endif() pkg_check_modules(POPT REQUIRED IMPORTED_TARGET popt) @@ -202,10 +213,18 @@ if (WITH_READLINE) pkg_check_modules(READLINE REQUIRED IMPORTED_TARGET readline) endif() -pkg_check_modules(ZSTD IMPORTED_TARGET libzstd>=1.3.8) -pkg_check_modules(LIBELF IMPORTED_TARGET libelf) -pkg_check_modules(LIBDW IMPORTED_TARGET libdw) -pkg_check_modules(LIBLZMA IMPORTED_TARGET liblzma>=5.2.0) +if (WITH_ZSTD) + pkg_check_modules(ZSTD REQUIRED IMPORTED_TARGET libzstd>=1.3.8) +endif() +if (WITH_LIBELF) + pkg_check_modules(LIBELF REQUIRED IMPORTED_TARGET libelf) +endif() +if (WITH_LIBDW) + pkg_check_modules(LIBDW REQUIRED IMPORTED_TARGET libdw) +endif() +if (WITH_LIBLZMA) + pkg_check_modules(LIBLZMA REQUIRED IMPORTED_TARGET liblzma>=5.2.0) +endif() pkg_check_modules(LIBARCHIVE REQUIRED IMPORTED_TARGET libarchive) # Lua module does not ship an IMPORTED target, define our own diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 0bc0761301..378b029f8b 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -3,7 +3,9 @@ mark_as_advanced(PANDOC) add_subdirectory(man) -find_package(Doxygen) +if (WITH_DOXYGEN) + find_package(Doxygen REQUIRED) +endif() if (DOXYGEN_FOUND) # XXX API docs should be pre-built in tarballs file(GLOB headers ${CMAKE_SOURCE_DIR}/include/rpm/*.h)