Adjust database packages FindFoo.cmake files to CMake convention

Replace package _LIBRARIES by _LIBRARY and _INCLUDE_DIRS by
_INCLUDE_DIR. Move find_package_handle_standard_args for Oracle and DB2,
since this call should set _FOUND variable but not separate condition.

Fixes: QTBUG-89866
Change-Id: I54be2c2c4d7ba4b849a27139702861ecd937c444
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexey Edelev 2021-01-07 11:05:07 +01:00
parent fd5006eb48
commit e74fd6897b
3 changed files with 41 additions and 36 deletions

View File

@ -19,43 +19,44 @@
# The db2 client library
if (NOT DEFINED DB2_INCLUDE_DIR)
find_path(DB2_INCLUDE_DIRS
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ENV DB2_HOME
PATH_SUFFIXES include)
else()
find_path(DB2_INCLUDE_DIRS
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ${DB2_INCLUDE_DIR})
endif()
if (NOT DEFINED DB2_LIBRARY_DIR)
find_library(DB2_LIBRARIES
find_library(DB2_LIBRARY
NAMES db2
HINTS ENV DB2LIB)
else()
find_library(DB2_LIBRARIES
find_library(DB2_LIBRARY
NAMES db2
HINTS ${DB2_LIBRARY_DIR})
endif()
if (NOT DB2_INCLUDE_DIRS STREQUAL "DB2_INCLUDE_DIRS-NOTFOUND" AND NOT DB2_LIBRARIES STREQUAL "DB2_LIBRARIES-NOTFOUND")
set(DB2_FOUND ON)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DB2 DEFAULT_MSG DB2_INCLUDE_DIR DB2_LIBRARY)
if(DB2_FOUND)
set(DB2_INCLUDE_DIRS "${DB2_INCLUDE_DIR}")
set(DB2_LIBRARIES "${DB2_LIBRARY}")
if(NOT TARGET DB2::DB2)
add_library(DB2::DB2 UNKNOWN IMPORTED)
set_target_properties(DB2::DB2 PROPERTIES
IMPORTED_LOCATION "${DB2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${DB2_INCLUDE_DIRS}")
endif()
endif()
if(DB2_FOUND AND NOT TARGET DB2::DB2)
add_library(DB2::DB2 UNKNOWN IMPORTED)
set_target_properties(DB2::DB2 PROPERTIES
IMPORTED_LOCATION "${DB2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${DB2_INCLUDE_DIRS}")
endif()
mark_as_advanced(DB2_INCLUDE_DIRS DB2_LIBRARIES)
mark_as_advanced(DB2_INCLUDE_DIR DB2_LIBRARY)
include(FeatureSummary)
set_package_properties(DB2 PROPERTIES
URL "https://www.ibm.com"
DESCRIPTION "IBM DB2 client library")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DB2 DEFAULT_MSG DB2_INCLUDE_DIRS DB2_LIBRARIES)

View File

@ -21,29 +21,33 @@
find_package(PkgConfig QUIET)
pkg_check_modules(PC_MySQL QUIET mysqlclient)
find_path(MySQL_INCLUDE_DIRS
find_path(MySQL_INCLUDE_DIR
NAMES mysql.h
HINTS ${PC_MySQL_INCLUDEDIR}
PATH_SUFFIXES mysql mariadb)
find_library(MySQL_LIBRARIES
find_library(MySQL_LIBRARY
NAMES libmysql mysql mysqlclient libmariadb mariadb
HINTS ${PC_MySQL_LIBDIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MySQL DEFAULT_MSG MySQL_LIBRARIES MySQL_INCLUDE_DIRS)
find_package_handle_standard_args(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
if(MySQL_FOUND AND NOT TARGET MySQL::MySQL)
if(MySQL_FOUND)
set(MySQL_INCLUDE_DIRS "${MySQL_INCLUDE_DIR}")
set(MySQL_LIBRARIES "${MySQL_LIBRARY}")
if(NOT TARGET MySQL::MySQL)
add_library(MySQL::MySQL UNKNOWN IMPORTED)
set_target_properties(MySQL::MySQL PROPERTIES
IMPORTED_LOCATION "${MySQL_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${MySQL_INCLUDE_DIRS}")
endif()
endif()
mark_as_advanced(MySQL_INCLUDE_DIRS MySQL_LIBRARIES)
mark_as_advanced(MySQL_INCLUDE_DIR MySQL_LIBRARY)
include(FeatureSummary)
set_package_properties(MySQL PROPERTIES
URL "https://www.mysql.com"
DESCRIPTION "MySQL client library")
URL "https://www.mysql.com"
DESCRIPTION "MySQL client library")

View File

@ -18,33 +18,33 @@
# ``Oracle::Oracle``
# The oracle instant client library
find_path(Oracle_INCLUDE_DIRS
find_path(Oracle_INCLUDE_DIR
NAMES oci.h
HINTS ${Oracle_INCLUDE_DIR})
set(ORACLE_OCI_NAMES clntsh ociei oraociei12 oci)
find_library(Oracle_LIBRARIES
NAMES NAMES ${ORACLE_OCI_NAMES}
find_library(Oracle_LIBRARY
NAMES ${ORACLE_OCI_NAMES}
HINTS ${Oracle_LIBRARY_DIR})
if (NOT Oracle_INCLUDE_DIRS STREQUAL "Oracle_INCLUDE_DIRS-NOTFOUND" AND NOT Oracle_LIBRARIES STREQUAL "Oracle_LIBRARIES-NOTFOUND")
set(Oracle_FOUND ON)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Oracle DEFAULT_MSG Oracle_LIBRARY Oracle_INCLUDE_DIR)
if(Oracle_FOUND AND NOT TARGET Oracle::OCI)
add_library(Oracle::OCI UNKNOWN IMPORTED)
set_target_properties(Oracle::OCI PROPERTIES
if(Oracle_FOUND)
set(Oracle_INCLUDE_DIRS "${Oracle_INCLUDE_DIR}")
set(Oracle_LIBRARIES "${Oracle_LIBRARY}")
if(NOT TARGET Oracle::OCI)
add_library(Oracle::OCI UNKNOWN IMPORTED)
set_target_properties(Oracle::OCI PROPERTIES
IMPORTED_LOCATION "${Oracle_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Oracle_INCLUDE_DIRS}")
endif()
endif()
mark_as_advanced(Oracle_INCLUDE_DIRS Oracle_LIBRARIES)
mark_as_advanced(Oracle_INCLUDE_DIR Oracle_LIBRARY)
include(FeatureSummary)
set_package_properties(Oracle PROPERTIES
URL "https://www.oracle.com"
DESCRIPTION "Oracle client library")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Oracle DEFAULT_MSG Oracle_INCLUDE_DIRS Oracle_LIBRARIES)