From ef15984dca3f67d78eb6026970537442d7450830 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Mon, 19 Aug 2013 22:34:47 -0700 Subject: cmake: Refactor option validation Move validation of options into a new module WaffleValidateOptions. This change belongs to a series that cleans up the toplevel CMakeLists by decompositing it into modules. Signed-off-by: Chad Versace --- CMakeLists.txt | 51 +----------------------- cmake/Modules/WaffleValidateOptions.cmake | 65 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 cmake/Modules/WaffleValidateOptions.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d4892d3..4d94054 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,62 +34,13 @@ cmake_minimum_required(VERSION 2.8) include(Options.cmake) include(WaffleDefineInternalOptions) +include(WaffleValidateOptions) include(WaffleDefineVersion) include(WaffleDefineCompilerFlags) include(GNUInstallDirs) find_package(PkgConfig) -# ---------------------------------------------- -# Emit errors for removed options -# ---------------------------------------------- - -if(DEFINED waffle_install_includedir) - message(FATAL_ERROR "Option waffle_install_includedir has been " - "replaced by CMAKE_INSTALL_INCLUDEDIR. You may need to edit the " - "CMakeCache to delete the option. See /doc/building.txt for " - "details.") -endif() - -if(DEFINED waffle_install_libdir) - message(FATAL_ERROR "Option waffle_install_libdir has been " - "replaced by CMAKE_INSTALL_LIBDIR. You may need to edit the " - "CMakeCache to delete the option. See /doc/building.txt for " - "details.") -endif() - -if(DEFINED waffle_install_docdir) - message(FATAL_ERROR "Option waffle_install_docdir has been " - "replaced by CMAKE_INSTALL_DOCDIR. You may need to edit the " - "CMakeCache to delete the option. See /doc/building.txt for " - "details.") -endif() - -# ---------------------------------------------- -# Validate waffle options -# ---------------------------------------------- - -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - if(NOT waffle_has_glx AND NOT waffle_has_wayland AND - NOT waffle_has_x11_egl AND NOT waffle_has_gbm) - message(FATAL_ERROR - "Must enable at least one of: " - "waffle_has_glx, waffle_has_wayland, " - "waffle_has_x11_egl, waffle_has_gbm.") - endif() -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") - if(waffle_has_glx) - message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_glx.") - endif() - if(waffle_has_wayland) - message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_wayland.") - endif() - if(waffle_has_x11_egl) - message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_x11_egl.") - endif() -endif() - - # ------------------------------------------------------------------------------ # Find Libraries # ------------------------------------------------------------------------------ diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake new file mode 100644 index 0000000..798d9c9 --- /dev/null +++ b/cmake/Modules/WaffleValidateOptions.cmake @@ -0,0 +1,65 @@ +# Copyright 2013 Intel Corporation +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# - Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +if(DEFINED waffle_install_includedir) + message(FATAL_ERROR "Option waffle_install_includedir has been " + "replaced by CMAKE_INSTALL_INCLUDEDIR. You may need to edit the " + "CMakeCache to delete the option. See /doc/building.txt for " + "details.") +endif() + +if(DEFINED waffle_install_libdir) + message(FATAL_ERROR "Option waffle_install_libdir has been " + "replaced by CMAKE_INSTALL_LIBDIR. You may need to edit the " + "CMakeCache to delete the option. See /doc/building.txt for " + "details.") +endif() + +if(DEFINED waffle_install_docdir) + message(FATAL_ERROR "Option waffle_install_docdir has been " + "replaced by CMAKE_INSTALL_DOCDIR. You may need to edit the " + "CMakeCache to delete the option. See /doc/building.txt for " + "details.") +endif() + +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + if(NOT waffle_has_glx AND NOT waffle_has_wayland AND + NOT waffle_has_x11_egl AND NOT waffle_has_gbm) + message(FATAL_ERROR + "Must enable at least one of: " + "waffle_has_glx, waffle_has_wayland, " + "waffle_has_x11_egl, waffle_has_gbm.") + endif() +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + if(waffle_has_glx) + message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_glx.") + endif() + if(waffle_has_wayland) + message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_wayland.") + endif() + if(waffle_has_x11_egl) + message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_x11_egl.") + endif() +endif() -- cgit v1.2.3