[waffle] [PATCH 04/10] cmake: add autodetection for waffle_has_egl, glx...
Emil Velikov
emil.l.velikov at gmail.com
Fri May 30 19:22:02 PDT 2014
Silence the pkg_check_modules and check set the default
options depending on the packages found.
Error out if the user has selected an option and it's
requirements are not met.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
CMakeLists.txt | 2 +-
Options.cmake | 29 +++++++++++++++++++++++++----
cmake/Modules/WaffleFindDependencies.cmake | 30 ++++++++++++++----------------
cmake/Modules/WaffleValidateOptions.cmake | 21 +++++++++++++++++++++
4 files changed, 61 insertions(+), 21 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b32b3d1..cf19929 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,12 +30,12 @@ cmake_minimum_required(VERSION 2.8)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
include(WaffleDefineOS)
+include(WaffleFindDependencies)
include(Options.cmake)
include(WaffleDefineInternalOptions)
include(WaffleValidateOptions)
include(WaffleDefineVersion)
include(WaffleDefineCompilerFlags)
-include(WaffleFindDependencies)
include(GNUInstallDirs)
if(waffle_build_tests)
diff --git a/Options.cmake b/Options.cmake
index 7f694e3..3a36a5d 100644
--- a/Options.cmake
+++ b/Options.cmake
@@ -1,9 +1,30 @@
+set(glx_default OFF)
+set(wayland_default OFF)
+set(x11_egl_default OFF)
+set(gbm_default OFF)
+
if(waffle_on_linux)
+ if(gl_FOUND AND x11-xcb_FOUND)
+ set(glx_default ON)
+ endif()
+
+ if(wayland-client_FOUND AND wayland-egl_FOUND AND egl_FOUND)
+ set(wayland_default ON)
+ endif()
+
+ if(x11-xcb_FOUND AND egl_FOUND)
+ set(x11_egl_default ON)
+ endif()
+
+ if(gbm_FOUND AND libudev_FOUND AND egl_FOUND)
+ set(gbm_default ON)
+ endif()
+
# On Linux, you must enable at least one of the below options.
- option(waffle_has_glx "Build support for GLX" OFF)
- option(waffle_has_wayland "Build support for Wayland" OFF)
- option(waffle_has_x11_egl "Build support for X11/EGL" OFF)
- option(waffle_has_gbm "Build support for GBM" OFF)
+ option(waffle_has_glx "Build support for GLX" ${glx_default})
+ option(waffle_has_wayland "Build support for Wayland" ${wayland_default})
+ option(waffle_has_x11_egl "Build support for X11/EGL" ${x11_egl_default})
+ option(waffle_has_gbm "Build support for GBM" ${gbm_default})
endif()
option(waffle_build_tests "Build tests" ON)
diff --git a/cmake/Modules/WaffleFindDependencies.cmake b/cmake/Modules/WaffleFindDependencies.cmake
index 527e01f..42725ec 100644
--- a/cmake/Modules/WaffleFindDependencies.cmake
+++ b/cmake/Modules/WaffleFindDependencies.cmake
@@ -61,24 +61,22 @@ if(waffle_on_mac)
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
endif()
-if(waffle_has_egl)
- waffle_pkg_config(egl REQUIRED egl)
-endif()
-if(waffle_has_glx)
- waffle_pkg_config(gl REQUIRED gl)
-endif()
+if(waffle_on_linux)
+ # waffle_has_egl
+ waffle_pkg_config(egl QUIET egl)
-if(waffle_has_wayland)
- waffle_pkg_config(wayland-client REQUIRED wayland-client>=1)
- waffle_pkg_config(wayland-egl REQUIRED wayland-egl>=9.1)
-endif()
+ # waffle_has_glx
+ waffle_pkg_config(gl QUIET gl)
-if(waffle_has_x11)
- waffle_pkg_config(x11-xcb REQUIRED x11-xcb)
-endif()
+ # waffle_has_wayland
+ waffle_pkg_config(wayland-client QUIET wayland-client>=1)
+ waffle_pkg_config(wayland-egl QUIET wayland-egl>=9.1)
+
+ # waffle_has_x11
+ waffle_pkg_config(x11-xcb QUIET x11-xcb)
-if(waffle_has_gbm)
- waffle_pkg_config(gbm REQUIRED gbm)
- waffle_pkg_config(libudev REQUIRED libudev)
+ # waffle_has_gbm
+ waffle_pkg_config(gbm QUIET gbm)
+ waffle_pkg_config(libudev QUIET libudev)
endif()
diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake
index 03eb4ba..f87f5b1 100644
--- a/cmake/Modules/WaffleValidateOptions.cmake
+++ b/cmake/Modules/WaffleValidateOptions.cmake
@@ -52,6 +52,27 @@ if(waffle_on_linux)
"waffle_has_glx, waffle_has_wayland, "
"waffle_has_x11_egl, waffle_has_gbm.")
endif()
+ if(waffle_has_gbm)
+ if(NOT gbm_FOUND OR NOT libudev_FOUND OR NOT egl_FOUND)
+ message(FATAL_ERROR "gbm requirements are not met.")
+ endif()
+ endif()
+ if(waffle_has_glx)
+ if(NOT gl_FOUND OR NOT x11-xcb_FOUND)
+ message(FATAL_ERROR "glx requirements are not met.")
+ endif()
+ endif()
+ if(waffle_has_wayland)
+ if(NOT wayland-client_FOUND OR
+ NOT wayland-egl_FOUND OR NOT egl_FOUND)
+ message(FATAL_ERROR "wayland requirements are not met.")
+ endif()
+ endif()
+ if(waffle_has_x11_egl)
+ if(NOT x11-xcb_FOUND OR NOT egl_FOUND)
+ message(FATAL_ERROR "x11_egl requirements are not met.")
+ endif()
+ endif()
elseif(waffle_on_mac)
if(waffle_has_gbm)
message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_gbm.")
--
1.9.3
More information about the waffle
mailing list