cmake: Don't use pkgconfig on Android.

It tends to pick up host libraries.
This commit is contained in:
Ryan Pavlik 2021-05-06 09:57:16 -05:00
parent 7dc61f8d51
commit 9626a8d575
8 changed files with 92 additions and 63 deletions

View file

@ -36,7 +36,7 @@
#=============================================================================
# Copyright 2014 Alex Merry <alex.merry@kde.org>
# Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
# Copyright 2019 Ryan Pavlik <ryan.pavlik@collabora.com>
# Copyright 2019, 2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@ -67,8 +67,12 @@ include(CMakePushCheckState)
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKGCONFIG_FOUND)
pkg_check_modules(PKG_EGL QUIET egl)
endif()
endif()
set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER})

View file

@ -40,11 +40,11 @@
# ``HIDAPI_LIBRARIES``
#
# Original Author:
# 2009-2010, 2019 Ryan Pavlik <ryan.pavlik@collabora.com> <abiryan@ryand.net>
# 2009-2010, 2019, 2021 Ryan Pavlik <ryan.pavlik@collabora.com> <abiryan@ryand.net>
# http://academic.cleardefinition.com
#
# Copyright Iowa State University 2009-2010.
# Copyright Collabora, Ltd. 2019.
# Copyright Collabora, Ltd. 2019, 2021.
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
@ -72,6 +72,7 @@ if(NOT HIDAPI_FIND_COMPONENTS)
endif()
# Ask pkg-config for hints
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
@ -84,6 +85,7 @@ if(PKG_CONFIG_FOUND)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
endif()
# Actually search
find_library(

View file

@ -1,11 +1,11 @@
# Copyright 2019 Collabora, Ltd.
# Copyright 2019, 2021 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Original Author:
# 2019 Ryan Pavlik <ryan.pavlik@collabora.com>
# 2019, 2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#.rst:
# FindCheck
@ -36,6 +36,7 @@ set(LIBCHECK_ROOT_DIR
"${LIBCHECK_ROOT_DIR}"
CACHE PATH "Root to search for libcheck")
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
@ -47,6 +48,8 @@ if(PKG_CONFIG_FOUND)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
endif()
find_path(
LIBCHECK_INCLUDE_DIR
NAMES check.h

View file

@ -14,11 +14,11 @@
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
# 2009-2010, 2021 Ryan Pavlik <ryanpavlik@gmail.com> <abiryan@ryand.net>
#
# Copyright Iowa State University 2009-2010.
# Copyright Collabora, Ltd 2021.
#
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
@ -47,9 +47,11 @@ if(WIN32)
endif()
else()
set(_lib_suffixes)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUSB1 libusb-1.0)
pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0)
endif()
endif()
endif()

View file

@ -1,11 +1,11 @@
# Copyright 2020 Collabora, Ltd.
# Copyright 2020-2021 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Original Author:
# 2020 Ryan Pavlik <ryan.pavlik@collabora.com>
# 2020-2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#[[.rst:
FindOpenGLES
@ -53,6 +53,8 @@ set(OpenGLES_ROOT_DIR
if(NOT OpenGLES_FIND_COMPONENTS)
set(OpenGLES_FIND_COMPONENTS V2)
endif()
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
@ -65,6 +67,8 @@ if(PKG_CONFIG_FOUND)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
endif()
find_path(
OpenGLES_V1_INCLUDE_DIR
NAMES GLES/gl.h

View file

@ -1,11 +1,11 @@
# Copyright 2019 Collabora, Ltd.
# Copyright 2019, 2021 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Original Author:
# 2019 Ryan Pavlik <ryan.pavlik@collabora.com>
# 2019, 2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#.rst:
# FindOpenHMD
@ -34,6 +34,7 @@ set(OPENHMD_ROOT_DIR
"${OPENHMD_ROOT_DIR}"
CACHE PATH "Root to search for OpenHMD")
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
@ -45,6 +46,7 @@ if(PKG_CONFIG_FOUND)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif()
endif()
find_path(
OPENHMD_INCLUDE_DIR

View file

@ -15,7 +15,7 @@
#
#=============================================================================
# Copyright (c) 2015 Jari Vetoniemi
# Copyright (c) 2020 Collabora, Ltd.
# Copyright (c) 2020-2021 Collabora, Ltd.
#
# Distributed under the OSI-approved BSD License (the "License");
#
@ -31,8 +31,13 @@ set_package_properties(
URL "http://freedesktop.org/wiki/Software/systemd/"
DESCRIPTION "System and Service Manager")
find_package(PkgConfig)
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_SYSTEMD QUIET libsystemd)
endif()
endif()
find_library(
SYSTEMD_LIBRARY
NAMES systemd

View file

@ -13,8 +13,13 @@
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# Copyright 2014 Kevin M. Godby <kevin@godby.org>
# Original Authors:
# 2014 Kevin M. Godby <kevin@godby.org>
# 2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#
# Copyright 2014, Kevin M. Godby <kevin@godby.org>
# Copyright 2021, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Distributed under the Boost Software License, Version 1.0.
@ -27,9 +32,11 @@ set(UDEV_ROOT_DIR
PATH
"Directory to search for udev")
if(NOT ANDROID)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBUDEV libudev)
pkg_check_modules(PC_LIBUDEV QUIET libudev)
endif()
endif()
find_library(UDEV_LIBRARY