From d892dedf2253127c85a443330630c6a9704c5e28 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Dec 2023 11:28:18 -0500 Subject: FindFreetype: always find the config module quietly When the config module is not present, a spurious "freetype not found" is output before the pre-existing logic is used. Instead, silence the module and use FPHSA to report as-if `Freetype` did the search. See: #25485 --- Modules/FindFreetype.cmake | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 583d056..32b2e06 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -66,10 +66,6 @@ directory of a Freetype installation. # everything still works. set(_Freetype_args) -if (Freetype_FIND_QUIETLY) - list(APPEND _Freetype_args - QUIET) -endif () if (Freetype_FIND_VERSION) list(APPEND _Freetype_args "${Freetype_FIND_VERSION}") @@ -100,7 +96,8 @@ if (_Freetype_component_opt) OPTIONAL_COMPONENTS "${_Freetype_component_opt}") endif () unset(_Freetype_component_opt) -find_package(freetype CONFIG ${_Freetype_args}) +# Always find with QUIET to avoid noise when it is not found. +find_package(freetype CONFIG QUIET ${_Freetype_args}) unset(_Freetype_args) if (freetype_FOUND) if (NOT TARGET Freetype::Freetype) @@ -150,6 +147,14 @@ if (freetype_FOUND) set(Freetype_${_Freetype_component}_FOUND "${freetype_${_Freetype_component}_FOUND}") endforeach () unset(_Freetype_component) + + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + find_package_handle_standard_args( + Freetype + VERSION_VAR + FREETYPE_VERSION_STRING + ) + return () endif () -- cgit v0.12 From a575bebf0d28cb00481da66f0aad306262b69d13 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Dec 2023 13:12:16 -0500 Subject: FindFreetype: also consider RelWithDebInfo-built libraries --- Modules/FindFreetype.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 32b2e06..a24fd40 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -110,6 +110,9 @@ if (freetype_FOUND) get_property(_Freetype_location TARGET freetype PROPERTY IMPORTED_IMPLIB) if (NOT _Freetype_location) get_property(_Freetype_location_release TARGET freetype PROPERTY IMPORTED_IMPLIB_RELEASE) + if (NOT _Freetype_location_release) + get_property(_Freetype_location_release TARGET freetype PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO) + endif () get_property(_Freetype_location_debug TARGET freetype PROPERTY IMPORTED_IMPLIB_DEBUG) if (_Freetype_location_release AND _Freetype_location_debug) set(_Freetype_location @@ -121,6 +124,9 @@ if (freetype_FOUND) set(_Freetype_location "${_Freetype_location_debug}") else () get_property(_Freetype_location_release TARGET freetype PROPERTY LOCATION_RELEASE) + if (NOT _Freetype_location_release) + get_property(_Freetype_location_release TARGET freetype PROPERTY LOCATION_RELWITHDEBINFO) + endif () get_property(_Freetype_location_debug TARGET freetype PROPERTY LOCATION_DEBUG) if (_Freetype_location_release AND _Freetype_location_debug) set(_Freetype_location -- cgit v0.12 From e8e7d9f775c3811ae58de75056c68f300868081e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Dec 2023 11:28:18 -0500 Subject: FindTIFF: always find the config module quietly When the config module is not present, a spurious "tiff not found" is output before the pre-existing logic is used. Instead, silence the module and use FPHSA to report as-if `TIFF` did the search. Fixes: #25485 --- Modules/FindTIFF.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 4a93c04..45b3164 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -66,10 +66,6 @@ The following cache variables may also be set: #]=======================================================================] set(_TIFF_args) -if (TIFF_FIND_QUIETLY) - list(APPEND _TIFF_args - QUIET) -endif () if (TIFF_FIND_VERSION) list(APPEND _TIFF_args "${TIFF_FIND_VERSION}") @@ -100,7 +96,8 @@ if (_TIFF_component_opt) OPTIONAL_COMPONENTS "${_TIFF_component_opt}") endif () unset(_TIFF_component_opt) -find_package(tiff CONFIG ${_TIFF_args}) +# Always find with QUIET to avoid noise when it is not found. +find_package(tiff CONFIG QUIET ${_TIFF_args}) unset(_TIFF_args) if (tiff_FOUND) if (NOT TARGET TIFF::TIFF) @@ -135,6 +132,12 @@ if (tiff_FOUND) set(TIFF_${_TIFF_component}_FOUND "${tiff_${_TIFF_component}_FOUND}") endforeach () unset(_TIFF_component) + + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + find_package_handle_standard_args(TIFF + HANDLE_COMPONENTS + VERSION_VAR TIFF_VERSION_STRING) + return () endif () -- cgit v0.12 From 581acbce523dada7005bf0bef43eff346610e936 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Dec 2023 11:34:08 -0500 Subject: FindTIFF: consider `IMPLIB`-using platforms Support multi-config-providing and `IMPLIB`-using deployments with the `tiff-config` trampoline code. Follow the pattern used in `FindFreetype` by commit ae9890cd36 (FindFreeType: consider `IMPLIB`-using platforms, 2023-10-26, v3.28.0-rc4~10^2~3). See: #25485 --- Modules/FindTIFF.cmake | 79 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 45b3164..2a99314 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -107,15 +107,86 @@ if (tiff_FOUND) endif () get_property(TIFF_INCLUDE_DIRS TARGET TIFF::tiff PROPERTY INTERFACE_INCLUDE_DIRECTORIES) get_property(TIFF_LIBRARIES TARGET TIFF::tiff PROPERTY INTERFACE_LINK_LIBRARIES) - get_property(_TIFF_location TARGET TIFF::tiff PROPERTY LOCATION) - list(APPEND TIFF_LIBRARIES + get_property(_TIFF_location TARGET TIFF::tiff PROPERTY IMPORTED_IMPLIB) + if (NOT _TIFF_location) + get_property(_TIFF_location_release TARGET TIFF::tiff PROPERTY IMPORTED_IMPLIB_RELEASE) + if (NOT _TIFF_location_release) + get_property(_TIFF_location_release TARGET TIFF::tiff PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO) + endif () + get_property(_TIFF_location_debug TARGET TIFF::tiff PROPERTY IMPORTED_IMPLIB_DEBUG) + if (_TIFF_location_release AND _TIFF_location_debug) + set(_TIFF_location + optimized "${_TIFF_location_release}" + debug "${_TIFF_location_debug}") + elseif (_TIFF_location_release) + set(_TIFF_location "${_TIFF_location_release}") + elseif (_TIFF_location_debug) + set(_TIFF_location "${_TIFF_location_debug}") + else () + get_property(_TIFF_location_release TARGET TIFF::tiff PROPERTY LOCATION_RELEASE) + if (NOT _TIFF_location_release) + get_property(_TIFF_location_release TARGET TIFF::tiff PROPERTY LOCATION_RELWITHDEBINFO) + endif () + get_property(_TIFF_location_debug TARGET TIFF::tiff PROPERTY LOCATION_DEBUG) + if (_TIFF_location_release AND _TIFF_location_debug) + set(_TIFF_location + optimized "${_TIFF_location_release}" + debug "${_TIFF_location_debug}") + elseif (_TIFF_location_release) + set(_TIFF_location "${_TIFF_location_release}") + elseif (_TIFF_location_debug) + set(_TIFF_location "${_TIFF_location_debug}") + else () + get_property(_TIFF_location TARGET TIFF::tiff PROPERTY LOCATION) + endif () + endif () + unset(_TIFF_location_release) + unset(_TIFF_location_debug) + endif () + list(INSERT TIFF_LIBRARIES 0 "${_TIFF_location}") unset(_TIFF_location) set(TIFF_FOUND 1) if("CXX" IN_LIST TIFF_FIND_COMPONENTS) if (TARGET TIFF::CXX) - get_property(_TIFF_CXX_location TARGET TIFF::CXX PROPERTY LOCATION) - list(APPEND TIFF_LIBRARIES ${_TIFF_CXX_location}) + get_property(_TIFF_CXX_location TARGET TIFF::CXX PROPERTY IMPORTED_IMPLIB) + if (NOT _TIFF_CXX_location) + get_property(_TIFF_CXX_location_release TARGET TIFF::CXX PROPERTY IMPORTED_IMPLIB_RELEASE) + if (NOT _TIFF_CXX_location_release) + get_property(_TIFF_CXX_location_release TARGET TIFF::CXX PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO) + endif () + get_property(_TIFF_CXX_location_debug TARGET TIFF::CXX PROPERTY IMPORTED_IMPLIB_DEBUG) + if (_TIFF_CXX_location_release AND _TIFF_CXX_location_debug) + set(_TIFF_CXX_location + optimized "${_TIFF_CXX_location_release}" + debug "${_TIFF_CXX_location_debug}") + elseif (_TIFF_CXX_location_release) + set(_TIFF_CXX_location "${_TIFF_CXX_location_release}") + elseif (_TIFF_CXX_location_debug) + set(_TIFF_CXX_location "${_TIFF_CXX_location_debug}") + else () + get_property(_TIFF_CXX_location_release TARGET TIFF::CXX PROPERTY LOCATION_RELEASE) + if (NOT _TIFF_CXX_location_release) + get_property(_TIFF_CXX_location_release TARGET TIFF::CXX PROPERTY LOCATION_RELWITHDEBINFO) + endif () + get_property(_TIFF_CXX_location_debug TARGET TIFF::CXX PROPERTY LOCATION_DEBUG) + if (_TIFF_CXX_location_release AND _TIFF_CXX_location_debug) + set(_TIFF_CXX_location + optimized "${_TIFF_CXX_location_release}" + debug "${_TIFF_CXX_location_debug}") + elseif (_TIFF_CXX_location_release) + set(_TIFF_CXX_location "${_TIFF_CXX_location_release}") + elseif (_TIFF_CXX_location_debug) + set(_TIFF_CXX_location "${_TIFF_CXX_location_debug}") + else () + get_property(_TIFF_CXX_location TARGET TIFF::CXX PROPERTY LOCATION) + endif () + endif () + unset(_TIFF_CXX_location_release) + unset(_TIFF_CXX_location_debug) + endif () + list(INSERT TIFF_LIBRARIES 0 + "${_TIFF_CXX_location}") unset(_TIFF_CXX_location) set(TIFF_CXX_FOUND 1) else () -- cgit v0.12