From a5e59578725c79cd8f46e261a910223b1d36a738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Tue, 4 Mar 2014 16:51:08 +0100 Subject: Check versions for individual components First part of the diff makes sure find_package_handle_standard_args() gets a version number to check against. Second part ensures we get proper results from pkg-config even if not all components are available. find_package(Wayland COMPONENTS Client Egl) was failing for me because I have Client installed but not Egl, causing pkg_check_modules() to not set any PKG_Wayland_${comp} variable. REVIEW: 116598 --- find-modules/FindWayland.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'find-modules/FindWayland.cmake') diff --git a/find-modules/FindWayland.cmake b/find-modules/FindWayland.cmake index 21014fc4..a121de9f 100644 --- a/find-modules/FindWayland.cmake +++ b/find-modules/FindWayland.cmake @@ -128,6 +128,7 @@ macro(_wayland_handle_component _comp) set(Wayland_VERSION_STRING ${Wayland_${_comp}_VERSION_STRING}) endif() + set(Wayland_${_comp}_FIND_VERSION "${Wayland_FIND_VERSION}") find_package_handle_standard_args(Wayland_${_comp} FOUND_VAR Wayland_${_comp}_FOUND @@ -158,7 +159,13 @@ if(NOT WIN32) # Use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) - pkg_check_modules(PKG_Wayland QUIET ${pkgConfigModules}) + # Invoke pkg_check_modules() in a loop because if we call it like this: + # pkg_check_modules(PKG_Wayland QUIET ${pkgConfigModules}) + # and one of the components cannot be found, then it won't set any variable + # at all. + foreach(comp ${pkgConfigModules}) + pkg_check_modules(PKG_Wayland_${comp} QUIET ${comp}) + endforeach() set(Wayland_DEFINITIONS ${PKG_Wayland_CFLAGS_OTHER}) -- cgit v1.2.1