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 Alex Merry <alex.merry@kde.org>
# Copyright 2014 Martin Gräßlin <mgraesslin@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 # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # 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 # Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls # in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig) if(NOT ANDROID)
pkg_check_modules(PKG_EGL QUIET egl) find_package(PkgConfig QUIET)
if(PKGCONFIG_FOUND)
pkg_check_modules(PKG_EGL QUIET egl)
endif()
endif()
set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER}) set(EGL_DEFINITIONS ${PKG_EGL_CFLAGS_OTHER})

View file

@ -40,11 +40,11 @@
# ``HIDAPI_LIBRARIES`` # ``HIDAPI_LIBRARIES``
# #
# Original Author: # 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 # http://academic.cleardefinition.com
# #
# Copyright Iowa State University 2009-2010. # Copyright Iowa State University 2009-2010.
# Copyright Collabora, Ltd. 2019. # Copyright Collabora, Ltd. 2019, 2021.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
@ -72,17 +72,19 @@ if(NOT HIDAPI_FIND_COMPONENTS)
endif() endif()
# Ask pkg-config for hints # Ask pkg-config for hints
find_package(PkgConfig QUIET) if(NOT ANDROID)
if(PKG_CONFIG_FOUND) find_package(PkgConfig QUIET)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}") if(PKG_CONFIG_FOUND)
# So pkg-config uses HIDAPI_ROOT_DIR too. set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
if(HIDAPI_ROOT_DIR) # So pkg-config uses HIDAPI_ROOT_DIR too.
list(APPEND CMAKE_PREFIX_PATH ${HIDAPI_ROOT_DIR}) if(HIDAPI_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${HIDAPI_ROOT_DIR})
endif()
pkg_check_modules(PC_HIDAPI_LIBUSB QUIET hidapi-libusb)
pkg_check_modules(PC_HIDAPI_HIDRAW QUIET hidapi-hidraw)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
pkg_check_modules(PC_HIDAPI_LIBUSB QUIET hidapi-libusb)
pkg_check_modules(PC_HIDAPI_HIDRAW QUIET hidapi-hidraw)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
# Actually search # Actually search

View file

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

View file

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

View file

@ -1,11 +1,11 @@
# Copyright 2020 Collabora, Ltd. # Copyright 2020-2021 Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0 # SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
# #
# Original Author: # Original Author:
# 2020 Ryan Pavlik <ryan.pavlik@collabora.com> # 2020-2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#[[.rst: #[[.rst:
FindOpenGLES FindOpenGLES
@ -53,18 +53,22 @@ set(OpenGLES_ROOT_DIR
if(NOT OpenGLES_FIND_COMPONENTS) if(NOT OpenGLES_FIND_COMPONENTS)
set(OpenGLES_FIND_COMPONENTS V2) set(OpenGLES_FIND_COMPONENTS V2)
endif() endif()
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND) if(NOT ANDROID)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}") find_package(PkgConfig QUIET)
# So pkg-config uses OpenGLES_ROOT_DIR too. if(PKG_CONFIG_FOUND)
if(OpenGLES_ROOT_DIR) set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_PREFIX_PATH ${OpenGLES_ROOT_DIR}) # So pkg-config uses OpenGLES_ROOT_DIR too.
if(OpenGLES_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${OpenGLES_ROOT_DIR})
endif()
pkg_check_modules(PC_glesv1_cm QUIET glesv1_cm)
pkg_check_modules(PC_glesv2 QUIET glesv2)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
pkg_check_modules(PC_glesv1_cm QUIET glesv1_cm)
pkg_check_modules(PC_glesv2 QUIET glesv2)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
find_path( find_path(
OpenGLES_V1_INCLUDE_DIR OpenGLES_V1_INCLUDE_DIR
NAMES GLES/gl.h 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 # SPDX-License-Identifier: BSL-1.0
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at # (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt) # http://www.boost.org/LICENSE_1_0.txt)
# #
# Original Author: # Original Author:
# 2019 Ryan Pavlik <ryan.pavlik@collabora.com> # 2019, 2021 Ryan Pavlik <ryan.pavlik@collabora.com>
#.rst: #.rst:
# FindOpenHMD # FindOpenHMD
@ -34,16 +34,18 @@ set(OPENHMD_ROOT_DIR
"${OPENHMD_ROOT_DIR}" "${OPENHMD_ROOT_DIR}"
CACHE PATH "Root to search for OpenHMD") CACHE PATH "Root to search for OpenHMD")
find_package(PkgConfig QUIET) if(NOT ANDROID)
if(PKG_CONFIG_FOUND) find_package(PkgConfig QUIET)
set(_old_prefix_path "${CMAKE_PREFIX_PATH}") if(PKG_CONFIG_FOUND)
# So pkg-config uses OPENHMD_ROOT_DIR too. set(_old_prefix_path "${CMAKE_PREFIX_PATH}")
if(OPENHMD_ROOT_DIR) # So pkg-config uses OPENHMD_ROOT_DIR too.
list(APPEND CMAKE_PREFIX_PATH ${OPENHMD_ROOT_DIR}) if(OPENHMD_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH ${OPENHMD_ROOT_DIR})
endif()
pkg_check_modules(PC_OPENHMD QUIET openhmd)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
pkg_check_modules(PC_OPENHMD QUIET openhmd)
# Restore
set(CMAKE_PREFIX_PATH "${_old_prefix_path}")
endif() endif()
find_path( find_path(

View file

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

View file

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