1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

FPHSA: detect inclusion between find modules

Various find modules include each other to delegate finding some subset
or variant of the package. Ideally, these would use `find_dependency` or
some other actual `find_package` mechanism, but that is a larger change.
Instead, just detect inclusion and suppress FPHSA name mismatch
warnings.

Fixes: #21060
This commit is contained in:
Ben Boeckel
2020-08-06 12:38:04 -04:00
parent d421274e3e
commit 98844ec9db
7 changed files with 52 additions and 0 deletions

View File

@@ -424,8 +424,15 @@ if(OPENGL_EGL_INCLUDE_DIR)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "GLU")
# FindGLU include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive to
# the contents, detect the case in this module and suppress it explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS}
HANDLE_COMPONENTS)
unset(FPHSA_NAME_MISMATCHED)
unset(_OpenGL_REQUIRED_VARS)
# OpenGL:: targets

View File

@@ -73,8 +73,15 @@ endif()
set(PERL ${PERL_EXECUTABLE})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "PerlLibs")
# FindPerlLibs include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive to
# the contents, detect the case in this module and suppress it explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl
REQUIRED_VARS PERL_EXECUTABLE
VERSION_VAR PERL_VERSION_STRING)
unset(FPHSA_NAME_MISMATCHED)
mark_as_advanced(PERL_EXECUTABLE)

View File

@@ -201,9 +201,16 @@ endif()
# if the include a library are found then we have it
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "Qt")
# FindQt include()'s this module. It's an old pattern, but rather than trying
# to suppress this from outside the module (which is then sensitive to the
# contents, detect the case in this module and suppress it explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3
REQUIRED_VARS QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE
VERSION_VAR QT_VERSION_STRING)
unset(FPHSA_NAME_MISMATCHED)
set(QT_FOUND ${QT3_FOUND} )
if(QT_FOUND)

View File

@@ -1318,10 +1318,18 @@ if (NOT QT_VERSION_MAJOR EQUAL 4)
endif()
endif()
else()
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "Qt")
# FindQt include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive
# to the contents, detect the case in this module and suppress it
# explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 FOUND_VAR Qt4_FOUND
REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS}
VERSION_VAR QTVERSION
)
unset(FPHSA_NAME_MISMATCHED)
endif()
#######################################

View File

@@ -223,6 +223,12 @@ find_path(TK_INCLUDE_PATH
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "TclStub")
# FindTclStub include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive to
# the contents, detect the case in this module and suppress it explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
set(FPHSA_NAME_MISMATCHED 1)
set(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED})

View File

@@ -92,8 +92,17 @@ if(TCL_TCLSH)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "TCL" OR
CMAKE_FIND_PACKAGE_NAME STREQUAL "TclStub")
# FindTCL include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive to
# the contents, detect the case in this module and suppress it explicitly.
# Transitively, FindTclStub includes FindTCL.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh
REQUIRED_VARS TCL_TCLSH
VERSION_VAR TCLSH_VERSION_STRING)
unset(FPHSA_NAME_MISMATCHED)
mark_as_advanced(TCL_TCLSH)

View File

@@ -404,9 +404,17 @@ if (UNIX)
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if (CMAKE_FIND_PACKAGE_NAME STREQUAL "FLTK")
# FindFLTK include()'s this module. It's an old pattern, but rather than
# trying to suppress this from outside the module (which is then sensitive
# to the contents, detect the case in this module and suppress it
# explicitly.
set(FPHSA_NAME_MISMATCHED 1)
endif ()
find_package_handle_standard_args(X11
REQUIRED_VARS X11_X11_INCLUDE_PATH X11_X11_LIB
HANDLE_COMPONENTS)
unset(FPHSA_NAME_MISMATCHED)
if(X11_FOUND)
include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)