summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2013-08-19 23:50:15 -0700
committerChad Versace <chad.versace@linux.intel.com>2013-08-19 23:50:15 -0700
commit877f856fa9b96defae18e5479f8ddad0c4983324 (patch)
tree8049902c45b72ef6c181e9085dcb8be6d4b4179d
parenteebc0fd464ebebc2dbfbd3db8f57c6ee8df28ce9 (diff)
parent2b9748a7f552a56f4042b017d3bfcfe9e61c7de4 (diff)
Merge branch chadv/cmake-cleanup
-rw-r--r--CMakeLists.txt338
-rw-r--r--Options.cmake15
-rw-r--r--README.txt8
-rw-r--r--cmake/CMakeLists.txt2
-rw-r--r--cmake/Modules/WaffleCheckThreadLocalStorage.cmake (renamed from cmake/Modules/CheckThreadLocalStorage.cmake)6
-rw-r--r--cmake/Modules/WaffleDefineCompilerFlags.cmake71
-rw-r--r--cmake/Modules/WaffleDefineInternalOptions.cmake11
-rw-r--r--cmake/Modules/WaffleDefineOS.cmake32
-rw-r--r--cmake/Modules/WaffleDefineVersion.cmake53
-rw-r--r--cmake/Modules/WaffleFindDependencies.cmake54
-rw-r--r--cmake/Modules/WafflePrintConfigurationSummary.cmake90
-rw-r--r--cmake/Modules/WaffleValidateOptions.cmake68
-rw-r--r--doc/building.txt146
-rw-r--r--examples/CMakeLists.txt4
-rw-r--r--src/waffle/CMakeLists.txt4
-rw-r--r--tests/CMakeLists.txt19
-rw-r--r--tests/functional/CMakeLists.txt2
17 files changed, 439 insertions, 484 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cfbcdb0..a6695fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,240 +23,23 @@
# 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.
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
-project(waffle C)
-cmake_minimum_required(VERSION 2.8)
-
-# -----------------------------------------------------------------------------
-# Version Numbers
-# -----------------------------------------------------------------------------
-
-# See /doc/versioning-rules.txt.
-
-#
-# Release versions.
-#
-# !!! Must be updated in tandem with the Android.mk !!!
-#
-set(waffle_major_version "1")
-set(waffle_minor_version "2")
-set(waffle_patch_version "75")
+project(waffle1 C)
-set(waffle_version "${waffle_major_version}.${waffle_minor_version}.${waffle_patch_version}")
-
-
-#
-# Library versions.
-#
-# On Linux, libwaffle's filename is:
-# libwaffle-MAJOR.so.0.MINOR.PATCH
-#
-set(waffle_libname "waffle-${waffle_major_version}")
-set(waffle_soversion "0")
-
-# ------------------------------------------------------------------------------
-# Includes
-# ------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 2.8)
-include(CheckThreadLocalStorage)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
-#
-# Include GNUInstallDirs.
-#
-# Hackishly rename PROJECT_NAME temporarily in order to workaround the default
-# of CMAKE_INSTALL_DOCDIR. The default value is "DATAROOTDIR/doc/PROJECT_NAME",
-# which evaluates to the undesirable "DATAROOTDIR/doc/waffle". Instead, we
-# want to install to "DATAROOTDIR/doc/waffle-MAJOR_VERSION".
-#
-set(PROJECT_NAME "waffle-${waffle_major_version}")
+include(WaffleDefineOS)
+include(Options.cmake)
+include(WaffleDefineInternalOptions)
+include(WaffleValidateOptions)
+include(WaffleDefineVersion)
+include(WaffleDefineCompilerFlags)
+include(WaffleFindDependencies)
include(GNUInstallDirs)
-set(PROJECT_NAME "waffle")
find_package(PkgConfig)
-
-# ------------------------------------------------------------------------------
-# Waffle Options
-# ------------------------------------------------------------------------------
-
-# All options here are prefixed with `waffle_`. Most options are cache
-# variables set by the user.
-
-# ----------------------------------------------
-# Set waffle options
-# ----------------------------------------------
-
-option(waffle_build_tests "Build tests" ON)
-
-# Most users don't have the necessary tools installed to build from
-# Docbook sources, so require users to explicitly enable building them.
-option(waffle_build_manpages "Build manpages" OFF)
-option(waffle_build_htmldoc "Build html documentation" OFF)
-
-option(waffle_build_examples "Build examples" ON)
-
-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)
-
-set(waffle_xsltproc "xsltproc"
- CACHE STRING "Tool used to process XSLT stylesheets")
-
-# ----------------------------------------------
-# 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()
-
-#
-# Set internal options.
-#
-
-# Set the following:
-# waffle_has_tls
-# waffle_tls_model_initial_exec
-check_thread_local_storage()
-
-if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
- set(waffle_has_egl TRUE)
-else(waffle_has_wayland OR waffle_has_x11_egl)
- set(waffle_has_egl FALSE)
-endif()
-
-if(waffle_has_glx OR waffle_has_x11_egl)
- set(waffle_has_x11 TRUE)
-else()
- set(waffle_has_x11 FALSE)
-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
-# ------------------------------------------------------------------------------
-
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- find_package(OpenGL REQUIRED)
- find_library(COCOA_FRAMEWORK Cocoa REQUIRED)
- find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
-endif()
-
-if(waffle_has_egl)
- pkg_check_modules(egl REQUIRED egl)
-endif()
-
-if(waffle_has_glx)
- pkg_check_modules(gl REQUIRED gl)
-endif()
-
-if(waffle_has_wayland)
- pkg_check_modules(wayland-client REQUIRED wayland-client>=1)
- pkg_check_modules(wayland-egl REQUIRED wayland-egl>=9.1)
-endif()
-
-if(waffle_has_x11)
- pkg_check_modules(x11-xcb REQUIRED x11-xcb)
-endif()
-
-if(waffle_has_gbm)
- pkg_check_modules(gbm REQUIRED gbm)
- pkg_check_modules(libudev REQUIRED libudev)
-endif()
-
-
-# ------------------------------------------------------------------------------
-# Compiler Flags
-# ------------------------------------------------------------------------------
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=c99 -Wall -Werror=implicit-function-declaration")
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
- # On MacOS, the SSE2 headers trigger this error.
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=missing-prototypes")
-endif()
-
-set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 -DDEBUG")
-
-# Produce enough debug info for generating backtraces, but not
-# single-stepping.
-set(CMAKE_C_FLAGS_RELEASE "-g1 -O2 -DNDEBUG")
-
-if(waffle_has_tls)
- add_definitions(-DWAFFLE_HAS_TLS)
-endif()
-
-if(waffle_has_tls_model_initial_exec)
- add_definitions(-DWAFFLE_HAS_TLS_MODEL_INITIAL_EXEC)
-endif()
-
-#
-# Define macros WAFFLE_HAS_{PLATFORM}.
-#
-# Android is not in this list because it uses a separate build system.
-#
-
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- add_definitions(-DWAFFLE_HAS_CGL)
-endif()
-
-if(waffle_has_glx)
- add_definitions(-DWAFFLE_HAS_GLX)
-endif()
-
-if(waffle_has_wayland)
- add_definitions(-DWAFFLE_HAS_WAYLAND)
-endif()
-
-if(waffle_has_x11_egl)
- add_definitions(-DWAFFLE_HAS_X11_EGL)
-endif()
-
-if(waffle_has_gbm)
- add_definitions(-DWAFFLE_HAS_GBM)
-endif()
-
# ------------------------------------------------------------------------------
# Add subdirectories
# ------------------------------------------------------------------------------
@@ -266,7 +49,6 @@ include_directories(
src
)
-add_subdirectory(cmake)
add_subdirectory(doc)
add_subdirectory(pkg)
add_subdirectory(src)
@@ -282,36 +64,7 @@ if(waffle_build_examples)
endif()
# ------------------------------------------------------------------------------
-# Target: check
-# ------------------------------------------------------------------------------
-
-# Run only unit tests.
-
-if(waffle_build_tests)
- add_custom_target(check
- DEPENDS waffle-unittest
- COMMAND ${CMAKE_BINARY_DIR}/tests/unittests/waffle-unittest
- )
-endif()
-
-# ------------------------------------------------------------------------------
-# Target: check-func
-# ------------------------------------------------------------------------------
-
-# Run functional and unit tests.
-#
-# The unit tests are ran first (due to the depenency on 'check'). If they
-# fail, then no subsequent tests are ran.
-
-if(waffle_build_tests)
- add_custom_target(check-func
- DEPENDS check gl_basic_test
- COMMAND ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
- )
-endif()
-
-# ------------------------------------------------------------------------------
-# Install: waffle.pc
+# Install packaging files: waffle.pc, FindWaffle.cmake
# ------------------------------------------------------------------------------
configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
@@ -319,70 +72,9 @@ configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${waffle_libname}.pc
DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig)
-# ------------------------------------------------------------------------------
-# Print summary
-# ------------------------------------------------------------------------------
+install(FILES cmake/Modules/FindWaffle.cmake
+ DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake/Modules")
-# CMake is annoyingly silent compared to autoconf. The user wants to know what
-# was configured how.
+# ------------------------------------------------------------------------------
-message("-----------------------------------------------")
-message("")
-message("Waffle configuration summary")
-message("")
-message("Supported platforms: ")
-if(waffle_has_glx)
- message(" glx")
-endif()
-if(waffle_has_wayland)
- message(" wayland")
-endif()
-if(waffle_has_x11_egl)
- message(" x11_egl")
-endif()
-if(waffle_has_gbm)
- message(" gbm")
-endif()
-message("")
-message("Dependencies:")
-if(waffle_has_egl)
- message(" egl_INCLUDE_DIRS: ${egl_INCLUDE_DIRS}")
- message(" egl_LDFLAGS: ${egl_LDFLAGS}")
-endif()
-if(waffle_has_glx)
- message(" gl_INCLUDE_DIRS: ${gl_INCLUDE_DIRS}")
- message(" gl_LDFLAGS: ${gl_LDFLAGS}")
-endif()
-if(waffle_has_wayland)
- message(" wayland-client_INCLUDE_DIRS: ${wayland-client_INCLUDE_DIRS}")
- message(" wayland-client_LDFLAGS: ${wayland-client_LDFLAGS}")
- message(" wayland-egl_INCLUDE_DIRS: ${wayland-egl_INCLUDE_DIRS}")
- message(" wayland-egl_LDFLAGS: ${wayland-egl_LDFLAGS}")
-endif()
-if(waffle_has_x11)
- message(" x11-xcb_INCLUDE_DIRS: ${x11-xcb_INCLUDE_DIRS}")
- message(" x11-xcb_LDFLAGS: ${x11-xcb_LDFLAGS}")
-endif()
-if(waffle_has_gbm)
- message(" gbm_INCLUDE_DIRS: ${gbm_INCLUDE_DIRS}")
- message(" gbm_LDFLAGS: ${gbm_LDFLAGS}")
-endif()
-message("")
-message("Build type:")
-message(" ${CMAKE_BUILD_TYPE}")
-message("")
-message("Tools:")
-message(" CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
-message(" CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
-message(" CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
-message(" CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
-if(waffle_build_manpages OR waffle_build_htmldocs)
-message(" xsltproc: ${waffle_xsltproc}")
-endif()
-message("")
-message("Install paths:")
-message(" CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
-message(" CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}")
-message(" CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
-message(" CMAKE_INSTALL_DOCDIR: ${CMAKE_INSTALL_DOCDIR}")
-message("-----------------------------------------------")
+include(WafflePrintConfigurationSummary)
diff --git a/Options.cmake b/Options.cmake
new file mode 100644
index 0000000..923505b
--- /dev/null
+++ b/Options.cmake
@@ -0,0 +1,15 @@
+if(waffle_on_linux)
+ # 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)
+endif()
+
+option(waffle_build_tests "Build tests" ON)
+option(waffle_build_manpages "Build manpages" OFF)
+option(waffle_build_htmldoc "Build html documentation" OFF)
+option(waffle_build_examples "Build example programs" ON)
+
+set(waffle_xsltproc "xsltproc"
+ CACHE STRING "Program for processing XSLT stylesheets. Used for building docs.")
diff --git a/README.txt b/README.txt
index 28904f3..97aeac3 100644
--- a/README.txt
+++ b/README.txt
@@ -121,9 +121,8 @@ a dependeny into /usr/local, then:
export PKG_CONFIG_PATH=/usr/local/share/pkgconfig:/usr/local/$libdir/pkgconfig:$PKG_CONFIG_PATH
-2. Configure Waffle with CMake
--------------------------------
-
+2. Configure CMake
+------------------
On Linux, you likely want to call cmake with the following
arguments. It configures Waffle in debug mode and with support for only GLX.
@@ -136,8 +135,7 @@ If in addition to GLX you want support for X11/EGL, then add
-Dwaffle_has_x11_egl=1 to the cmake arguments. Likewise for Wayland, add
-Dwaffle_has_wayland=1; and for GBM, add -Dwaffle_has_gbm=1.
-To build the manpages, add -Dwaffle_build_manpages=1. To build the html
-documentation, add -Dwaffle_build_htmldocs=1.
+For the full list of Waffle's custom CMake options, see file `Options.cmake`.
To install into a custom location, autoconf-esque variables such
as CMAKE_INSTALL_LIBDIR are supported. See
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
deleted file mode 100644
index 97befca..0000000
--- a/cmake/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-install(FILES Modules/FindWaffle.cmake
- DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake/Modules")
diff --git a/cmake/Modules/CheckThreadLocalStorage.cmake b/cmake/Modules/WaffleCheckThreadLocalStorage.cmake
index ad8cd85..c8bc3fe 100644
--- a/cmake/Modules/CheckThreadLocalStorage.cmake
+++ b/cmake/Modules/WaffleCheckThreadLocalStorage.cmake
@@ -28,8 +28,8 @@
# Check if the compiler supports various types of thread-local storage.
#
# Usage:
-# include(CheckThreadLocalStorage)
-# check_thread_local_storage()
+# include(WaffleCheckThreadLocalStorage)
+# waffle_check_thread_local_storage()
#
# Output Variables:
# waffle_has_tls
@@ -42,7 +42,7 @@
include(CheckCSourceCompiles)
-macro(check_thread_local_storage)
+macro(waffle_check_thread_local_storage)
# Clang, in its zeal for compatibility with gcc, emits only a warning if
# it encounters an __attribute__ that it does not recognize. To prevent
# this function from returning a false positive in that situation, force
diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake b/cmake/Modules/WaffleDefineCompilerFlags.cmake
new file mode 100644
index 0000000..0f4cdec
--- /dev/null
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -0,0 +1,71 @@
+# 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.
+
+include(WaffleCheckThreadLocalStorage)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=c99")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
+
+if(waffle_on_linux)
+ # On MacOS, the SSE2 headers trigger this error.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=missing-prototypes")
+endif()
+
+set(CMAKE_C_FLAGS_DEBUG "-g3 -O0 -DDEBUG")
+
+# Use '-g1' to produce enough debug info for generating backtraces, but not
+# enough for single-stepping.
+set(CMAKE_C_FLAGS_RELEASE "-g1 -O2 -DNDEBUG")
+
+waffle_check_thread_local_storage()
+
+if(waffle_has_tls)
+ add_definitions(-DWAFFLE_HAS_TLS)
+endif()
+
+if(waffle_has_tls_model_initial_exec)
+ add_definitions(-DWAFFLE_HAS_TLS_MODEL_INITIAL_EXEC)
+endif()
+
+if(waffle_on_mac)
+ add_definitions(-DWAFFLE_HAS_CGL)
+endif()
+
+if(waffle_has_glx)
+ add_definitions(-DWAFFLE_HAS_GLX)
+endif()
+
+if(waffle_has_wayland)
+ add_definitions(-DWAFFLE_HAS_WAYLAND)
+endif()
+
+if(waffle_has_x11_egl)
+ add_definitions(-DWAFFLE_HAS_X11_EGL)
+endif()
+
+if(waffle_has_gbm)
+ add_definitions(-DWAFFLE_HAS_GBM)
+endif()
diff --git a/cmake/Modules/WaffleDefineInternalOptions.cmake b/cmake/Modules/WaffleDefineInternalOptions.cmake
new file mode 100644
index 0000000..3ef7a25
--- /dev/null
+++ b/cmake/Modules/WaffleDefineInternalOptions.cmake
@@ -0,0 +1,11 @@
+if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
+ set(waffle_has_egl TRUE)
+else(waffle_has_wayland OR waffle_has_x11_egl)
+ set(waffle_has_egl FALSE)
+endif()
+
+if(waffle_has_glx OR waffle_has_x11_egl)
+ set(waffle_has_x11 TRUE)
+else()
+ set(waffle_has_x11 FALSE)
+endif()
diff --git a/cmake/Modules/WaffleDefineOS.cmake b/cmake/Modules/WaffleDefineOS.cmake
new file mode 100644
index 0000000..e437947
--- /dev/null
+++ b/cmake/Modules/WaffleDefineOS.cmake
@@ -0,0 +1,32 @@
+# 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("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ set(waffle_on_linux true)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+ set(waffle_on_mac true)
+else()
+ message(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME=\"${CMAKE_SYSTEM_NAME|\"")
+endif()
diff --git a/cmake/Modules/WaffleDefineVersion.cmake b/cmake/Modules/WaffleDefineVersion.cmake
new file mode 100644
index 0000000..c73810a
--- /dev/null
+++ b/cmake/Modules/WaffleDefineVersion.cmake
@@ -0,0 +1,53 @@
+# 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.
+
+#
+# Waffle's version scheme follows the rules [1] set by the Apache Portable
+# Runtime Project. The scheme allows multiple versions of a library and its
+# headers to be installed in parallel.
+#
+# [1] http://apr.apache.org/versioning.html
+#
+
+#
+# Release versions.
+#
+# !!! Must be updated in tandem with the Android.mk !!!
+#
+set(waffle_major_version "1")
+set(waffle_minor_version "2")
+set(waffle_patch_version "75")
+
+set(waffle_version "${waffle_major_version}.${waffle_minor_version}.${waffle_patch_version}")
+
+
+#
+# Library versions.
+#
+# On Linux, libwaffle's filename is:
+# libwaffle-MAJOR.so.0.MINOR.PATCH
+#
+set(waffle_libname "waffle-${waffle_major_version}")
+set(waffle_soversion "0")
diff --git a/cmake/Modules/WaffleFindDependencies.cmake b/cmake/Modules/WaffleFindDependencies.cmake
new file mode 100644
index 0000000..8fb9d2a
--- /dev/null
+++ b/cmake/Modules/WaffleFindDependencies.cmake
@@ -0,0 +1,54 @@
+# 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.
+
+find_package(PkgConfig)
+
+if(waffle_on_mac)
+ find_package(OpenGL REQUIRED)
+ find_library(COCOA_FRAMEWORK Cocoa REQUIRED)
+ find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
+endif()
+
+if(waffle_has_egl)
+ pkg_check_modules(egl REQUIRED egl)
+endif()
+
+if(waffle_has_glx)
+ pkg_check_modules(gl REQUIRED gl)
+endif()
+
+if(waffle_has_wayland)
+ pkg_check_modules(wayland-client REQUIRED wayland-client>=1)
+ pkg_check_modules(wayland-egl REQUIRED wayland-egl>=9.1)
+endif()
+
+if(waffle_has_x11)
+ pkg_check_modules(x11-xcb REQUIRED x11-xcb)
+endif()
+
+if(waffle_has_gbm)
+ pkg_check_modules(gbm REQUIRED gbm)
+ pkg_check_modules(libudev REQUIRED libudev)
+endif()
diff --git a/cmake/Modules/WafflePrintConfigurationSummary.cmake b/cmake/Modules/WafflePrintConfigurationSummary.cmake
new file mode 100644
index 0000000..2b66fae
--- /dev/null
+++ b/cmake/Modules/WafflePrintConfigurationSummary.cmake
@@ -0,0 +1,90 @@
+# 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.
+
+# CMake is annoyingly silent compared to autoconf. The user wants to know what
+# was configured how.
+
+message("")
+message("-----------------------------------------------")
+message("Configuration summary")
+message("-----------------------------------------------")
+message("")
+message("Supported platforms: ")
+if(waffle_has_glx)
+ message(" glx")
+endif()
+if(waffle_has_wayland)
+ message(" wayland")
+endif()
+if(waffle_has_x11_egl)
+ message(" x11_egl")
+endif()
+if(waffle_has_gbm)
+ message(" gbm")
+endif()
+message("")
+message("Dependencies:")
+if(waffle_has_egl)
+ message(" egl_INCLUDE_DIRS: ${egl_INCLUDE_DIRS}")
+ message(" egl_LDFLAGS: ${egl_LDFLAGS}")
+endif()
+if(waffle_has_glx)
+ message(" gl_INCLUDE_DIRS: ${gl_INCLUDE_DIRS}")
+ message(" gl_LDFLAGS: ${gl_LDFLAGS}")
+endif()
+if(waffle_has_wayland)
+ message(" wayland-client_INCLUDE_DIRS: ${wayland-client_INCLUDE_DIRS}")
+ message(" wayland-client_LDFLAGS: ${wayland-client_LDFLAGS}")
+ message(" wayland-egl_INCLUDE_DIRS: ${wayland-egl_INCLUDE_DIRS}")
+ message(" wayland-egl_LDFLAGS: ${wayland-egl_LDFLAGS}")
+endif()
+if(waffle_has_x11)
+ message(" x11-xcb_INCLUDE_DIRS: ${x11-xcb_INCLUDE_DIRS}")
+ message(" x11-xcb_LDFLAGS: ${x11-xcb_LDFLAGS}")
+endif()
+if(waffle_has_gbm)
+ message(" gbm_INCLUDE_DIRS: ${gbm_INCLUDE_DIRS}")
+ message(" gbm_LDFLAGS: ${gbm_LDFLAGS}")
+endif()
+message("")
+message("Build type:")
+message(" ${CMAKE_BUILD_TYPE}")
+message("")
+message("Tools:")
+message(" CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
+message(" CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
+message(" CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
+message(" CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
+if(waffle_build_manpages OR waffle_build_htmldocs)
+message(" xsltproc: ${waffle_xsltproc}")
+endif()
+message("")
+message("Install paths:")
+message(" CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
+message(" CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}")
+message(" CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
+message(" CMAKE_INSTALL_DOCDIR: ${CMAKE_INSTALL_DOCDIR}")
+message("")
+message("-----------------------------------------------")
diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake
new file mode 100644
index 0000000..03eb4ba
--- /dev/null
+++ b/cmake/Modules/WaffleValidateOptions.cmake
@@ -0,0 +1,68 @@
+# 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(waffle_on_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(waffle_on_mac)
+ if(waffle_has_gbm)
+ message(FATAL_ERROR "Option is not supported on Darwin: waffle_has_gbm.")
+ endif()
+ 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()
diff --git a/doc/building.txt b/doc/building.txt
deleted file mode 100644
index 1ab1a2b..0000000
--- a/doc/building.txt
+++ /dev/null
@@ -1,146 +0,0 @@
-Quickstart
-==========
-
-For basic build instructions that should work for most users, see the README.
-
-
-Configuration
-=============
-
-If any of Waffle's dependencies are installed in custom locations, you must
-set the PKG_CONFIG_PATH environment variable.
-
-To configure Waffle, invoke CMake as `cmake [options] $WAFFLE_SOURCE_DIR`.
-Options are given in form `-Dname=value`. CMake stores its configuration in a
-top-level file named CMakeCache.txt. To edit cached variables, either edit the
-file by hand or call `make edit_cache`.
-
-CMake builtin options:
-
- CMake has many builtin options. Here is a small subset of important
- options that affect Waffle.
-
- - CMAKE_INSTALL_PREFIX
- [default=/usr/local]
- Equivalent to autoconf's --prefix.
-
- - CMAKE_INSTALL_INCLUDEDIR
- [default=include]
- Equivalent to autoconf's --includedir.
- Relative paths are interpreted relative to CMAKE_INSTALL_PREFIX.
-
- - CMAKE_INSTALL_LIBDIR
- [default=lib or lib64, system-dependent]
- Equivalent to autoconf's --libdir.
- Relative paths are interpreted relative to CMAKE_INSTALL_PREFIX.
-
- - CMAKE_INSTALL_DOCDIR
- [default=${CMAKE_INSTALL_DATAROOTDIR}/doc/waffle-${MAJOR_VERSION}]
- Equivalent to autoconf's --docdir.
- Relative paths are interpreted relative to CMAKE_INSTALL_PREFIX.
-
- - CMAKE_BUILD_TYPE
- [default=?; choices=debug,release]
- This affects compilation flags.
-
- - CMAKE_C_FLAGS
- [default="--std=c99 -Wall -Werror"]
-
- - CMAKE_C_FLAGS_DEBUG
- [default="-g3 -O0 -DDEBUG"]
- Flags to append to CMAKE_C_FLAGS when CMAKE_BUILD_TYPE=debug.
-
- - CMAKE_C_FLAGS_RELEASE
- [default="-g1 -O2 -DNEDEBUG"]
- Flags to append to CMAKE_C_FLAGS when CMAKE_BUILD_TYPE=release.
-
-Platform options;
-
- - waffle_has_gbm
- [default=0] [choices=0,1]
- Build Waffle with support for GBM.
-
- - waffle_has_glx
- [default=0] [choices=0,1]
- Build Waffle with support for GLX.
-
- - waffle_has_wayland
- [default=0] [choices=0,1]
- Build Waffle with support for Wayland.
-
- - waffle_has_x11_egl
- [default=0] [choices=0,1]
- Build Waffle with support for X11/EGL.
-
-Miscellaneous options:
-
- - waffle_build_manpages
- [default=0; choices=0,1]
- Build and install the manpages.
-
- - waffle_build_htmldocs
- [default=0; choices=0,1]
- Build and install html documentation.
-
- - waffle_build_tests
- [default=1; choices=0,1]
- Build the unit tests and functional tests ran by `make check` and
- `make check-func`.
-
- - waffle_build_examples
- [default=1; choices=0,1]
- Build the stuff in the /examples directory.
-
-
-Building and Installing
-=======================
-
-To build and install Waffle:
-
- make
- make install
-
-I strongly recommend you run `make check` before installing.
-
-What follows is a list of significant build targets.
-
-Generic targets:
-
- - all
- Build everything.
-
- - check
- Run unit tests.
-
- - check-func
- Run functional tests as well as unit tests.
-
- - install
-
-Libraries:
-
- - waffle
- Waffle's main library.
-
- - waffle_test
- Waffle's test framework.
-
-Test programs:
-
- - waffle-unittest
- - gl_basic_test
-
-Example programs:
-
- - gl_basic
- - simple-x11-egl
-
-CMake targets:
-
- - help
- List all make targets.
-
- - edit_cache
- Edit CMakeCache.txt.
-
- - rebuild_cache
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index eb09669..48147f9 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -7,7 +7,7 @@ install(FILES Makefile.example
# Target: simple-x11-egl (executable)
# ----------------------------------------------------------------------------
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+if(waffle_on_linux)
add_executable(simple-x11-egl simple-x11-egl.c)
target_link_libraries(simple-x11-egl ${waffle_libname})
endif()
@@ -19,7 +19,7 @@ endif()
add_executable(gl_basic gl_basic.c)
target_link_libraries(gl_basic ${waffle_libname})
-if("${CMAKE_SYSTEM_NAME}" STREQUAL Darwin)
+if(waffle_on_mac)
set_target_properties(gl_basic
PROPERTIES
COMPILE_FLAGS "-ObjC"
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index cdb8981..a743096 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -59,7 +59,7 @@ set(waffle_sources
core/wcore_util.c
)
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+if(waffle_on_mac)
list(APPEND waffle_sources
cgl/cgl_config.m
cgl/cgl_context.m
@@ -98,7 +98,7 @@ if(waffle_has_glx)
)
endif()
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+if(waffle_on_linux)
list(APPEND waffle_sources
linux/linux_dl.c
linux/linux_platform.c
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 75bf90b..7a9dd7e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -3,3 +3,22 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(waffle_test)
add_subdirectory(unittests)
add_subdirectory(functional)
+
+#
+# Run only pure unit tests.
+#
+add_custom_target(check
+ DEPENDS waffle-unittest
+ COMMAND ${CMAKE_BINARY_DIR}/tests/unittests/waffle-unittest
+)
+
+#
+# Run functional and unit tests.
+#
+# The unit tests are ran first (due to the depenency on 'check'). If they
+# fail, then no subsequent tests are ran.
+#
+add_custom_target(check-func
+ DEPENDS check gl_basic_test
+ COMMAND ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
+)
diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt
index dbf481c..6ad923d 100644
--- a/tests/functional/CMakeLists.txt
+++ b/tests/functional/CMakeLists.txt
@@ -7,7 +7,7 @@ set(gl_basic_test_sources
gl_basic_test.c
)
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+if(waffle_on_mac)
list(APPEND gl_basic_test_sources
gl_basic_cocoa.m
)