From 0f1aaa474a0d81ccb8c7fd74d856cd42e48cb3b0 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 12 May 2018 15:39:13 +0200 Subject: CMake: (Properly) build glfw separately with CMake This reverts commit 2d6fb5c628068757387525e190c3afdbe33ae9c6, and adds a fix for Alien::raylib's test failures. The tests failed because the resulting static library didn't reexport GLFW symbols. As a fix, we now have GLFW create a CMake "object library" target that we can link with both the static and shared raylib. This is arguably ugly... Proper fix would probably be a GLFW upstream object library target. Closes #536. --- utils.cmake | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) mode change 100644 => 100755 utils.cmake (limited to 'utils.cmake') diff --git a/utils.cmake b/utils.cmake old mode 100644 new mode 100755 index 71e34e01..27f74e68 --- a/utils.cmake +++ b/utils.cmake @@ -17,47 +17,24 @@ if(APPLE) elseif(WIN32) # no pkg-config --static on Windows yet... else() - if(USE_WAYLAND) - set(_GLFW_WAYLAND 1) - else() - set(_GLFW_X11 1) - endif() - find_library(pthread NAMES pthread) find_package(OpenGL QUIET) if ("${OPENGL_LIBRARIES}" STREQUAL "") - if(NOT USE_WAYLAND) - # CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding - set(LIBS_PRIVATE m pthread GL X11 Xrandr Xinerama Xi Xxf86vm Xcursor) - else() - # CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding - set(LIBS_PRIVATE m pthread GL wayland-client wayland-cursor wayland-egl) - endif() + set(OPENGL_LIBRARIES "GL") + endif() + + include_directories(${OPENGL_INCLUDE_DIR}) + + if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") + find_library(OSS_LIBRARY ossaudio) + endif() + + set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) + # TODO: maybe read those out of glfw's cmake config? + if(USE_WAYLAND) + set(LIBS_PRIVATE ${LIBS_PRIVATE} wayland-client wayland-cursor wayland-egl) else() - if(NOT USE_WAYLAND) - find_package(X11 REQUIRED X11) - find_library(XRANDR_LIBRARY Xrandr) - find_library(XI_LIBRARY Xi) - find_library(XINERAMA_LIBRARY Xinerama) - find_library(XXF86VM_LIBRARY Xxf86vm) - find_library(XCURSOR_LIBRARY Xcursor) - else() - find_library(WAYLAND_CLIENT_LIBRARY wayland-client) - find_library(WAYLAND_CURSOR_LIBRARY wayland-cursor) - find_library(WAYLAND_EGL_LIBRARY wayland-egl) - endif() - - include_directories(${OPENGL_INCLUDE_DIR}) - - if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") - find_library(OSS_LIBRARY ossaudio) - endif() - - if(NOT USE_WAYLAND) - set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY} ${OSS_LIBRARY}) - else() - set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${WAYLAND_CLIENT_LIBRARY} ${WAYLAND_CURSOR_LIBRARY} ${WAYLAND_EGL_LIBRARY} ${OSS_LIBRARY}) - endif() + set(LIBS_PRIVATE ${LIBS_PRIVATE} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) endif() endif() -- cgit v1.2.3