[Piglit] [Patch v2] cmake: Use waffle PackageConfig instead of pkg-find.

Dylan Baker baker.dylan.c at gmail.com
Fri Jan 30 13:14:26 PST 2015


From: Dylan Baker <dylanx.c.baker at intel.com>

This patch changes the behavior find_pkg for waffle to use a config file
pkg-config.

Config files are like pkgconfig files, but instead of being a linux
specific solution they are a cmake specific solution. This allows a
single solution to work on OSX, Windows, and *nix; which removes the
need the need for a lot of OS specific logic.

This has one additional advantage, pkg-cfg caches it's value, which
means the cache must be cleared to if the waffle requirement is updated,
while a PackageConfig value will not be cached.

v2: - rebase to master
    - replace Waffle_LDFLAGS with Waffle_LIBRARIES (pkg-config ->
      cmake-config change)

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com> (v1)
---

This was originally part of a 4 patch series, versions of patches 1-3
have landed already or been rejected. This particular patch requires a
newer version of waffle (to get the config files). The required version
1.5.1 was released on 2015/01/22, and is available at least through
Gentoo and Debian, for those using distro packaged versions.

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b7874cf..d1233fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,42 +42,7 @@ else()
 endif()
 
 if(PIGLIT_USE_WAFFLE)
-	if (NOT WIN32)
-		pkg_check_modules(Waffle REQUIRED waffle-1)
-
-		if(NOT Waffle_FOUND)
-			message(FATAL_ERROR "Failed to find Waffle. If Waffle"
-			"is not packaged for your distribution, you can get "
-			"it at http://www.waffle-gl.org."
-		)
-		endif()
-
-		# Check the installed waffle version.
-		#
-		# We cannot reliably check the version with pkg_check_modules(), but
-		# instead must check the version manually as below. The problem is that,
-		# if one passes a required version to pkg_check_modules(), CMake
-		# validates the required version at most once for the lifetime of the
-		# source tree.  If someone changes the required version by editing the
-		# CMakeLists, CMake fails to detect the new requirement.
-		set(Waffle_REQUIRED_VERSION "1.5.0")
-		if(Waffle_VERSION VERSION_LESS Waffle_REQUIRED_VERSION)
-			message(FATAL_ERROR "Found waffle-${Waffle_VERSION}, but "
-			"piglit requires waffle-${Waffle_REQUIRED_VERSION}")
-		endif()
-	else ()
-		find_path(Waffle_INCLUDE_DIRS waffle.h)
-		find_library(Waffle_LDFLAGS waffle-1)
-		if(Waffle_INCLUDE_DIRS AND Waffle_LDFLAGS)
-			set(Waffle_FOUND TRUE)
-		else()
-			message(FATAL_ERROR "Failed to find Waffle. Get and build Waffle from "
-				"http://www.waffle-gl.org and set Waffle_INCLUDE_DIRS and "
-				"Waffle_LDFLAGS variables accordingly."
-			)
-		endif()
-	endif ()
-
+	find_package(Waffle 1.5.0 CONFIG REQUIRED)
 	add_definitions(-DPIGLIT_USE_WAFFLE)
 	add_definitions(-DWAFFLE_API_VERSION=0x0103)
 else()
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 45fd25f..4c1bad7 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -86,7 +86,7 @@ if(PIGLIT_USE_WAFFLE)
 	endif()
 
 	list(APPEND UTIL_GL_LIBS
-		${Waffle_LDFLAGS}
+		${Waffle_LIBRARIES}
 	)
 	IF(PIGLIT_BUILD_GLX_TESTS)
 		list(APPEND UTIL_GL_LIBS
-- 
2.2.2



More information about the Piglit mailing list