From 287912d6fc7ab0ab0b5f69a4a5260b5bf53121ba Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 5 Nov 2020 00:14:32 +0100 Subject: Rename CMake find_package helpers to avoid developer warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message): | The package name passed to `find_package_handle_standard_args` (Berkeley) | does not match the name of the calling package (BerkeleyDB). This can lead | to problems in calling code that expects `find_package` result variables | (e.g., `_FOUND`) to follow a certain pattern. | Call Stack (most recent call first): | CMake/FindBerkeleyDB.cmake:57 (find_package_handle_standard_args) | CMakeLists.txt:83 (find_package) | This warning is for project developers. Use -Wno-dev to suppress it. And indeed, we checked for BERKLEY_DB_FOUND which was not defined so our HAVE_BDB was not set – just that it is never used, so it wasn't noticed. --- CMake/FindBerkeley.cmake | 59 ++++++++++++++++++++++++++++++++++++++++++++++ CMake/FindBerkeleyDB.cmake | 59 ---------------------------------------------- CMake/FindGCRYPT.cmake | 25 ++++++++++++++++++++ CMake/FindGcrypt.cmake | 25 -------------------- CMake/FindSECCOMP.cmake | 25 ++++++++++++++++++++ CMake/FindSeccomp.cmake | 25 -------------------- CMake/FindZSTD.cmake | 25 ++++++++++++++++++++ CMake/FindZstd.cmake | 25 -------------------- CMakeLists.txt | 10 ++++---- ftparchive/CMakeLists.txt | 6 ++--- 10 files changed, 142 insertions(+), 142 deletions(-) create mode 100644 CMake/FindBerkeley.cmake delete mode 100644 CMake/FindBerkeleyDB.cmake create mode 100644 CMake/FindGCRYPT.cmake delete mode 100644 CMake/FindGcrypt.cmake create mode 100644 CMake/FindSECCOMP.cmake delete mode 100644 CMake/FindSeccomp.cmake create mode 100644 CMake/FindZSTD.cmake delete mode 100644 CMake/FindZstd.cmake diff --git a/CMake/FindBerkeley.cmake b/CMake/FindBerkeley.cmake new file mode 100644 index 000000000..a6215d728 --- /dev/null +++ b/CMake/FindBerkeley.cmake @@ -0,0 +1,59 @@ +# - Try to find Berkeley DB +# Once done this will define +# +# BERKELEY_FOUND - system has Berkeley DB +# BERKELEY_INCLUDE_DIRS - the Berkeley DB include directory +# BERKELEY_LIBRARIES - Link these to use Berkeley DB +# BERKELEY_DEFINITIONS - Compiler switches required for using Berkeley DB + +# Copyright (c) 2006, Alexander Dymo, +# Copyright (c) 2016, Julian Andres Klode +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +# We need NO_DEFAULT_PATH here, otherwise CMake helpfully picks up the wrong +# db.h on BSD systems instead of the Berkeley DB one. +find_path(BERKELEY_INCLUDE_DIRS db.h + ${CMAKE_INSTALL_FULL_INCLUDEDIR}/db5 + /usr/local/include/db5 + /usr/include/db5 + + ${CMAKE_INSTALL_FULL_INCLUDEDIR}/db4 + /usr/local/include/db4 + /usr/include/db4 + + ${CMAKE_INSTALL_FULL_INCLUDEDIR} + /usr/local/include + /usr/include + + NO_DEFAULT_PATH +) + +find_library(BERKELEY_LIBRARIES NAMES db db-5) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Berkeley "Could not find Berkeley DB >= 4.1" BERKELEY_INCLUDE_DIRS BERKELEY_LIBRARIES) +# show the BERKELEY_INCLUDE_DIRS and BERKELEY_LIBRARIES variables only in the advanced view +mark_as_advanced(BERKELEY_INCLUDE_DIRS BERKELEY_LIBRARIES) diff --git a/CMake/FindBerkeleyDB.cmake b/CMake/FindBerkeleyDB.cmake deleted file mode 100644 index 34bc3b0d1..000000000 --- a/CMake/FindBerkeleyDB.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# - Try to find Berkeley DB -# Once done this will define -# -# BERKELEY_DB_FOUND - system has Berkeley DB -# BERKELEY_DB_INCLUDE_DIRS - the Berkeley DB include directory -# BERKELEY_DB_LIBRARIES - Link these to use Berkeley DB -# BERKELEY_DB_DEFINITIONS - Compiler switches required for using Berkeley DB - -# Copyright (c) 2006, Alexander Dymo, -# Copyright (c) 2016, Julian Andres Klode -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -# We need NO_DEFAULT_PATH here, otherwise CMake helpfully picks up the wrong -# db.h on BSD systems instead of the Berkeley DB one. -find_path(BERKELEY_DB_INCLUDE_DIRS db.h - ${CMAKE_INSTALL_FULL_INCLUDEDIR}/db5 - /usr/local/include/db5 - /usr/include/db5 - - ${CMAKE_INSTALL_FULL_INCLUDEDIR}/db4 - /usr/local/include/db4 - /usr/include/db4 - - ${CMAKE_INSTALL_FULL_INCLUDEDIR} - /usr/local/include - /usr/include - - NO_DEFAULT_PATH -) - -find_library(BERKELEY_DB_LIBRARIES NAMES db db-5) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Berkeley "Could not find Berkeley DB >= 4.1" BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES) -# show the BERKELEY_DB_INCLUDE_DIRS and BERKELEY_DB_LIBRARIES variables only in the advanced view -mark_as_advanced(BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES) diff --git a/CMake/FindGCRYPT.cmake b/CMake/FindGCRYPT.cmake new file mode 100644 index 000000000..56bfc9fef --- /dev/null +++ b/CMake/FindGCRYPT.cmake @@ -0,0 +1,25 @@ +# - Try to find GCRYPT +# Once done, this will define +# +# GCRYPT_FOUND - system has GCRYPT +# GCRYPT_INCLUDE_DIRS - the GCRYPT include directories +# GCRYPT_LIBRARIES - the GCRYPT library +find_package(PkgConfig) + +pkg_check_modules(GCRYPT_PKGCONF libgcrypt) + +find_path(GCRYPT_INCLUDE_DIRS + NAMES gcrypt.h + PATHS ${GCRYPT_PKGCONF_INCLUDE_DIRS} +) + + +find_library(GCRYPT_LIBRARIES + NAMES gcrypt + PATHS ${GCRYPT_PKGCONF_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GCRYPT DEFAULT_MSG GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES) + +mark_as_advanced(GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES) diff --git a/CMake/FindGcrypt.cmake b/CMake/FindGcrypt.cmake deleted file mode 100644 index 56bfc9fef..000000000 --- a/CMake/FindGcrypt.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# - Try to find GCRYPT -# Once done, this will define -# -# GCRYPT_FOUND - system has GCRYPT -# GCRYPT_INCLUDE_DIRS - the GCRYPT include directories -# GCRYPT_LIBRARIES - the GCRYPT library -find_package(PkgConfig) - -pkg_check_modules(GCRYPT_PKGCONF libgcrypt) - -find_path(GCRYPT_INCLUDE_DIRS - NAMES gcrypt.h - PATHS ${GCRYPT_PKGCONF_INCLUDE_DIRS} -) - - -find_library(GCRYPT_LIBRARIES - NAMES gcrypt - PATHS ${GCRYPT_PKGCONF_LIBRARY_DIRS} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GCRYPT DEFAULT_MSG GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES) - -mark_as_advanced(GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES) diff --git a/CMake/FindSECCOMP.cmake b/CMake/FindSECCOMP.cmake new file mode 100644 index 000000000..5cfd13a37 --- /dev/null +++ b/CMake/FindSECCOMP.cmake @@ -0,0 +1,25 @@ +# - Try to find SECCOMP +# Once done, this will define +# +# SECCOMP_FOUND - system has SECCOMP +# SECCOMP_INCLUDE_DIRS - the SECCOMP include directories +# SECCOMP_LIBRARIES - the SECCOMP library +find_package(PkgConfig) + +pkg_check_modules(SECCOMP_PKGCONF libseccomp) + +find_path(SECCOMP_INCLUDE_DIRS + NAMES seccomp.h + PATHS ${SECCOMP_PKGCONF_INCLUDE_DIRS} +) + + +find_library(SECCOMP_LIBRARIES + NAMES seccomp + PATHS ${SECCOMP_PKGCONF_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SECCOMP DEFAULT_MSG SECCOMP_INCLUDE_DIRS SECCOMP_LIBRARIES) + +mark_as_advanced(SECCOMP_INCLUDE_DIRS SECCOMP_LIBRARIES) diff --git a/CMake/FindSeccomp.cmake b/CMake/FindSeccomp.cmake deleted file mode 100644 index 5cfd13a37..000000000 --- a/CMake/FindSeccomp.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# - Try to find SECCOMP -# Once done, this will define -# -# SECCOMP_FOUND - system has SECCOMP -# SECCOMP_INCLUDE_DIRS - the SECCOMP include directories -# SECCOMP_LIBRARIES - the SECCOMP library -find_package(PkgConfig) - -pkg_check_modules(SECCOMP_PKGCONF libseccomp) - -find_path(SECCOMP_INCLUDE_DIRS - NAMES seccomp.h - PATHS ${SECCOMP_PKGCONF_INCLUDE_DIRS} -) - - -find_library(SECCOMP_LIBRARIES - NAMES seccomp - PATHS ${SECCOMP_PKGCONF_LIBRARY_DIRS} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SECCOMP DEFAULT_MSG SECCOMP_INCLUDE_DIRS SECCOMP_LIBRARIES) - -mark_as_advanced(SECCOMP_INCLUDE_DIRS SECCOMP_LIBRARIES) diff --git a/CMake/FindZSTD.cmake b/CMake/FindZSTD.cmake new file mode 100644 index 000000000..68118049b --- /dev/null +++ b/CMake/FindZSTD.cmake @@ -0,0 +1,25 @@ +# - Try to find ZSTD +# Once done, this will define +# +# ZSTD_FOUND - system has ZSTD +# ZSTD_INCLUDE_DIRS - the ZSTD include directories +# ZSTD_LIBRARIES - the ZSTD library +find_package(PkgConfig) + +pkg_check_modules(ZSTD_PKGCONF libzstd) + +find_path(ZSTD_INCLUDE_DIRS + NAMES zstd.h + PATHS ${ZSTD_PKGCONF_INCLUDE_DIRS} +) + + +find_library(ZSTD_LIBRARIES + NAMES zstd + PATHS ${ZSTD_PKGCONF_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES) + +mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES) diff --git a/CMake/FindZstd.cmake b/CMake/FindZstd.cmake deleted file mode 100644 index 68118049b..000000000 --- a/CMake/FindZstd.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# - Try to find ZSTD -# Once done, this will define -# -# ZSTD_FOUND - system has ZSTD -# ZSTD_INCLUDE_DIRS - the ZSTD include directories -# ZSTD_LIBRARIES - the ZSTD library -find_package(PkgConfig) - -pkg_check_modules(ZSTD_PKGCONF libzstd) - -find_path(ZSTD_INCLUDE_DIRS - NAMES zstd.h - PATHS ${ZSTD_PKGCONF_INCLUDE_DIRS} -) - - -find_library(ZSTD_LIBRARIES - NAMES zstd - PATHS ${ZSTD_PKGCONF_LIBRARY_DIRS} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES) - -mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4afce7ea..51f0c25d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,8 +80,8 @@ add_optional_compile_options(Wsuggest-override) add_optional_compile_options(Werror=suggest-override) add_optional_compile_options(Werror=return-type) # apt-ftparchive dependencies -find_package(BerkeleyDB REQUIRED) -if (BERKELEY_DB_FOUND) +find_package(Berkeley REQUIRED) +if (BERKELEY_FOUND) set(HAVE_BDB 1) endif() @@ -113,7 +113,7 @@ if (LZ4_FOUND) set(HAVE_LZ4 1) endif() -find_package(Zstd) +find_package(ZSTD) if (ZSTD_FOUND) set(HAVE_ZSTD 1) endif() @@ -129,12 +129,12 @@ if (SYSTEMD_FOUND) set(HAVE_SYSTEMD 1) endif() -find_package(Seccomp) +find_package(SECCOMP) if (SECCOMP_FOUND) set(HAVE_SECCOMP 1) endif() -find_package(Gcrypt REQUIRED) +find_package(GCRYPT REQUIRED) # Mount()ing and stat()ing and friends check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H) diff --git a/ftparchive/CMakeLists.txt b/ftparchive/CMakeLists.txt index 9aa6606f1..4af250474 100644 --- a/ftparchive/CMakeLists.txt +++ b/ftparchive/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(${BERKELEY_DB_INCLUDE_DIRS}) +include_directories(${BERKELEY_INCLUDE_DIRS}) # Definition of the C++ files used to build the program - note that this # is expanded at CMake time, so you have to rerun cmake if you add or remove # a file (you can just run cmake . in the build directory) @@ -6,8 +6,8 @@ file(GLOB_RECURSE source "*.cc") add_executable(apt-ftparchive ${source}) # Link the executables against the libraries -target_include_directories(apt-ftparchive PRIVATE ${BERKELEY_DB_INCLUDE_DIRS}) -target_link_libraries(apt-ftparchive apt-pkg apt-private ${BERKELEY_DB_LIBRARIES}) +target_include_directories(apt-ftparchive PRIVATE ${BERKELEY_INCLUDE_DIRS}) +target_link_libraries(apt-ftparchive apt-pkg apt-private ${BERKELEY_LIBRARIES}) # Install the executables install(TARGETS apt-ftparchive RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -- cgit v1.2.3-70-g09d2