Skip to content

Commit

Permalink
CMakeLists.txt: eliminate floating dependencies
Browse files Browse the repository at this point in the history
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: #2855
  • Loading branch information
Alexander Kanavin authored and dmnks committed Mar 6, 2024
1 parent f016ab7 commit 26a1ccf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -193,19 +200,31 @@ 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)

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
Expand Down
4 changes: 3 additions & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 26a1ccf

Please sign in to comment.