Skip to content

Commit

Permalink
FindPackage.cmake:Added support to handle REQUIRED and QUIET (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Oct 26, 2021
1 parent d69cbd5 commit f7ed978
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 63 deletions.
2 changes: 1 addition & 1 deletion DeviceIdentification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (PLUGIN_DEVICEIDENTIFICATION_USE_MFR AND MFRFWLIBS_FOUND)
Implementation/MFR/MFR.cpp)
target_link_libraries(${MODULE_NAME}
PRIVATE
mfrfwlibs::mfrfwlibs)
MFRFWLibs::MFRFWLibs)
elseif (BUILD_BROADCOM)
target_sources(${MODULE_NAME}
PRIVATE
Expand Down
20 changes: 12 additions & 8 deletions DeviceIdentification/cmake/FindBCM_HOST.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_package(PkgConfig)
pkg_check_modules(PC_BCM_HOST bcm_host)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PC_BCM_HOST DEFAULT_MSG PC_BCM_HOST_FOUND)
if(BCM_HOST_FIND_QUIETLY)
set(_BCM_HOST_MODE QUIET)
elseif(BCM_HOST_FIND_REQUIRED)
set(_BCM_HOST_MODE REQUIRED)
endif()

mark_as_advanced(PC_BCM_HOST_INCLUDE_DIRS PC_BCM_HOST_LIBRARIES)
find_package(PkgConfig)
pkg_check_modules(PC_BCM_HOST ${_BCM_HOST_MODE} bcm_host)

if(${PC_BCM_HOST_FOUND})
find_library(BCM_HOST_LIBRARY bcm_host
HINTS ${PC_BCM_LIBDIR} ${PC_BCM_LIBRARY_DIRS}
)
set(BCM_LIBRARIES ${PC_BCM_HOST_LIBRARIES})
set(BCM_HOST_FOUND ${PC_BCM_HOST_FOUND})

if(NOT TARGET BCM_HOST::BCM_HOST)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BCM_HOST DEFAULT_MSG PC_BCM_HOST_FOUND PC_BCM_HOST_INCLUDE_DIRS BCM_HOST_LIBRARY PC_BCM_HOST_LIBRARIES)
mark_as_advanced(PC_BCM_HOST_INCLUDE_DIRS PC_BCM_HOST_LIBRARIES)

if(BCM_HOST_FOUND AND NOT TARGET BCM_HOST::BCM_HOST)
add_library(BCM_HOST::BCM_HOST UNKNOWN IMPORTED)

set_target_properties(BCM_HOST::BCM_HOST
Expand Down
31 changes: 17 additions & 14 deletions DeviceIdentification/cmake/FindMFRFWLibs.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# - Try to find MFRFWLIBS
# Once done this will define
# MFRFWLIBS_FOUND - System has mfrfwlibs
# MFRFWLIBS_INCLUDE_DIRS - The mfrfwlibs include directories
# MFRFWLIBS_LIBRARIES - The libraries needed to use mfrfwlibs
# MFRFWLIBS_FOUND - System has MFRFWLibs
# MFRFWLIBS_INCLUDE_DIRS - The MFRFWLibs include directories
# MFRFWLIBS_LIBRARIES - The libraries needed to use MFRFWLibs
#
# Copyright (C) 2019 Metrological.
#
Expand All @@ -27,22 +27,25 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

find_package(PkgConfig)
pkg_check_modules(MFRFWLIBS fwupgrade)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(mfrfwlibs DEFAULT_MSG MFRFWLIBS_LIBRARIES)

mark_as_advanced(MFRFWLIBS_INCLUDE_DIRS MFRFWLIBS_LIBRARIES)

if(MFRFWLibs_FIND_QUIETLY)
set(_MFRFWLIBS_MODE QUIET)
elseif(MFRFWLibs_FIND_REQUIRED)
set(_MFRFWLIBS_MODE REQUIRED)
endif()

find_package(PkgConfig)
pkg_check_modules(MFRFWLIBS ${_MFRFWLIBS_MODE} fwupgrade)
find_library(MFRFWLIBS_LIBRARY NAMES ${MFRFWLIBS_LIBRARIES}
HINTS ${MFRFWLIBS_LIBDIR} ${MFRFWLIBS_LIBRARY_DIRS}
)

if(MFRFWLIBS_LIBRARY AND NOT TARGET mfrfwlibs::mfrfwlibs)
add_library(mfrfwlibs::mfrfwlibs UNKNOWN IMPORTED)
set_target_properties(mfrfwlibs::mfrfwlibs PROPERTIES
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MFRFWLibs DEFAULT_MSG MFRFWLIBS_LIBRARY MFRFWLIBS_LIBRARIES)
mark_as_advanced(MFRFWLIBS_INCLUDE_DIRS MFRFWLIBS_LIBRARIES)

if(MFRFWLibs_FOUND AND NOT TARGET MFRFWLibs::MFRFWLibs)
add_library(MFRFWLibs::MFRFWLibs UNKNOWN IMPORTED)
set_target_properties(MFRFWLibs::MFRFWLibs PROPERTIES
IMPORTED_LOCATION "${MFRFWLIBS_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${MFRFWLIBS_LIBRARIES}"
INTERFACE_COMPILE_OPTIONS "${MFRFWLIBS_DEFINITIONS}"
Expand Down
10 changes: 2 additions & 8 deletions DeviceIdentification/cmake/FindNEXUS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,15 @@ find_path(LIBNEXUS_INCLUDE nexus_config.h
find_library(LIBNEXUS_LIBRARY nexus)

if(EXISTS "${LIBNEXUS_LIBRARY}")
set(NEXUS_FOUND TRUE)

find_library(LIBB_OS_LIBRARY b_os)

find_library(LIBNEXUS_CLIENT_LIBRARY nexus_client)

find_library(LIBNXCLIENT_LIBRARY nxclient)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(LIBNEXUS DEFAULT_MSG LIBNEXUS_INCLUDE LIBNEXUS_LIBRARY)

find_package_handle_standard_args(NEXUS DEFAULT_MSG LIBNEXUS_INCLUDE LIBNEXUS_LIBRARY)
mark_as_advanced(LIBNEXUS_INCLUDE LIBNEXUS_LIBRARY)

if(NOT TARGET NEXUS::NEXUS)
if(NEXUS_FOUND AND NOT TARGET NEXUS::NEXUS)
add_library(NEXUS::NEXUS UNKNOWN IMPORTED)
set_target_properties(NEXUS::NEXUS PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
Expand Down
8 changes: 2 additions & 6 deletions DeviceIdentification/cmake/FindNXCLIENT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ find_library(LIBNXCLIENT_LIBRARY nxclient)

if(EXISTS "${LIBNXCLIENT_LIBRARY}")
include(FindPackageHandleStandardArgs)

set(NXCLIENT_FOUND TRUE)

find_package_handle_standard_args(LIBNXCLIENT DEFAULT_MSG NXCLIENT_FOUND LIBNXCLIENT_INCLUDE LIBNXCLIENT_LIBRARY)
find_package_handle_standard_args(NXCLIENT DEFAULT_MSG LIBNXCLIENT_INCLUDE LIBNXCLIENT_LIBRARY)
mark_as_advanced(LIBNXCLIENT_LIBRARY)

if(NOT TARGET NXCLIENT::NXCLIENT)
if(NXCLIENT_FOUND AND NOT TARGET NXCLIENT::NXCLIENT)
add_library(NXCLIENT::NXCLIENT UNKNOWN IMPORTED)

set_target_properties(NXCLIENT::NXCLIENT PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LIBNXCLIENT_LIBRARY}"
Expand Down
10 changes: 8 additions & 2 deletions Packager/cmake/FindGLIB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

if(GLIB_FIND_QUIETLY)
set(_GLIB_MODE QUIET)
elseif(GLIB_FIND_REQUIRED)
set(_GLIB_MODE REQUIRED)
endif()

find_package(PkgConfig)
pkg_check_modules(PC_GLIB QUIET glib-2.0)
pkg_check_modules(PC_GLIB ${_GLIB_MODE} glib-2.0)

find_library(GLIB_LIBRARIES
NAMES glib-2.0
Expand Down Expand Up @@ -106,7 +112,7 @@ foreach (_component ${GLIB_FIND_COMPONENTS})
endforeach ()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
find_package_handle_standard_args(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
VERSION_VAR GLIB_VERSION)

mark_as_advanced(
Expand Down
12 changes: 10 additions & 2 deletions Packager/cmake/FindLibOPKG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@
# LIBOPKG_INCLUDE_DIRS - The libopkg include directories
# LIBOPKG_LIBRARIES - The libraries needed to use libopkg
#

if(LibOPKG_FIND_QUIETLY)
set(_LIBOPKG_MODE QUIET)
elseif(LibOPKG_FIND_REQUIRED)
set(_LIBOPKG_MODE REQUIRED)
endif()

find_package(PkgConfig)
pkg_check_modules(PC_LIBOPKG libopkg)
pkg_check_modules(PC_LIBOPKG ${_LIBOPKG_MODE} libopkg)

if(PC_LIBOPKG_FOUND)
if(LIBOPKG_FIND_VERSION AND PC_LIBOPKG_VERSION)
Expand All @@ -43,7 +50,8 @@ set(LIBOPKG_LIBRARIES ${PC_LIBOPKG_LIBRARIES})
set(LIBOPKG_LIBRARY_DIRS ${PC_LIBOPKG_LIBRARY_DIRS} ${PC_LIBOPKG_LIBDIR})

find_library(OPKG_LIBRARY_LOCATION "${LIBOPKG_LIBRARIES}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibOPKG DEFAULT_MSG OPKG_LIBRARY_LOCATION LIBOPKG_INCLUDE_DIRS LIBOPKG_LIBRARIES)
mark_as_advanced(LIBOPKG_DEFINITIONS LIBOPKG_INCLUDE_DIRS LIBOPKG_LIBRARIES)

if(NOT TARGET LibOPKG::LibOPKG)
Expand Down
8 changes: 6 additions & 2 deletions Packager/cmake/FindSqlite.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
find_package(PkgConfig)

pkg_search_module(SQLITE REQUIRED sqlite3)
if(Sqlite_FIND_QUIETLY)
set(_SQLITE_MODE QUIET)
elseif(Sqlite_FIND_REQUIRED)
set(_SQLITE_MODE REQUIRED)
endif()
pkg_search_module(SQLITE ${_SQLITE_MODE} sqlite3)
7 changes: 6 additions & 1 deletion Packager/cmake/FindSqliteSee.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
find_package(PkgConfig)

pkg_search_module(SQLITE REQUIRED sqlite3see)
if(SqliteSee_FIND_QUIETLY)
set(_SQLITE_SEE_MODE QUIET)
elseif(SqliteSee_FIND_REQUIRED)
set(_SQLITE_SEE_MODE REQUIRED)
endif()
pkg_search_module(SQLITE_SEE ${_SQLITE_SEE_MODE} sqlite3see)
2 changes: 1 addition & 1 deletion WebKitBrowser/cmake/FindAampJSBindings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ find_library(AAMP_JSBINDINGS_LIBRARIES aampjsbindings)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(AAMP_JSBINDINGS DEFAULT_MSG AAMP_JSBINDINGS_LIBRARIES)
find_package_handle_standard_args(AampJSBindings DEFAULT_MSG AAMP_JSBINDINGS_LIBRARIES)

mark_as_advanced(AAMP_JSBINDINGS_LIBRARIES)
27 changes: 13 additions & 14 deletions WebKitBrowser/cmake/FindWPEBackend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ if(PC_WPE_BACKEND_FOUND)
NAMES ${PC_WPE_BACKEND_LIBRARIES}
HINTS ${PC_WPE_BACKEND_LIBDIR} ${PC_WPE_BACKEND_LIBRARY_DIRS}
)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WPEBackend
VERSION_VAR PC_WPE_BACKEND_VERSION
REQUIRED_VARS WPE_BACKEND_LIBRARY WPE_BACKEND_INCLUDE_DIR WPE_BACKEND_LIBRARY)

if(PC_WPE_BACKEND_FOUND AND NOT TARGET WPEBackend::WPEBackend)
add_library(WPEBackend::WPEBackend SHARED IMPORTED)
set_target_properties(WPEBackend::WPEBackend PROPERTIES
IMPORTED_LOCATION "${WPE_BACKEND_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${WPE_BACKEND_INCLUDE_DIR}"
)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WPEBackend
VERSION_VAR PC_WPE_BACKEND_VERSION
REQUIRED_VARS WPE_BACKEND_LIBRARY WPE_BACKEND_INCLUDE_DIR)
mark_as_advanced(WPE_BACKEND_INCLUDE_DIR WPE_BACKEND_LIBRARY)
endif()

if(WPEBackend_FOUND AND NOT TARGET WPEBackend::WPEBackend)
add_library(WPEBackend::WPEBackend SHARED IMPORTED)
set_target_properties(WPEBackend::WPEBackend PROPERTIES
IMPORTED_LOCATION "${WPE_BACKEND_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${WPE_BACKEND_INCLUDE_DIR}"
)
endif()
8 changes: 4 additions & 4 deletions WebKitBrowser/cmake/FindWPEWebKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ else()
set(WEBKIT_GLIB_API FALSE CACHE INTERNAL "" FORCE)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WPEWebKit
VERSION_VAR WPE_WEBKIT_VERSION
REQUIRED_VARS WPE_WEBKIT_LIBRARY WPE_WEBKIT_LINK_LIBRARIES WPE_WEBKIT_INCLUDE_DIRS)
REQUIRED_VARS WPE_WEBKIT_FOUND WPE_WEBKIT_LIBRARY WPE_WEBKIT_LINK_LIBRARIES WPE_WEBKIT_INCLUDE_DIRS)
mark_as_advanced(WPE_WEBKIT_LINK_LIBRARIES WPE_WEBKIT_CFLAGS WPE_WEBKIT_INCLUDE_DIRS)

if(WPE_WEBKIT_FOUND AND NOT TARGET WPEWebKit::WPEWebKit)
if(WPEWebKit_FOUND AND NOT TARGET WPEWebKit::WPEWebKit)
add_library(WPEWebKit::WPEWebKit SHARED IMPORTED)
set_target_properties(WPEWebKit::WPEWebKit PROPERTIES
IMPORTED_LOCATION "${WPE_WEBKIT_LIBRARY}"
Expand All @@ -110,5 +112,3 @@ if(WPE_WEBKIT_FOUND AND NOT TARGET WPEWebKit::WPEWebKit)
INTERFACE_INCLUDE_DIRECTORIES "${WPE_WEBKIT_INCLUDE_DIRS}"
)
endif()

mark_as_advanced(WPE_WEBKIT_LINK_LIBRARIES WPE_WEBKIT_CFLAGS WPE_WEBKIT_INCLUDE_DIRS)

0 comments on commit f7ed978

Please sign in to comment.