[Piglit] [PATCH] cmake: On Android, use find_package to find Waffle

Chad Versace chad.versace at linux.intel.com
Tue Nov 20 11:20:43 PST 2012


Android lacks pkg-config, so we must fallback to the FindWaffle.cmake
module.

Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
[chadv: Use find_packge only on Android. Continue to use pkg_check_module on Linux.]
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---



Adrian,

Linux users are sure to be upset if you take away pkg-config. I've modified
your patch so that find_package() is used only on Android, and pkg-config
remains in use on Linux. What do you think?




 CMakeLists.txt            | 19 ++++++++++++++++---
 tests/util/CMakeLists.txt |  2 +-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f4c213..35203a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,21 @@ else()
 endif()
 
 if(PIGLIT_USE_WAFFLE)
-	pkg_check_modules(WAFFLE REQUIRED waffle-1>=1.1.0)
+	if(PIGLIT_HAS_ANDROID)
+		find_package(Waffle 1.1.0 REQUIRED)
+	else()
+		pkg_check_modules(WAFFLE REQUIRED waffle-1>=1.1.0)
+
+		# Override WAFFLE_LIBRARIES in order to provide compatibility
+		# with find_package().
+		#
+		# pkg_check_modules() defines XXX_LIBRARIES as a list of paths
+		# *relative* to the package's libdir.  But find_package()
+		# defines XXX_LIBRARIES as a list of *absolute* paths.  By
+		# overriding WAFFLE_LIBRARIES=WAFFLE_LDFLAGS, we get behavior
+		# that is compatible with find_package().
+		set(WAFFLE_LIBRARIES ${WAFFLE_LDFLAGS})
+	endif()
 
 	if(NOT WAFFLE_FOUND)
 		message(FATAL_ERROR "Failed to find Waffle. If Waffle is not "
@@ -44,8 +58,7 @@ if(PIGLIT_USE_WAFFLE)
         endif()
 
         add_definitions(-DPIGLIT_USE_WAFFLE)
-	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WAFFLE_CFLAGS}")
-	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WAFFLE_CFLAGS}")
+	include_directories(${WAFFLE_INCLUDE_DIRS})
 endif(PIGLIT_USE_WAFFLE)
 
 if(PIGLIT_BUILD_GLES1_TESTS AND NOT PIGLIT_USE_WAFFLE)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index a4784b1..8a145c6 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -48,7 +48,7 @@ endif()
 
 set(UTIL_GL_LIBS
 	piglitutil
-        ${WAFFLE_LDFLAGS}
+	${WAFFLE_LIBRARIES}
 	)
 
 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-- 
1.7.11.7



More information about the Piglit mailing list