From 2c6d2dd1e30ebdec7888dfdc88b5e65880068fe1 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Tue, 17 Jan 2017 21:34:18 +0100 Subject: [PATCH] cmake: Find programs on the host too when building for Android --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 404f704734..f2bf209acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,6 +111,12 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") add_definitions(-D_FILE_OFFSET_BITS=64) endif() +if(CMAKE_SYSROOT) + # If we should use a sysroot, tell pkg-config to search for packages in there, not on the host + set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig") + set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}") +endif() + # Set where the binary files will be built. The program will not execute from # here. You must run "make install" to install these to the proper location # as defined above. @@ -439,7 +445,7 @@ if(ANDROID) # We are cross compiling, search only the toolchain for libraries and includes SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) elseif(NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES OpenBSD) list(APPEND LIBS rt)