Skip to content

Commit

Permalink
Clean up find_package flag handling in Find modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Dec 22, 2022
1 parent 1e312b4 commit 7c6b34f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
20 changes: 9 additions & 11 deletions cmake/Modules/FindLibDW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ This module will set the following variables in your project:
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT

if(LibDW_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

if(NOT "x${LibDW_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDW_FIND_VERSION}")
endif()

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${LibDW_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDW_FIND_VERSION}")
endif()
if(LibDW_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

pkg_check_modules(PC_LIBDW ${_quiet} "libdw${_version}")
unset(_version)
unset(_quiet)
endif()

if(PC_LIBDW_FOUND)
Expand Down Expand Up @@ -127,6 +128,3 @@ if(LibDW_FOUND)
IMPORTED_LOCATION "${LibDW_LIBRARIES}")
endif()
endif()

unset(_quiet)
unset(_version)
20 changes: 9 additions & 11 deletions cmake/Modules/FindLibDebuginfod.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ This module will set the following variables in your project:
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT

if(LibDebuginfod_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

if(NOT "x${LibDebuginfod_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDebuginfod_FIND_VERSION}")
endif()

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${LibDebuginfod_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibDebuginfod_FIND_VERSION}")
endif()
if(LibDebuginfod_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

pkg_check_modules(PC_LIBDEBUGINFOD ${_quiet} "libdebuginfod${_version}")
unset(_version)
unset(_quiet)
endif()

if(PC_LIBDEBUGINFOD_FOUND)
Expand Down Expand Up @@ -107,6 +108,3 @@ if(LibDebuginfod_FOUND)
"${LibDebuginfod_LIBRARIES}")
endif()
endif()

unset(_quiet)
unset(_version)
20 changes: 9 additions & 11 deletions cmake/Modules/FindLibELF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ This module will set the following variables in your project:
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT

if(LibELF_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

if(NOT "x${LibELF_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibELF_FIND_VERSION}")
endif()

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${LibELF_FIND_VERSION}" STREQUAL "x")
set(_version ">=${LibELF_FIND_VERSION}")
endif()
if(LibELF_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

pkg_check_modules(PC_LIBELF ${_quiet} "libelf${_version}")
unset(_version)
unset(_quiet)
endif()

if(PC_LIBELF_FOUND)
Expand Down Expand Up @@ -111,6 +112,3 @@ if(LibELF_FOUND)
IMPORTED_LOCATION "${LibELF_LIBRARIES}")
endif()
endif()

unset(_quiet)
unset(_version)
19 changes: 9 additions & 10 deletions cmake/Modules/FindValgrind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ This module will set the following variables in your project:
#]=======================================================================]
cmake_policy(SET CMP0074 NEW) # Use <Package>_ROOT

if(Valgrind_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

if(NOT "x${Valgrind_FIND_VERSION}" STREQUAL "x")
set(_version ">=${Valgrind_FIND_VERSION}")
endif()

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
if(NOT "x${Valgrind_FIND_VERSION}" STREQUAL "x")
set(_version ">=${Valgrind_FIND_VERSION}")
endif()
if(Valgrind_FIND_QUIETLY)
set(_quiet "QUIET")
endif()

pkg_check_modules(PC_VALGRIND ${_quiet} "valgrind${_version}")
unset(_version)
unset(_quiet)
endif()

if(PC_VALGRIND_FOUND)
Expand Down Expand Up @@ -90,5 +91,3 @@ find_package_handle_standard_args(
VERSION_VAR Valgrind_VERSION)

mark_as_advanced(Valgrind_INCLUDE_DIRS)
unset(_quiet)
unset(_version)

0 comments on commit 7c6b34f

Please sign in to comment.