diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2014-12-31 18:47:13 -0800 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2014-12-31 18:47:13 -0800 |
commit | 46f54d88ce56ad4c489768e19aa7ef05603d821a (patch) | |
tree | 0d6fbfe0cb98c2b9343c707aea9ce3ed95ef592d | |
parent | cfa7afa25beb48b2457046d40f2a68aef8e25b7b (diff) | |
parent | 792072c3b592e0e2286b9faaf7be3a05e4a9e873 (diff) |
Merge branch 'maint-1.5'
* maint-1.5:
cmake: Add cmake PackageConfig files
cmake: fix version search
wgl: Verify the client area size matches the required size on window creation too.
examples/gl_basic: Add option for window size.
test/gl_basic_test: Address gcc format mismatch warning.
wgl: Fix requirements for creation of ES2 context
-rw-r--r-- | CMakeLists.txt | 27 | ||||
-rw-r--r-- | cmake/Modules/.gitignore | 2 | ||||
-rw-r--r-- | cmake/Modules/FindWaffle.cmake | 6 | ||||
-rw-r--r-- | cmake/Modules/WaffleConfig.cmake.in | 12 | ||||
-rw-r--r-- | examples/gl_basic.c | 22 | ||||
-rw-r--r-- | src/waffle/wgl/wgl_config.c | 4 | ||||
-rw-r--r-- | src/waffle/wgl/wgl_window.c | 12 | ||||
-rw-r--r-- | tests/functional/gl_basic_test.c | 2 |
8 files changed, 74 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bde8096..6fabb54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,8 @@ if(waffle_build_examples) endif() # ------------------------------------------------------------------------------ -# Install packaging files: waffle.pc, FindWaffle.cmake +# Install packaging files: waffle.pc, FindWaffle.cmake, +# WaffleConfigVersion.cmake, and WaffleConfig.cmake # ------------------------------------------------------------------------------ configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY) @@ -145,6 +146,30 @@ install( COMPONENT cmakefind ) +set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle") +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake" + VERSION "${waffle_version}" + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + cmake/Modules/WaffleConfig.cmake.in + cmake/Modules/WaffleConfig.cmake + INSTALL_DESTINATION "${ConfigPackageLocation}" + PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +install( + FILES + "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake" + "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfig.cmake" + DESTINATION "${ConfigPackageLocation}" + COMPONENT devel +) + # ------------------------------------------------------------------------------ # Install core documentation # ------------------------------------------------------------------------------ diff --git a/cmake/Modules/.gitignore b/cmake/Modules/.gitignore new file mode 100644 index 0000000..9742f46 --- /dev/null +++ b/cmake/Modules/.gitignore @@ -0,0 +1,2 @@ +WaffleConfigVersion.cmake +WaffleConfig.cmake diff --git a/cmake/Modules/FindWaffle.cmake b/cmake/Modules/FindWaffle.cmake index 972bdfe..4e16c4e 100644 --- a/cmake/Modules/FindWaffle.cmake +++ b/cmake/Modules/FindWaffle.cmake @@ -48,8 +48,8 @@ find_library(WAFFLE_LIBRARIES NAMES "waffle-${WAFFLE_FIND_VERSION_MAJOR}" ) -if(WAFFLE_INCLUDE_DIR AND EXISTS "${WAFFLE_INCLUDE_DIR}/waffle_version.h") - file(STRINGS "${WAFFLE_INCLUDE_DIR}/waffle_version.h" WAFFLE_VERSION_H) +if(WAFFLE_INCLUDE_DIRS AND EXISTS "${WAFFLE_INCLUDE_DIRS}/waffle_version.h") + file(STRINGS "${WAFFLE_INCLUDE_DIRS}/waffle_version.h" WAFFLE_VERSION_H) string(REGEX REPLACE "^.*WAFFLE_MAJOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MAJOR_VERSION "${WAFFLE_VERSION_H}") string(REGEX REPLACE "^.*WAFFLE_MINOR_VERSION ([0-9]+).*$" "\\1" WAFFLE_MINOR_VERSION "${WAFFLE_VERSION_H}") string(REGEX REPLACE "^.*WAFFLE_PATCH_VERSION ([0-9]+).*$" "\\1" WAFFLE_PATCH_VERSION "${WAFFLE_VERSION_H}") @@ -72,9 +72,7 @@ mark_as_advanced(WAFFLE_LIBRARIES WAFFLE_INCLUDE_DIRS) # variables from the cache *and* local scope. # unset(WAFFLE_FIND_VERSION_MAJOR CACHE) -unset(WAFFLE_INCLUDE_DIR CACHE) unset(WAFFLE_VERSION_H CACHE) unset(WAFFLE_FIND_VERSION_MAJOR) -unset(WAFFLE_INCLUDE_DIR) unset(WAFFLE_VERSION_H) diff --git a/cmake/Modules/WaffleConfig.cmake.in b/cmake/Modules/WaffleConfig.cmake.in new file mode 100644 index 0000000..b60b470 --- /dev/null +++ b/cmake/Modules/WaffleConfig.cmake.in @@ -0,0 +1,12 @@ +# Config module for Waffle +# +# Provides the following variables +# Waffle_INCLUDE_DIRS - Directories to include +# Waffle_LIBRARIES - Libraries to link +# Waffle_LIBRARY_DIRS - Library directories to search for link libraries + +@PACKAGE_INIT@ + +set_and_check(Waffle_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@waffle_libname@") +set_and_check(Waffle_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") +set(Waffle_LIBRARIES "@waffle_libname@") diff --git a/examples/gl_basic.c b/examples/gl_basic.c index fb62d52..69418c8 100644 --- a/examples/gl_basic.c +++ b/examples/gl_basic.c @@ -68,6 +68,7 @@ static const char *usage_message = " [--forward-compatible]\n" " [--debug]\n" " [--resize-window]\n" + " [--window-size=WIDTHxHEIGHT]\n" "\n" "examples:\n" " gl_basic --platform=glx --api=gl\n" @@ -96,6 +97,7 @@ enum { OPT_DEBUG, OPT_FORWARD_COMPATIBLE, OPT_RESIZE_WINDOW, + OPT_WINDOW_SIZE, }; static const struct option get_opts[] = { @@ -106,6 +108,7 @@ static const struct option get_opts[] = { { .name = "debug", .has_arg = no_argument, .val = OPT_DEBUG }, { .name = "forward-compatible", .has_arg = no_argument, .val = OPT_FORWARD_COMPATIBLE }, { .name = "resize-window", .has_arg = no_argument, .val = OPT_RESIZE_WINDOW }, + { .name = "window-size", .has_arg = required_argument, .val = OPT_WINDOW_SIZE }, { 0 }, }; @@ -190,8 +193,8 @@ enum { GL_CONTEXT_FLAG_DEBUG_BIT = 0x00000002, }; -#define WINDOW_WIDTH 320 -#define WINDOW_HEIGHT 240 +static int window_width = 320; +static int window_height = 240; #ifndef _WIN32 #define APIENTRY @@ -348,6 +351,15 @@ parse_args(int argc, char *argv[], struct options *opts) case OPT_RESIZE_WINDOW: opts->resize_window = true; break; + case OPT_WINDOW_SIZE: { + int match_count; + match_count = sscanf(optarg, "%dx%d", &window_width, &window_height); + if (match_count != 2) { + usage_error_printf("'%s' is not a valid window geometry", + optarg); + } + break; + } default: abort(); loop_get_opt = false; @@ -389,8 +401,8 @@ draw(struct waffle_window *window, bool resize) { bool ok; unsigned char *colors; - int width = WINDOW_WIDTH; - int height = WINDOW_HEIGHT; + int width = window_width; + int height = window_height; #if !defined(_WIN32) static const struct timespec sleep_time = { @@ -616,7 +628,7 @@ main(int argc, char **argv) if (!ctx) error_waffle(); - window = waffle_window_create(config, WINDOW_WIDTH, WINDOW_HEIGHT); + window = waffle_window_create(config, window_width, window_height); if (!window) error_waffle(); diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c index 9dea991..59a70a6 100644 --- a/src/waffle/wgl/wgl_config.c +++ b/src/waffle/wgl/wgl_config.c @@ -118,8 +118,10 @@ wgl_config_check_context_attrs(struct wgl_display *dpy, assert(attrs->context_major_version == 2); assert(!attrs->context_forward_compatible); - if (!dpy->EXT_create_context_es2_profile) { + if (!dpy->EXT_create_context_es2_profile + && !dpy->EXT_create_context_es_profile) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + "WGL_EXT_create_context_es_profile or " "WGL_EXT_create_context_es2_profile is required " "to create an OpenGL ES2 context"); return false; diff --git a/src/waffle/wgl/wgl_window.c b/src/waffle/wgl/wgl_window.c index a557c2f..7c3932f 100644 --- a/src/waffle/wgl/wgl_window.c +++ b/src/waffle/wgl/wgl_window.c @@ -127,6 +127,16 @@ wgl_window_priv_create(struct wcore_platform *wc_plat, if (!self->hWnd) goto error; +#ifndef NDEBUG + // Verify the client area size matches the required size. + + GetClientRect(self->hWnd, &rect); + assert(rect.left == 0); + assert(rect.top == 0); + assert(rect.right - rect.left == width); + assert(rect.bottom - rect.top == height); +#endif + self->hDC = GetDC(self->hWnd); if (!self->hDC) goto error; @@ -178,7 +188,7 @@ wgl_window_resize(struct wcore_window *wc_self, rect.bottom - rect.top, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); -#ifdef DEBUG +#ifndef NDEBUG // Verify the client area size matches the required size. GetClientRect(self->hWnd, &rect); diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 03692e0..0e932e3 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -1129,7 +1129,7 @@ run_testsuite(void (*testsuite)(void)) } else { fprintf(stderr, "gl_basic_test: error: get thread exit status" - " failed (%d)\n", GetLastError()); + " failed (%lu)\n", GetLastError()); abort(); } } |