[Piglit] [PATCH 1/9] cmake: Fix waffle version requirement

Chad Versace chad.versace at linux.intel.com
Mon Dec 30 16:08:28 PST 2013


CMake is so stupid sometimes :(

When building with waffle, piglit requires waffle >= 1.2.2. Piglit's
CMake captures the required by calling

    pkg_check_modules(WAFFLE REQUIRED waffle-1>=1.2.2)

However, we cannot reliably check the version with pkg_check_modules(). 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.

To workaround this deficiency of CMake, check the version instead with

    if(WAFFLE_VERSION VERSION_LESS 1.2.2)

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 CMakeLists.txt | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e952e24..7418ac3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,7 @@ else()
 endif()
 
 if(PIGLIT_USE_WAFFLE)
-	pkg_check_modules(WAFFLE REQUIRED waffle-1>=1.2.2)
+	pkg_check_modules(WAFFLE REQUIRED waffle-1)
 
 	if(NOT WAFFLE_FOUND)
 		message(FATAL_ERROR "Failed to find Waffle. If Waffle is not "
@@ -42,6 +42,20 @@ if(PIGLIT_USE_WAFFLE)
 	)
         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.2.2")
+	if(WAFFLE_VERSION VERSION_LESS WAFFLE_REQUIRED_VERSION)
+		message(FATAL_ERROR "Found waffle-${WAFFLE_VERSION}, but "
+		"piglit requires waffle-${WAFFLE_REQUIRED_VERSION}")
+        endif()
+
 	add_definitions(-DPIGLIT_USE_WAFFLE)
 	add_definitions(-DPIGLIT_HAS_WAYLAND)
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WAFFLE_CFLAGS}")
-- 
1.8.4



More information about the Piglit mailing list