Browse Source

Fix macOS build of new rglfw.c approach

There have been two problems:

* GLFW itself was compiled with the definitions for compiling
_against_ GLFW (fixed by removing requirement for external glfw)

* rglfw.c was being compiled as C code, although it includes
Objective C files.

This _might_ break the Windows build, needs to be checked.

Fixes #391, but as noted I'd prefer though a separate source directory
and build script for GLFW.
Ahmad Fatoum 7 years ago
parent
commit
b2acff66de
5 changed files with 8 additions and 16 deletions
  1. 1 2
      .travis.yml
  2. 3 3
      src/CMakeLists.txt
  3. 3 3
      src/gestures.h
  4. 1 1
      src/rglfw.c
  5. 0 7
      utils.cmake

+ 1 - 2
.travis.yml

@@ -25,9 +25,8 @@ before_install:
                               libopenal-dev
                               libopenal-dev
                               libxcursor-dev libxinerama-dev
                               libxcursor-dev libxinerama-dev
                               mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev;
                               mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev;
-      wget 'https://github.com/a3f/GLFW-3.2.1-Debian-binary-package/releases/download/v3.2.1/GLFW-3.2.1-Linux.deb' && sudo dpkg -i GLFW-3.2.1-Linux.deb;
     fi
     fi
-  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; brew install glfw; export CC=clang; fi
+  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; brew install glfw; fi
   - "$CC --version"
   - "$CC --version"
 
 
 script:
 script:

+ 3 - 3
src/CMakeLists.txt

@@ -20,6 +20,7 @@ set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
 set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
 set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
 ### Config options ###
 ### Config options ###
 
 
+include_directories(external/glfw/include)
 
 
 # Translate the config options to what raylib wants
 # Translate the config options to what raylib wants
 if(${PLATFORM} MATCHES "Desktop")
 if(${PLATFORM} MATCHES "Desktop")
@@ -40,6 +41,8 @@ if(${PLATFORM} MATCHES "Desktop")
   # See: https://github.com/raysan5/raylib/issues/341
   # See: https://github.com/raysan5/raylib/issues/341
   if(APPLE)
   if(APPLE)
     set(GRAPHICS "GRAPHICS_API_OPENGL_33")
     set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+    set_source_files_properties(rglfw.c PROPERTIES COMPILE_FLAGS "-x objective-c")
+    link_libraries("-framework CoreFoundation -framework Cocoa -framework IOKit -framework CoreVideo")
   endif()
   endif()
 elseif(${PLATFORM} MATCHES "Web")
 elseif(${PLATFORM} MATCHES "Web")
   set(PLATFORM "PLATFORM_WEB")
   set(PLATFORM "PLATFORM_WEB")
@@ -93,9 +96,6 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
     target_link_libraries(${RAYLIB} GL)
     target_link_libraries(${RAYLIB} GL)
   endif()
   endif()
   
   
-  # Add in GLFW as a linking target
-  target_link_libraries(${RAYLIB} glfw)
-  
   # Library file & Header
   # Library file & Header
   set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
   set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
   install(
   install(

+ 3 - 3
src/gestures.h

@@ -140,9 +140,6 @@ float GetGesturePinchAngle(void);                       // Get gesture pinch ang
 
 
 #if defined(GESTURES_IMPLEMENTATION)
 #if defined(GESTURES_IMPLEMENTATION)
 
 
-#include <math.h>               // Required for: atan2(), sqrt()
-#include <stdint.h>             // Required for: uint64_t
-
 #if defined(_WIN32)
 #if defined(_WIN32)
     // Functions required to query time on Windows
     // Functions required to query time on Windows
     int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
     int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
@@ -154,6 +151,9 @@ float GetGesturePinchAngle(void);                       // Get gesture pinch ang
     #endif
     #endif
     #include <sys/time.h>           // Required for: timespec
     #include <sys/time.h>           // Required for: timespec
     #include <time.h>               // Required for: clock_gettime()
     #include <time.h>               // Required for: clock_gettime()
+
+    #include <math.h>               // Required for: atan2(), sqrt()
+    #include <stdint.h>             // Required for: uint64_t
 #endif
 #endif
 
 
 //----------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------

+ 1 - 1
src/rglfw.c

@@ -86,5 +86,5 @@
     #include "external/glfw/src/posix_thread.c"
     #include "external/glfw/src/posix_thread.c"
     #include "external/glfw/src/nsgl_context.m" 
     #include "external/glfw/src/nsgl_context.m" 
     #include "external/glfw/src/egl_context.c" 
     #include "external/glfw/src/egl_context.c" 
-    #include "external/glfw/src/osmesa_context.c.m"
+    #include "external/glfw/src/osmesa_context.c"
 #endif
 #endif

+ 0 - 7
utils.cmake

@@ -6,10 +6,6 @@ if(UNIX AND NOT APPLE)
   set(LINUX TRUE)
   set(LINUX TRUE)
 endif()
 endif()
 
 
-# Need GLFW 3.2.1
-find_package(glfw3 3.2.1 REQUIRED)
-
-
 # Linking for OS X -framework options
 # Linking for OS X -framework options
 # Will do nothing on other OSes
 # Will do nothing on other OSes
 function(link_os_x_frameworks binary)
 function(link_os_x_frameworks binary)
@@ -40,9 +36,6 @@ function(link_libraries_to_executable executable)
     # TODO windows
     # TODO windows
   endif()
   endif()
   
   
-  # Add in GLFW as a linking target
-  target_link_libraries(${executable} glfw)
-
   # And raylib
   # And raylib
   target_link_libraries(${executable} raylib)
   target_link_libraries(${executable} raylib)
 endfunction()
 endfunction()