From d976a7a86df4de24e20ba14ba99e5c5290b5705e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 14:27:19 +0100 Subject: [PATCH 01/34] Added Win32 library binaries. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index fad26de1..0496a03c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ src/libglfw.pc src/libglfw.so src/libglfw.a src/libglfw.dylib +src/glfw.lib +src/glfw.dll +src/glfwdll.lib examples/boing examples/gears examples/heightmap From 812ad163ebefa787437ecb6e5d58426b9e23f7d8 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 14:29:23 +0100 Subject: [PATCH 02/34] Formatting. --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdc4d5fe..7c66ba97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -if(UNIX) +if (UNIX) if (_GLFW_HAS_XRANDR) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") endif() @@ -18,19 +18,19 @@ include_directories(${GLFW_SOURCE_DIR}/src set(common_SOURCES error.c fullscreen.c gamma.c init.c input.c joystick.c opengl.c time.c window.c) -if(_GLFW_COCOA_NSGL) +if (_GLFW_COCOA_NSGL) set(libglfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c cocoa_init.m cocoa_input.m cocoa_joystick.m cocoa_opengl.m cocoa_time.c cocoa_window.m) # For some reason, CMake doesn't know about .m set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C) -elseif(_GLFW_WIN32_WGL) +elseif (_GLFW_WIN32_WGL) set(libglfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c win32_init.c win32_input.c win32_joystick.c win32_opengl.c win32_time.c win32_window.c win32_dllmain.c) -elseif(_GLFW_X11_GLX) +elseif (_GLFW_X11_GLX) set(libglfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c x11_init.c x11_input.c x11_joystick.c x11_keysym2unicode.c x11_opengl.c x11_time.c @@ -46,7 +46,7 @@ set_target_properties(libglfwStatic libglfwShared PROPERTIES CLEAN_DIRECT_OUTPUT 1 OUTPUT_NAME glfw) -if(WIN32) +if (WIN32) target_link_libraries(libglfwShared winmm) # The GLFW DLL needs a special compile-time macro and import library name set_target_properties(libglfwShared PROPERTIES @@ -56,7 +56,7 @@ if(WIN32) IMPORT_SUFFIX "dll.lib") endif() -if(APPLE) +if (APPLE) # Append -fno-common to the compile flags to work around a bug in the Apple GCC get_target_property(CFLAGS libglfwShared COMPILE_FLAGS) if (NOT CFLAGS) From 8d2c2791c2566109d91ff3033f7e81d10fdd4346 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 14:58:14 +0100 Subject: [PATCH 03/34] Added initial Linux MinGW-w64 support. --- CMake/linux-amd64-mingw32msvc.cmake | 15 +++++++++++++++ include/GL/glfw3.h | 6 ++++++ src/win32_init.c | 4 ++-- src/win32_platform.h | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 CMake/linux-amd64-mingw32msvc.cmake diff --git a/CMake/linux-amd64-mingw32msvc.cmake b/CMake/linux-amd64-mingw32msvc.cmake new file mode 100644 index 00000000..5b68540e --- /dev/null +++ b/CMake/linux-amd64-mingw32msvc.cmake @@ -0,0 +1,15 @@ +# Define the cross compilation environment for cross compiling from linux +# to Win64 it is to be used when Debian cross compilation toolchain is +# available. +SET(CMAKE_SYSTEM_NAME Windows) # Target system name +SET(CMAKE_SYSTEM_VERSION 1) # Not really used. +SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc") +SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++") +SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib") + + +#Configure the behaviour of the find commands +SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc") +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index cc817521..44e26b62 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -67,6 +67,12 @@ extern "C" { #endif #endif /* APIENTRY */ +/* TEMPORARY MinGW-w64 hacks. + */ +#if __MINGW64__ + #define WINAPI +#include +#endif /* The following three defines are here solely to make some Windows-based * files happy. Theoretically we could include , but diff --git a/src/win32_init.c b/src/win32_init.c index 4e1b7863..4fab9b74 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -200,7 +200,7 @@ int _glfwPlatformInit(void) // as possible in the hope of still being the foreground process) SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &_glfwLibrary.Win32.foregroundLockTimeout, 0); - SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0, + SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0), SPIF_SENDCHANGE); if (!initLibraries()) @@ -246,7 +246,7 @@ int _glfwPlatformTerminate(void) // Restore previous FOREGROUNDLOCKTIMEOUT system setting SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, - (LPVOID) _glfwLibrary.Win32.foregroundLockTimeout, + UIntToPtr(_glfwLibrary.Win32.foregroundLockTimeout), SPIF_SENDCHANGE); return GL_TRUE; diff --git a/src/win32_platform.h b/src/win32_platform.h index 82b8c9ca..0f6362c1 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -51,7 +51,9 @@ #endif // GLFW requires Windows XP +#ifndef WINVER #define WINVER 0x0501 +#endif #include #include From d204d5a434f51b0ddaab6537bd7acff0e288c55b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 23:25:39 +0100 Subject: [PATCH 04/34] Enabled all warnings on GNU C and compatibles. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f27cf7cd..57b8755f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) find_package(OpenGL REQUIRED) +if (CMAKE_COMPILER_IS_GNUCC) + add_definitions(-Wall) +endif() + #-------------------------------------------------------------------- # Set up GLFW for Win32 and WGL on Windows #-------------------------------------------------------------------- From 08942fcabe4474310a0d57176ae10b7842451276 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 23:28:43 +0100 Subject: [PATCH 05/34] Removed call to non-portable function. --- tests/modes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/modes.c b/tests/modes.c index de3aec8a..9c558d47 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -165,8 +165,6 @@ static void test_modes(GLFWvidmode* modes, int count) glfwCloseWindow(window); glfwPollEvents(); window = NULL; - - sleep(5); } } From c2a2114590ed289a14e64fcce614b852237f7b0f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Mar 2012 23:30:00 +0100 Subject: [PATCH 06/34] Fixed GCC warnings. --- src/x11_fullscreen.c | 2 +- src/x11_init.c | 4 ++-- src/x11_time.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/x11_fullscreen.c b/src/x11_fullscreen.c index f7855c4b..37a3ae98 100644 --- a/src/x11_fullscreen.c +++ b/src/x11_fullscreen.c @@ -323,7 +323,7 @@ struct _glfwResolution int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) { int count, k, l, r, g, b, rgba, gl; - int depth, screen; + int depth, screen = DefaultScreen(_glfwLibrary.X11.display); XVisualInfo* vislist; XVisualInfo dummy; int viscount, rgbcount, rescount; diff --git a/src/x11_init.c b/src/x11_init.c index 3ed9ab13..d57af27e 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -470,8 +470,8 @@ static void initGammaRamp(void) // RandR gamma support is only available with version 1.2 and above if (_glfwLibrary.X11.RandR.available && (_glfwLibrary.X11.RandR.majorVersion > 1 || - _glfwLibrary.X11.RandR.majorVersion == 1 && - _glfwLibrary.X11.RandR.minorVersion >= 2)) + (_glfwLibrary.X11.RandR.majorVersion == 1 && + _glfwLibrary.X11.RandR.minorVersion >= 2))) { // FIXME: Assumes that all monitors have the same size gamma tables // This is reasonable as I suspect the that if they did differ, it diff --git a/src/x11_time.c b/src/x11_time.c index 4184d326..f1445233 100644 --- a/src/x11_time.c +++ b/src/x11_time.c @@ -30,6 +30,7 @@ #include "internal.h" +#include #include From 29d38c3b649cbe5fecd315bab47c263852e24d2e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 23 Mar 2012 15:27:50 +0100 Subject: [PATCH 07/34] Increased Cocoa pixel format attribute array size. --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5bb33097..98c220ed 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -728,7 +728,7 @@ static GLboolean createContext(_GLFWwindow* window, #define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); } // Arbitrary array size here - NSOpenGLPixelFormatAttribute attributes[24]; + NSOpenGLPixelFormatAttribute attributes[40]; ADD_ATTR(NSOpenGLPFADoubleBuffer); From c175084e1310abdd98e5560416bf6e484cc113a1 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:47:13 +0200 Subject: [PATCH 08/34] Added workaround for CMake bug 0006976. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57b8755f..d30b1ee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,14 @@ if (UNIX AND NOT APPLE) if (X11_xf86vmode_FOUND) set(_GLFW_HAS_XF86VIDMODE 1) list(APPEND GLFW_INCLUDE_DIR ${X11_xf86vmode_INCLUDE_PATH}) + + # NOTE: This is a workaround for CMake bug 0006976 (missing + # X11_xf86vmode_LIB variable) + if (X11_xf86vmode_LIB) + list(APPEND GLFW_LIBRARIES ${X11_xf86vmode_LIB}) + else() + list(APPEND GLFW_LIBRARIES Xxf86vm) + endif() endif() # Check for Xkb (X keyboard extension) From 7f1d91e67b9904a6c64f3aab1f9df1da3603b8be Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:49:35 +0200 Subject: [PATCH 09/34] Formatting. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d30b1ee0..d09ba186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ if (UNIX AND APPLE) # Define the platform identifier set(_GLFW_COCOA_NSGL 1) - option(GLFW_BUILD_UNIVERSAL "Build the GLFW library and examples as Universal Binaries" FALSE) + option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) # Universal build if (GLFW_BUILD_UNIVERSAL) @@ -136,10 +136,10 @@ if (UNIX AND APPLE) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) - list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK}) - list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY}) - list(APPEND GLFW_LIBRARIES ${IOKIT_FRAMEWORK}) - list(APPEND GLFW_LIBRARIES ${CORE_FOUNDATION_FRAMEWORK}) + list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK} + ${OPENGL_gl_LIBRARY} + ${IOKIT_FRAMEWORK} + ${CORE_FOUNDATION_FRAMEWORK}) endif() #-------------------------------------------------------------------- From f21f196036234077083ac9d70d536b773cde0307 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:52:35 +0200 Subject: [PATCH 10/34] Added comment. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d09ba186..fc9fa103 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,9 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) find_package(OpenGL REQUIRED) +#-------------------------------------------------------------------- +# Enable all warnings on GCC, regardless of OS +#-------------------------------------------------------------------- if (CMAKE_COMPILER_IS_GNUCC) add_definitions(-Wall) endif() From 7b46a184cb0d1637ebb416b9ed578cbf2142046e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:53:53 +0200 Subject: [PATCH 11/34] Added standard option to switch between static and dynamic library, dropped dynamic test. --- CMakeLists.txt | 5 +++ examples/CMakeLists.txt | 12 ++++-- readme.html | 1 - src/CMakeLists.txt | 45 ++++++++++---------- tests/CMakeLists.txt | 40 ++++-------------- tests/dynamic.c | 91 ----------------------------------------- 6 files changed, 43 insertions(+), 151 deletions(-) delete mode 100644 tests/dynamic.c diff --git a/CMakeLists.txt b/CMakeLists.txt index fc9fa103..509ce57f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) find_package(OpenGL REQUIRED) @@ -33,6 +34,10 @@ if (WIN32) # Set up library and include paths list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR}) list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY}) + + if (BUILD_SHARED_LIBS) + list(APPEND GLFW_LIBRARIES winmm) + endif() endif() #-------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a644b987..b677addd 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,11 @@ -# This line is used to link with static libraries -# Note that the library list should be updated to be obtained from -# the main CMakeLists.txt -link_libraries(libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY}) + +link_libraries(glfw ${OPENGL_glu_LIBRARY}) + +if (BUILD_SHARED_LIBS) + add_definitions(-DGLFW_DLL) +else() + link_libraries(${GLFW_LIBRARIES}) +endif() include_directories(${GLFW_SOURCE_DIR}/include ${GLFW_SOURCE_DIR}/support diff --git a/readme.html b/readme.html index d7442d3b..84cc2a66 100644 --- a/readme.html +++ b/readme.html @@ -279,7 +279,6 @@ version of GLFW.

  • Added GLFW_INCLUDE_GL3 macro for telling the GLFW header to include gl3.h header instead of gl.h
  • Added windows simple multi-window test program
  • Added sharing simple OpenGL object sharing test program
  • -
  • Added dynamic simple dynamic linking test program
  • Added modes video mode enumeration and setting test program
  • Added a parameter to glfwOpenWindow for specifying a context the new window's context will share objects with
  • Added initial window title parameter to glfwOpenWindow
  • diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c66ba97..e508f259 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,31 +39,32 @@ else() message(FATAL_ERROR "No supported platform was selected") endif() -add_library(libglfwStatic STATIC ${libglfw_SOURCES}) -add_library(libglfwShared SHARED ${libglfw_SOURCES}) -target_link_libraries(libglfwShared ${GLFW_LIBRARIES}) -set_target_properties(libglfwStatic libglfwShared PROPERTIES - CLEAN_DIRECT_OUTPUT 1 - OUTPUT_NAME glfw) +add_library(glfw ${libglfw_SOURCES}) -if (WIN32) - target_link_libraries(libglfwShared winmm) - # The GLFW DLL needs a special compile-time macro and import library name - set_target_properties(libglfwShared PROPERTIES - COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" - PREFIX "" - IMPORT_PREFIX "" - IMPORT_SUFFIX "dll.lib") -endif() +if (BUILD_SHARED_LIBS) -if (APPLE) - # Append -fno-common to the compile flags to work around a bug in the Apple GCC - get_target_property(CFLAGS libglfwShared COMPILE_FLAGS) - if (NOT CFLAGS) - set(CFLAGS "") + if (WIN32) + # The GLFW DLL needs a special compile-time macro and import library name + set_target_properties(glfw PROPERTIES + COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" + PREFIX "" + IMPORT_PREFIX "" + IMPORT_SUFFIX "dll.lib") endif() - set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common") + + if (APPLE) + # Append -fno-common to the compile flags to work around a bug in the Apple GCC + get_target_property(CFLAGS glfw COMPILE_FLAGS) + if (NOT CFLAGS) + set(CFLAGS "") + endif() + set_target_properties(glfw PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common") + endif() + + target_link_libraries(glfw ${GLFW_LIBRARIES}) + target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) + endif() -install(TARGETS libglfwStatic libglfwShared DESTINATION lib) +install(TARGETS glfw DESTINATION lib) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7a166881..43db9d22 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,68 +1,42 @@ -set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY}) -set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY}) +link_libraries(glfw ${OPENGL_glu_LIBRARY}) + +if (BUILD_SHARED_LIBS) + add_definitions(-DGLFW_DLL) +else() + link_libraries(${GLFW_LIBRARIES}) +endif() include_directories(${GLFW_SOURCE_DIR}/include ${GLFW_SOURCE_DIR}/support ${OPENGL_INCLUDE_DIR}) add_executable(defaults defaults.c) -target_link_libraries(defaults ${STATIC_DEPS}) - -add_executable(dynamic dynamic.c) -target_link_libraries(dynamic ${SHARED_DEPS}) - add_executable(events events.c) -target_link_libraries(events ${STATIC_DEPS}) - add_executable(fsaa fsaa.c getopt.c) -target_link_libraries(fsaa ${STATIC_DEPS}) - add_executable(fsfocus fsfocus.c) -target_link_libraries(fsfocus ${STATIC_DEPS}) - add_executable(gamma gamma.c getopt.c) -target_link_libraries(gamma ${STATIC_DEPS}) - add_executable(glfwinfo glfwinfo.c getopt.c) -target_link_libraries(glfwinfo ${STATIC_DEPS}) - add_executable(iconify iconify.c getopt.c) -target_link_libraries(iconify ${STATIC_DEPS}) - add_executable(joysticks joysticks.c) -target_link_libraries(joysticks ${STATIC_DEPS}) - add_executable(listmodes listmodes.c) -target_link_libraries(listmodes ${STATIC_DEPS}) - add_executable(modes modes.c getopt.c) -target_link_libraries(modes ${STATIC_DEPS}) - add_executable(peter peter.c) -target_link_libraries(peter ${STATIC_DEPS}) - add_executable(reopen reopen.c) -target_link_libraries(reopen ${STATIC_DEPS}) add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) -target_link_libraries(accuracy ${STATIC_DEPS}) set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy") add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c) -target_link_libraries(sharing ${STATIC_DEPS}) set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) -target_link_libraries(tearing ${STATIC_DEPS}) set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") add_executable(title WIN32 MACOSX_BUNDLE title.c) -target_link_libraries(title ${STATIC_DEPS}) set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") add_executable(windows WIN32 MACOSX_BUNDLE windows.c) -target_link_libraries(windows ${STATIC_DEPS}) set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") set(WINDOWS_BINARIES accuracy sharing tearing title windows) diff --git a/tests/dynamic.c b/tests/dynamic.c deleted file mode 100644 index 8bc5568b..00000000 --- a/tests/dynamic.c +++ /dev/null @@ -1,91 +0,0 @@ -//======================================================================== -// Dynamic linking test -// Copyright (c) Camilla Berglund -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== -// -// This test came about as the result of bug #3060461 -// -//======================================================================== - -#define GLFW_DLL -#include - -#include -#include - -static void window_size_callback(GLFWwindow window, int width, int height) -{ - glViewport(0, 0, width, height); -} - -int main(void) -{ - GLFWwindow window; - int major, minor, rev; - glfwGetVersion(&major, &minor, &rev); - - printf("GLFW header version: %i.%i.%i\n", - GLFW_VERSION_MAJOR, - GLFW_VERSION_MINOR, - GLFW_VERSION_REVISION); - printf("GLFW library version: %i.%i.%i\n", major, minor, rev); - printf("GLFW library version string: %s\n", glfwGetVersionString()); - - if (major != GLFW_VERSION_MAJOR || - minor != GLFW_VERSION_MINOR || - rev != GLFW_VERSION_REVISION) - { - fprintf(stderr, "GLFW library version mismatch\n"); - exit(EXIT_FAILURE); - } - - if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW\n"); - exit(EXIT_FAILURE); - } - - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Dynamic Linking Test", NULL); - if (!window) - { - glfwTerminate(); - - fprintf(stderr, "Failed to open GLFW window\n"); - exit(EXIT_FAILURE); - } - - glfwSetWindowSizeCallback(window_size_callback); - glfwSwapInterval(1); - - while (glfwIsWindow(window)) - { - glClear(GL_COLOR_BUFFER_BIT); - - glfwSwapBuffers(); - glfwPollEvents(); - } - - glfwTerminate(); - exit(EXIT_SUCCESS); -} - From 23776f67e3708883dad557d1e0ed748f0bf3a7ac Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:58:07 +0200 Subject: [PATCH 12/34] Formatting. --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 509ce57f..2cd65cb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(OpenGL REQUIRED) # Enable all warnings on GCC, regardless of OS #-------------------------------------------------------------------- if (CMAKE_COMPILER_IS_GNUCC) - add_definitions(-Wall) + add_definitions(-Wall) endif() #-------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b677addd..2bdd95e9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,9 +2,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY}) if (BUILD_SHARED_LIBS) - add_definitions(-DGLFW_DLL) + add_definitions(-DGLFW_DLL) else() - link_libraries(${GLFW_LIBRARIES}) + link_libraries(${GLFW_LIBRARIES}) endif() include_directories(${GLFW_SOURCE_DIR}/include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 43db9d22..f6749e54 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,9 +2,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY}) if (BUILD_SHARED_LIBS) - add_definitions(-DGLFW_DLL) + add_definitions(-DGLFW_DLL) else() - link_libraries(${GLFW_LIBRARIES}) + link_libraries(${GLFW_LIBRARIES}) endif() include_directories(${GLFW_SOURCE_DIR}/include From 9e8f5477748814f87ddc362df264b2dc01448bdd Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 13:59:34 +0200 Subject: [PATCH 13/34] Formatting. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cd65cb3..85311188 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,7 @@ install(DIRECTORY include/GL DESTINATION include FILES_MATCHING PATTERN glfw3.h) install(FILES COPYING.txt readme.html - DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}/) + DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}) # The src directory's CMakeLists.txt file installs the library From 4a905d2e28144d6deeb962e4d073386b798a328b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 14:43:23 +0200 Subject: [PATCH 14/34] Comment update. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85311188..f5b08c1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ if (UNIX AND NOT APPLE) include(CheckFunctionExists) include(CheckSymbolExists) + # This is needed by the GLX function checks below set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES}) # Check for XRandR (modern resolution switching extension) @@ -97,7 +98,6 @@ if (UNIX AND NOT APPLE) list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) endif() - # Check for glXGetProcAddress check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) if (NOT _GLFW_HAS_GLXGETPROCADDRESS) From d743793e71ad3b0089a39f443c75391b832c3ee4 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 14:51:56 +0200 Subject: [PATCH 15/34] Pkg-config dependency generation fixes. --- CMakeLists.txt | 25 ++++++++++++++++--------- src/CMakeLists.txt | 9 ++------- src/libglfw.pc.cmake | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5b08c1e..5aa640b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,15 +55,7 @@ if (UNIX AND NOT APPLE) list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) list(APPEND GLFW_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY}) - find_library(MATH_LIBRARY m) - if (MATH_LIBRARY) - list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY}) - endif() - - find_library(RT_LIBRARY rt) - if (RT_LIBRARY) - list(APPEND GLFW_LIBRARIES ${RT_LIBRARY}) - endif() + set(GLFW_PKGLIBS "gl x11") include(CheckFunctionExists) include(CheckSymbolExists) @@ -76,6 +68,7 @@ if (UNIX AND NOT APPLE) set(_GLFW_HAS_XRANDR 1) list(APPEND GLFW_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH}) list(APPEND GLFW_LIBRARIES ${X11_Xrandr_LIB}) + set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") endif() # Check for Xf86VidMode (fallback legacy resolution switching extension) @@ -90,6 +83,8 @@ if (UNIX AND NOT APPLE) else() list(APPEND GLFW_LIBRARIES Xxf86vm) endif() + + set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm") endif() # Check for Xkb (X keyboard extension) @@ -98,6 +93,18 @@ if (UNIX AND NOT APPLE) list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) endif() + find_library(RT_LIBRARY rt) + if (RT_LIBRARY) + list(APPEND GLFW_LIBRARIES ${RT_LIBRARY}) + set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt") + endif() + + find_library(MATH_LIBRARY m) + if (MATH_LIBRARY) + list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY}) + set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m") + endif() + check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) if (NOT _GLFW_HAS_GLXGETPROCADDRESS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e508f259..aa7fbf30 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,14 +1,9 @@ if (UNIX) - if (_GLFW_HAS_XRANDR) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") - endif() - if (_GLFW_HAS_XF86VIDMODE) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm") - endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc + DESTINATION lib/pkgconfig) endif() include_directories(${GLFW_SOURCE_DIR}/src diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake index 47cfb4f5..164fdc26 100644 --- a/src/libglfw.pc.cmake +++ b/src/libglfw.pc.cmake @@ -7,6 +7,6 @@ Name: GLFW Description: A portable library for OpenGL, window and input Version: 3.0.0 URL: http://www.glfw.org/ -Requires.private: gl x11 @GLFW_PKGLIBS@ +Requires.private: @GLFW_PKGLIBS@ Libs: -L${libdir} -lglfw Cflags: -I${includedir} From 441452467a7127affa5957cdb24e184963b001c6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 15:05:48 +0200 Subject: [PATCH 16/34] Marked library variables as advanced. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aa640b7..d1034aad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,12 +94,14 @@ if (UNIX AND NOT APPLE) endif() find_library(RT_LIBRARY rt) + mark_as_advanced(RT_LIBRARY) if (RT_LIBRARY) list(APPEND GLFW_LIBRARIES ${RT_LIBRARY}) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt") endif() find_library(MATH_LIBRARY m) + mark_as_advanced(MATH_LIBRARY) if (MATH_LIBRARY) list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY}) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m") From 20e685d37bbfc5c377b085148fb2d66c8cd92abe Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 16:34:36 +0200 Subject: [PATCH 17/34] Formatted variables not used outside of the local CMake project. --- CMakeLists.txt | 30 +++++++++++++++--------------- src/CMakeLists.txt | 39 ++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1034aad..e7149dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,11 @@ if (WIN32) set(_GLFW_WIN32_WGL 1) # Set up library and include paths - list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR}) - list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY}) + list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) + list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY}) if (BUILD_SHARED_LIBS) - list(APPEND GLFW_LIBRARIES winmm) + list(APPEND glfw_LIBRARIES winmm) endif() endif() @@ -52,8 +52,8 @@ if (UNIX AND NOT APPLE) find_package(X11 REQUIRED) # Set up library and include paths - list(APPEND GLFW_INCLUDE_DIR ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) - list(APPEND GLFW_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY}) + list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) + list(APPEND glfw_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY}) set(GLFW_PKGLIBS "gl x11") @@ -61,27 +61,27 @@ if (UNIX AND NOT APPLE) include(CheckSymbolExists) # This is needed by the GLX function checks below - set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${glfw_LIBRARIES}) # Check for XRandR (modern resolution switching extension) if (X11_Xrandr_FOUND) set(_GLFW_HAS_XRANDR 1) - list(APPEND GLFW_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH}) - list(APPEND GLFW_LIBRARIES ${X11_Xrandr_LIB}) + list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH}) + list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB}) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") endif() # Check for Xf86VidMode (fallback legacy resolution switching extension) if (X11_xf86vmode_FOUND) set(_GLFW_HAS_XF86VIDMODE 1) - list(APPEND GLFW_INCLUDE_DIR ${X11_xf86vmode_INCLUDE_PATH}) + list(APPEND glfw_INCLUDE_DIRS ${X11_xf86vmode_INCLUDE_PATH}) # NOTE: This is a workaround for CMake bug 0006976 (missing # X11_xf86vmode_LIB variable) if (X11_xf86vmode_LIB) - list(APPEND GLFW_LIBRARIES ${X11_xf86vmode_LIB}) + list(APPEND glfw_LIBRARIES ${X11_xf86vmode_LIB}) else() - list(APPEND GLFW_LIBRARIES Xxf86vm) + list(APPEND glfw_LIBRARIES Xxf86vm) endif() set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm") @@ -90,20 +90,20 @@ if (UNIX AND NOT APPLE) # Check for Xkb (X keyboard extension) if (X11_Xkb_FOUND) set(_GLFW_HAS_XKB 1) - list(APPEND GLFW_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) + list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH}) endif() find_library(RT_LIBRARY rt) mark_as_advanced(RT_LIBRARY) if (RT_LIBRARY) - list(APPEND GLFW_LIBRARIES ${RT_LIBRARY}) + list(APPEND glfw_LIBRARIES ${RT_LIBRARY}) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt") endif() find_library(MATH_LIBRARY m) mark_as_advanced(MATH_LIBRARY) if (MATH_LIBRARY) - list(APPEND GLFW_LIBRARIES ${MATH_LIBRARY}) + list(APPEND glfw_LIBRARIES ${MATH_LIBRARY}) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m") endif() @@ -153,7 +153,7 @@ if (UNIX AND APPLE) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) - list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK} + list(APPEND glfw_LIBRARIES ${COCOA_FRAMEWORK} ${OPENGL_gl_LIBRARY} ${IOKIT_FRAMEWORK} ${CORE_FOUNDATION_FRAMEWORK}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa7fbf30..3f692cf8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,33 +8,33 @@ endif() include_directories(${GLFW_SOURCE_DIR}/src ${GLFW_BINARY_DIR}/src - ${GLFW_INCLUDE_DIR}) + ${glfw_INCLUDE_DIRS}) set(common_SOURCES error.c fullscreen.c gamma.c init.c input.c joystick.c opengl.c time.c window.c) if (_GLFW_COCOA_NSGL) - set(libglfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c - cocoa_init.m cocoa_input.m cocoa_joystick.m - cocoa_opengl.m cocoa_time.c cocoa_window.m) + set(glfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.c + cocoa_init.m cocoa_input.m cocoa_joystick.m + cocoa_opengl.m cocoa_time.c cocoa_window.m) # For some reason, CMake doesn't know about .m - set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C) + set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) elseif (_GLFW_WIN32_WGL) - set(libglfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c - win32_init.c win32_input.c win32_joystick.c - win32_opengl.c win32_time.c win32_window.c - win32_dllmain.c) + set(glfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c + win32_init.c win32_input.c win32_joystick.c + win32_opengl.c win32_time.c win32_window.c + win32_dllmain.c) elseif (_GLFW_X11_GLX) - set(libglfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c - x11_init.c x11_input.c x11_joystick.c - x11_keysym2unicode.c x11_opengl.c x11_time.c - x11_window.c) + set(glfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c + x11_init.c x11_input.c x11_joystick.c + x11_keysym2unicode.c x11_opengl.c x11_time.c + x11_window.c) else() message(FATAL_ERROR "No supported platform was selected") endif() -add_library(glfw ${libglfw_SOURCES}) +add_library(glfw ${glfw_SOURCES}) if (BUILD_SHARED_LIBS) @@ -49,14 +49,15 @@ if (BUILD_SHARED_LIBS) if (APPLE) # Append -fno-common to the compile flags to work around a bug in the Apple GCC - get_target_property(CFLAGS glfw COMPILE_FLAGS) - if (NOT CFLAGS) - set(CFLAGS "") + get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS) + if (NOT glfw_CFLAGS) + set(glfw_CFLAGS "") endif() - set_target_properties(glfw PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common") + set_target_properties(glfw PROPERTIES + COMPILE_FLAGS "${glfw_CFLAGS} -fno-common") endif() - target_link_libraries(glfw ${GLFW_LIBRARIES}) + target_link_libraries(glfw ${glfw_LIBRARIES}) target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) endif() From bd8eb1399a051ce09b07ce34f76f2e12889849bc Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 16:51:24 +0200 Subject: [PATCH 18/34] Put platform detection in a single place. --- CMakeLists.txt | 32 ++++++++++++++++++-------------- src/CMakeLists.txt | 11 +++-------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7149dd6..ef6ded3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,25 @@ if (CMAKE_COMPILER_IS_GNUCC) endif() #-------------------------------------------------------------------- -# Set up GLFW for Win32 and WGL on Windows +# Detect and select target platform #-------------------------------------------------------------------- if (WIN32) - message(STATUS "Building GLFW for WGL on a Win32 system") - - # Define the platform identifier set(_GLFW_WIN32_WGL 1) + message(STATUS "Building GLFW for WGL on a Win32 system") +elseif (UNIX AND APPLE) + set(_GLFW_COCOA_NSGL 1) + message(STATUS "Building GLFW for X11 and GLX on a Unix-like system") +elseif (UNIX AND NOT APPLE) + set(_GLFW_X11_GLX 1) + message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X") +else() + message(FATAL_ERROR "No supported platform was detected") +endif() + +#-------------------------------------------------------------------- +# Set up GLFW for Win32 and WGL on Windows +#-------------------------------------------------------------------- +if (_GLFW_WIN32_WGL) # Set up library and include paths list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) @@ -43,11 +55,7 @@ endif() #-------------------------------------------------------------------- # Set up GLFW for Xlib and GLX on Unix-like systems with X Windows #-------------------------------------------------------------------- -if (UNIX AND NOT APPLE) - message(STATUS "Building GLFW for X11 and GLX on a Unix-like system") - - # Define the platform identifier - set(_GLFW_X11_GLX 1) +if (_GLFW_X11_GLX) find_package(X11 REQUIRED) @@ -131,12 +139,8 @@ endif() #-------------------------------------------------------------------- # Set up GLFW for Cocoa and NSOpenGL on Mac OS X #-------------------------------------------------------------------- -if (UNIX AND APPLE) - message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X") +if (_GLFW_COCOA_NSGL) - # Define the platform identifier - set(_GLFW_COCOA_NSGL 1) - option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) # Universal build diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f692cf8..b8c0fd7d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ -if (UNIX) +if (_GLFW_X11_GLX) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @@ -30,24 +30,20 @@ elseif (_GLFW_X11_GLX) x11_init.c x11_input.c x11_joystick.c x11_keysym2unicode.c x11_opengl.c x11_time.c x11_window.c) -else() - message(FATAL_ERROR "No supported platform was selected") endif() add_library(glfw ${glfw_SOURCES}) if (BUILD_SHARED_LIBS) - if (WIN32) + if (_GLFW_WIN32_WGL) # The GLFW DLL needs a special compile-time macro and import library name set_target_properties(glfw PROPERTIES COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" PREFIX "" IMPORT_PREFIX "" IMPORT_SUFFIX "dll.lib") - endif() - - if (APPLE) + elseif (_GLFW_COCOA_NSGL) # Append -fno-common to the compile flags to work around a bug in the Apple GCC get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS) if (NOT glfw_CFLAGS) @@ -59,7 +55,6 @@ if (BUILD_SHARED_LIBS) target_link_libraries(glfw ${glfw_LIBRARIES}) target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) - endif() install(TARGETS glfw DESTINATION lib) From 1eb24ff261c815d2db102b78c74706defb892799 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:05:00 +0200 Subject: [PATCH 19/34] Executable dependency list fixes. --- examples/CMakeLists.txt | 3 ++- tests/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2bdd95e9..76135a92 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,8 +3,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY}) if (BUILD_SHARED_LIBS) add_definitions(-DGLFW_DLL) + link_libraries(${OPENGL_gl_LIBRARY}) else() - link_libraries(${GLFW_LIBRARIES}) + link_libraries(${glfw_LIBRARIES}) endif() include_directories(${GLFW_SOURCE_DIR}/include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f6749e54..d016fb0e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,8 +3,9 @@ link_libraries(glfw ${OPENGL_glu_LIBRARY}) if (BUILD_SHARED_LIBS) add_definitions(-DGLFW_DLL) + link_libraries(${OPENGL_gl_LIBRARY}) else() - link_libraries(${GLFW_LIBRARIES}) + link_libraries(${glfw_LIBRARIES}) endif() include_directories(${GLFW_SOURCE_DIR}/include From 862efe78e3535d8a1cad2084828ca91e410c60ac Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:22:35 +0200 Subject: [PATCH 20/34] Added fallback check for dlopen, clearer use of required libraries. --- CMakeLists.txt | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef6ded3d..d17f72ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,9 +68,6 @@ if (_GLFW_X11_GLX) include(CheckFunctionExists) include(CheckSymbolExists) - # This is needed by the GLX function checks below - set(CMAKE_REQUIRED_LIBRARIES ${glfw_LIBRARIES}) - # Check for XRandR (modern resolution switching extension) if (X11_Xrandr_FOUND) set(_GLFW_HAS_XRANDR 1) @@ -115,6 +112,8 @@ if (_GLFW_X11_GLX) set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m") endif() + set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY}) + check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS) if (NOT _GLFW_HAS_GLXGETPROCADDRESS) @@ -129,6 +128,26 @@ if (_GLFW_X11_GLX) NOT _GLFW_HAS_GLXGETPROCADDRESSARB AND NOT _GLFW_HAS_GLXGETPROCADDRESSEXT) message(WARNING "No glXGetProcAddressXXX variant found") + + # Check for dlopen support as a fallback + + find_library(DL_LIBRARY dl) + if (DL_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY}) + else() + set(CMAKE_REQUIRED_LIBRARIES "") + endif() + + check_function_exists(dlopen _GLFW_HAS_DLOPEN) + + if (NOT _GLFW_HAS_DLOPEN) + message(FATAL_ERROR "No entry point retrieval mechanism found") + endif() + + if (DL_LIBRARY) + list(APPEND glfw_LIBRARIES ${DL_LIBRARY}) + set(GLFW_PKGLIBS "${GLFW_PKGLIBS} dl") + endif() endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") From cfa798451e71b61504208de22434d1c51961961e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:23:24 +0200 Subject: [PATCH 21/34] Fixed platform messages being mixed up. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d17f72ed..8101242b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,10 @@ if (WIN32) message(STATUS "Building GLFW for WGL on a Win32 system") elseif (UNIX AND APPLE) set(_GLFW_COCOA_NSGL 1) - message(STATUS "Building GLFW for X11 and GLX on a Unix-like system") + message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X") elseif (UNIX AND NOT APPLE) set(_GLFW_X11_GLX 1) - message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X") + message(STATUS "Building GLFW for X11 and GLX on a Unix-like system") else() message(FATAL_ERROR "No supported platform was detected") endif() From 730e2e55c9a10b90c7728f44a9744873fd1ab36f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:24:33 +0200 Subject: [PATCH 22/34] Removed unused module. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8101242b..4ea202ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,6 @@ if (_GLFW_X11_GLX) set(GLFW_PKGLIBS "gl x11") include(CheckFunctionExists) - include(CheckSymbolExists) # Check for XRandR (modern resolution switching extension) if (X11_Xrandr_FOUND) From 8dc139183543040e87e0ac73ace61702ff4789ba Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:25:03 +0200 Subject: [PATCH 23/34] Marked library variable as advanced. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ea202ea..c3e41168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,7 @@ if (_GLFW_X11_GLX) # Check for dlopen support as a fallback find_library(DL_LIBRARY dl) + mark_as_advanced(DL_LIBRARY) if (DL_LIBRARY) set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY}) else() From c097246312820cb64c44d3742f4647b14c94b404 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:31:22 +0200 Subject: [PATCH 24/34] Fixed listing of non-pkg-config libraries. --- CMakeLists.txt | 13 +++++++------ src/libglfw.pc.cmake | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3e41168..07790a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,8 @@ if (_GLFW_X11_GLX) list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) list(APPEND glfw_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY}) - set(GLFW_PKGLIBS "gl x11") + set(GLFW_PKG_DEPS "gl x11") + set(GLFW_PKG_LIBS "") include(CheckFunctionExists) @@ -72,7 +73,7 @@ if (_GLFW_X11_GLX) set(_GLFW_HAS_XRANDR 1) list(APPEND glfw_INCLUDE_DIRS ${X11_Xrandr_INCLUDE_PATH}) list(APPEND glfw_LIBRARIES ${X11_Xrandr_LIB}) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xrandr") endif() # Check for Xf86VidMode (fallback legacy resolution switching extension) @@ -88,7 +89,7 @@ if (_GLFW_X11_GLX) list(APPEND glfw_LIBRARIES Xxf86vm) endif() - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm") + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xxf86vm") endif() # Check for Xkb (X keyboard extension) @@ -101,14 +102,14 @@ if (_GLFW_X11_GLX) mark_as_advanced(RT_LIBRARY) if (RT_LIBRARY) list(APPEND glfw_LIBRARIES ${RT_LIBRARY}) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} rt") + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lrt") endif() find_library(MATH_LIBRARY m) mark_as_advanced(MATH_LIBRARY) if (MATH_LIBRARY) list(APPEND glfw_LIBRARIES ${MATH_LIBRARY}) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} m") + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm") endif() set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY}) @@ -146,7 +147,7 @@ if (_GLFW_X11_GLX) if (DL_LIBRARY) list(APPEND glfw_LIBRARIES ${DL_LIBRARY}) - set(GLFW_PKGLIBS "${GLFW_PKGLIBS} dl") + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl") endif() endif() diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake index 164fdc26..f83ad126 100644 --- a/src/libglfw.pc.cmake +++ b/src/libglfw.pc.cmake @@ -7,6 +7,7 @@ Name: GLFW Description: A portable library for OpenGL, window and input Version: 3.0.0 URL: http://www.glfw.org/ -Requires.private: @GLFW_PKGLIBS@ -Libs: -L${libdir} -lglfw +Requires.private: @GLFW_PKG_DEPS@ +Libs: -L${libdir} -lglfw +Libs.private: @GLFW_PKG_LIBS@ Cflags: -I${includedir} From 2588c9be1739d62d7b27bf11e278d1a6063d40e3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:40:30 +0200 Subject: [PATCH 25/34] Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL. --- include/GL/glfw3.h | 2 +- readme.html | 1 + src/CMakeLists.txt | 2 +- src/win32_dllmain.c | 4 ++-- src/win32_init.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 44e26b62..180fca80 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -119,7 +119,7 @@ extern "C" { /* ---------------- GLFW related system specific defines ----------------- */ -#if defined(_WIN32) && defined(GLFW_BUILD_DLL) +#if defined(_WIN32) && defined(_GLFW_BUILD_DLL) /* We are building a Win32 DLL */ #define GLFWAPI __declspec(dllexport) diff --git a/readme.html b/readme.html index 84cc2a66..f631acd7 100644 --- a/readme.html +++ b/readme.html @@ -288,6 +288,7 @@ version of GLFW.

  • Renamed glfw.h to glfw3.h to avoid conflicts with 2.x series
  • Renamed GLFW_WINDOW token to GLFW_WINDOWED
  • Renamed GLFW_WINDOW_NO_RESIZE to GLFW_WINDOW_RESIZABLE
  • +
  • Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL
  • Renamed version test to glfwinfo
  • Replaced ad hoc build system with CMake
  • Replaced layout-dependent key codes with single, platform-independent set based on US layout
  • diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8c0fd7d..b87ac3b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,7 @@ if (BUILD_SHARED_LIBS) if (_GLFW_WIN32_WGL) # The GLFW DLL needs a special compile-time macro and import library name set_target_properties(glfw PROPERTIES - COMPILE_DEFINITIONS "GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" + COMPILE_DEFINITIONS "_GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" PREFIX "" IMPORT_PREFIX "" IMPORT_SUFFIX "dll.lib") diff --git a/src/win32_dllmain.c b/src/win32_dllmain.c index a999af0e..95258ccc 100644 --- a/src/win32_dllmain.c +++ b/src/win32_dllmain.c @@ -31,7 +31,7 @@ #include "internal.h" -#if defined(GLFW_BUILD_DLL) +#if defined(_GLFW_BUILD_DLL) //======================================================================== // GLFW DLL entry point @@ -45,5 +45,5 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) return TRUE; } -#endif // GLFW_BUILD_DLL +#endif // _GLFW_BUILD_DLL diff --git a/src/win32_init.c b/src/win32_init.c index 4fab9b74..55232fd7 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -271,7 +271,7 @@ const char* _glfwPlatformGetVersionString(void) #else " (unknown compiler)" #endif -#if defined(GLFW_BUILD_DLL) +#if defined(_GLFW_BUILD_DLL) " DLL" #endif #if !defined(_GLFW_NO_DLOAD_GDI32) From cc5d7cda64643b900c93502927837d09b35c13b3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 17:43:02 +0200 Subject: [PATCH 26/34] Added configuration error check. --- include/GL/glfw3.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 180fca80..b29d0005 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -119,6 +119,10 @@ extern "C" { /* ---------------- GLFW related system specific defines ----------------- */ +#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) + #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" +#endif + #if defined(_WIN32) && defined(_GLFW_BUILD_DLL) /* We are building a Win32 DLL */ From 415ebbb97cfb9487b8682cf704cd7a07481a2420 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 20:15:27 +0200 Subject: [PATCH 27/34] Added cache variable for dependencies of GLFW. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07790a12..522aaf76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,6 +183,11 @@ if (_GLFW_COCOA_NSGL) ${CORE_FOUNDATION_FRAMEWORK}) endif() +#-------------------------------------------------------------------- +# Export GLFW library dependencies +#-------------------------------------------------------------------- +set(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING "Dependencies of GLFW") + #-------------------------------------------------------------------- # Add subdirectories #-------------------------------------------------------------------- From 7fb702a22be00f26de75483185d39a01aa44abc6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 25 Mar 2012 20:45:06 +0200 Subject: [PATCH 28/34] Removed unused code. --- src/win32_window.c | 46 +--------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 0f3c67d0..dd25c3ce 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -34,30 +34,6 @@ #include -//======================================================================== -// Convert BPP to RGB bits based on "best guess" -//======================================================================== - -static void bpp2rgb(int bpp, int* r, int* g, int* b) -{ - int delta; - - // We assume that by 32 they really meant 24 - if (bpp == 32) - bpp = 24; - - // Convert "bits per pixel" to red, green & blue sizes - - *r = *g = *b = bpp / 3; - delta = bpp - (*r * 3); - if (delta >= 1) - *g = *g + 1; - - if (delta == 2) - *r = *r + 1; -} - - //======================================================================== // Enable/disable minimize/restore animations //======================================================================== @@ -1600,29 +1576,10 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) { - //int bpp, refresh; - int newMode = 0; GLboolean sizeChanged = GL_FALSE; if (window->mode == GLFW_FULLSCREEN) { - // Get some info about the current mode - - DEVMODE dm; - - dm.dmSize = sizeof(DEVMODE); - //if (EnumDisplaySettings(NULL, window->Win32.modeID, &dm)) - //{ - // We need to keep BPP the same for the OpenGL context to keep working - //bpp = dm.dmBitsPerPel; - - // Get closest match for target video mode - //refresh = window->Win32.desiredRefreshRate; - //newMode = _glfwGetClosestVideoModeBPP(&width, &height, &bpp, &refresh); - //} - //else - //newMode = window->Win32.modeID; - if (width > window->width || height > window->height) { // The new video mode is larger than the current one, so we resize @@ -1634,8 +1591,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) sizeChanged = GL_TRUE; } - //if (newMode != window->Win32.modeID) - //_glfwSetVideoModeMODE(newMode); + // TODO: Change video mode } else { From e53bbfd2dd5b383cfe0e1a7e2b1e4a6630b81956 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 03:06:45 +0200 Subject: [PATCH 29/34] Renamed pkg-config file template. --- src/CMakeLists.txt | 2 +- src/{libglfw.pc.cmake => libglfw.pc.in} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{libglfw.pc.cmake => libglfw.pc.in} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b87ac3b1..7358c8f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ if (_GLFW_X11_GLX) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig) diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.in similarity index 100% rename from src/libglfw.pc.cmake rename to src/libglfw.pc.in From 6fd6c5f7e45c0a9a29b9d539a2fb198603e596b6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 03:11:43 +0200 Subject: [PATCH 30/34] Moved pkg-config file generation. --- CMakeLists.txt | 6 ++++++ src/CMakeLists.txt | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 522aaf76..665f8c64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,12 @@ if (_GLFW_X11_GLX) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(_GLFW_USE_LINUX_JOYSTICKS 1) endif() + + configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in + ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY) + + install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc + DESTINATION lib/pkgconfig) endif() #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7358c8f5..26471f93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,4 @@ -if (_GLFW_X11_GLX) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc - DESTINATION lib/pkgconfig) -endif() - include_directories(${GLFW_SOURCE_DIR}/src ${GLFW_BINARY_DIR}/src ${glfw_INCLUDE_DIRS}) From fd6bc698c0d695b47c587549a77559f846ca91c6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 12:54:50 +0200 Subject: [PATCH 31/34] Moved file generation around. --- CMakeLists.txt | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 665f8c64..aab5c293 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,12 +154,6 @@ if (_GLFW_X11_GLX) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(_GLFW_USE_LINUX_JOYSTICKS 1) endif() - - configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in - ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY) - - install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc - DESTINATION lib/pkgconfig) endif() #-------------------------------------------------------------------- @@ -208,29 +202,34 @@ if (GLFW_BUILD_TESTS) endif() #-------------------------------------------------------------------- -# Create shared configuration header +# Create generated files #-------------------------------------------------------------------- +configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" + "${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY) + configure_file(${GLFW_SOURCE_DIR}/src/config.h.in ${GLFW_BINARY_DIR}/src/config.h @ONLY) #-------------------------------------------------------------------- -# Install standard files +# Install header and documentation +# The src directory's CMakeLists.txt file installs the library #-------------------------------------------------------------------- - install(DIRECTORY include/GL DESTINATION include FILES_MATCHING PATTERN glfw3.h) install(FILES COPYING.txt readme.html DESTINATION share/doc/glfw-${GLFW_VERSION_FULL}) -# The src directory's CMakeLists.txt file installs the library +#-------------------------------------------------------------------- +# Create and install pkg-config file on supported platforms +#-------------------------------------------------------------------- +if (_GLFW_X11_GLX) + configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in + ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY) -#-------------------------------------------------------------------- -# -- Documentation generation -#-------------------------------------------------------------------- -configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" - "${GLFW_BINARY_DIR}/docs/Doxyfile" - @ONLY) + install(FILES ${GLFW_BINARY_DIR}/src/libglfw.pc + DESTINATION lib/pkgconfig) +endif() #-------------------------------------------------------------------- # Uninstall operation From 2a8324955cc3630807c3f51ff0e4daf1a00f8364 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 13:14:06 +0200 Subject: [PATCH 32/34] Formatting. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aab5c293..01b50a6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,8 +204,8 @@ endif() #-------------------------------------------------------------------- # Create generated files #-------------------------------------------------------------------- -configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" - "${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY) +configure_file(${GLFW_SOURCE_DIR}/docs/Doxyfile.in + ${GLFW_BINARY_DIR}/docs/Doxyfile @ONLY) configure_file(${GLFW_SOURCE_DIR}/src/config.h.in ${GLFW_BINARY_DIR}/src/config.h @ONLY) From 92758e4ac0cccc1cf9cf30fd23a5bdcf76498bee Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 13:15:37 +0200 Subject: [PATCH 33/34] Made pkg-config file use version variable. --- src/libglfw.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libglfw.pc.in b/src/libglfw.pc.in index f83ad126..be6275aa 100644 --- a/src/libglfw.pc.in +++ b/src/libglfw.pc.in @@ -5,7 +5,7 @@ libdir=${exec_prefix}/lib Name: GLFW Description: A portable library for OpenGL, window and input -Version: 3.0.0 +Version: @GLFW_VERSION_FULL@ URL: http://www.glfw.org/ Requires.private: @GLFW_PKG_DEPS@ Libs: -L${libdir} -lglfw From ee1d71adf3d372ea039fd7033f6683cf7b2864cb Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 26 Mar 2012 13:35:14 +0200 Subject: [PATCH 34/34] Added OS X support to pkg-config file. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aab5c293..93970833 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,9 @@ if (_GLFW_COCOA_NSGL) ${OPENGL_gl_LIBRARY} ${IOKIT_FRAMEWORK} ${CORE_FOUNDATION_FRAMEWORK}) + + set(GLFW_PKG_DEPS "") + set(GLFW_PKG_LIBS "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation") endif() #-------------------------------------------------------------------- @@ -223,7 +226,7 @@ install(FILES COPYING.txt readme.html #-------------------------------------------------------------------- # Create and install pkg-config file on supported platforms #-------------------------------------------------------------------- -if (_GLFW_X11_GLX) +if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL) configure_file(${GLFW_SOURCE_DIR}/src/libglfw.pc.in ${GLFW_BINARY_DIR}/src/libglfw.pc @ONLY)