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

Jose Fonseca jfonseca at vmware.com
Tue Feb 3 13:13:32 PST 2015


Dylan,


When the original commit went in, I also noticed one further issue (but 
after the change was reverted I forgot to write it up):


Waffle sets two variables Waffle_LIBRARY_DIRS and Waffle_LIBRARIES.

But with this change, piglit uses Waffle_LIBRARIES from Waffle, and 
never uses Waffle_LIBRARY_DIRS, so if Waffle is installed into a non 
standard place, piglit fails to build with "ld: cannot find -lwaffle-1"

(I hit this on my build slaves because I don't install waffle into /usr 
or /usr/local.)

But worst thing is, I'm not sure this can be cleanly fixes from piglit 
side.

We could add

   link_directories(${Waffle_LIBRARY_DIRS})

But per 
http://www.cmake.org/cmake/help/v3.0/command/link_directories.html I 
think the right fix would be to fix Waffle to export full paths in 
Waffle_LIBRARIES, and kill Waffle_LIBRARY_DIRS.  I believe this is the 
right way -- and cmake will emit the -L option automatically...


Jose

On 30/01/15 21:14, Dylan Baker wrote:
> 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
>



More information about the Piglit mailing list