]> git.cworth.org Git - apitrace/commitdiff
More accurate include/linkage in Mac OS X.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 6 Jun 2011 20:06:29 +0000 (21:06 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 6 Jun 2011 20:06:29 +0000 (21:06 +0100)
A bit of a mess because unfortunately we depend on GLX to retrace on MacOSX.

CMakeLists.txt
glimports.hpp
glws_glx.cpp

index 5cf3ed87647a24d7a067f3a217865725d479e566..7da18a7ab5dfbb71a94b8b03d681aa10040b479c 100755 (executable)
@@ -20,12 +20,37 @@ if (NOT WIN32)
     # to deploy the wrappers DLLs
     find_package (ZLIB)
     find_package (PNG)
+endif (NOT WIN32)
+
+if (NOT WIN32)
     find_package (X11 REQUIRED)
 
-else (NOT WIN32)
-    find_package (DirectX)
+    # On Mac OS X, GLX is provided as a separate OpenGL implementation, different
+    # from the standard OpenGL framework which provides support for native Mac OS X
+    # applications.
+    if (APPLE)
+        find_path (X11_GL_INCLUDE_PATH GL/glx.h ${X11_INC_SEARCH_PATH})
+        if (NOT X11_GL_INCLUDE_PATH)
+            message (SEND_ERROR "Could not find GL/glx.h")
+        endif (NOT X11_GL_INCLUDE_PATH)
+        set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_GL_INCLUDE_PATH})
+
+        find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
+        if (NOT X11_GL_LIB)
+            message (SEND_ERROR "Could not find libGL.dylib")
+        endif (NOT X11_GL_LIB)
+    else ()
+        set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
+        set (X11_GL_LIB ${OPENGL_gl_LIBRARY})
+    endif ()
+
+    include_directories (${X11_INCLUDE_DIR})
 endif (NOT WIN32)
 
+if (WIN32)
+    find_package (DirectX)
+endif (WIN32)
+
 
 ##############################################################################
 # Set global build options
@@ -229,8 +254,6 @@ if (WIN32)
     install (TARGETS wgltrace LIBRARY DESTINATION wrappers)
 
 elseif (APPLE)
-    include_directories (${X11_INCLUDE_DIR})
-
     # OpenGL framework
     add_custom_command (
         OUTPUT cgltrace.cpp
@@ -241,7 +264,7 @@ elseif (APPLE)
     add_library (cgltrace SHARED cgltrace.cpp trace_writer.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
 
     set_target_properties (cgltrace PROPERTIES
-        # For
+        # OpenGL framework name
         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
         # Specificy the version and reexport GLU symbols
         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
@@ -253,8 +276,6 @@ elseif (APPLE)
 
     install (TARGETS cgltrace LIBRARY DESTINATION wrappers)
 else ()
-    include_directories (${X11_INCLUDE_DIR})
-
     # libGL.so
     add_custom_command (
         OUTPUT glxtrace.cpp
@@ -323,19 +344,21 @@ set_property (
 
 target_link_libraries (glretrace
     trace
-    ${OPENGL_gl_LIBRARY}
 )
 
-if (NOT WIN32)
-    target_link_libraries (glretrace ${X11_X11_LIB})
-
-    # We use GLX on MacOSX, which is in a separate library
-    if (APPLE)
-        find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
-        find_library (APPLICATIONSERVICES ApplicationServices)
-        target_link_libraries (glretrace ${X11_GL_LIB} ${APPLICATIONSERVICES})
-    endif (APPLE)
-endif (NOT WIN32)
+if (WIN32)
+    target_link_libraries (glretrace ${OPENGL_gl_LIBRARY})
+elseif (APPLE)
+    # XXX: We use GLX on MacOSX, which is in a separate library.
+    target_link_libraries (glretrace
+        ${X11_GL_LIB}
+        ${X11_X11_LIB}
+        "-framework ApplicationServices" # CGS*
+        ${OPENGL_gl_LIBRARY} # CGL*
+    )
+else ()
+    target_link_libraries (glretrace ${OPENGL_gl_LIBRARY} ${X11_X11_LIB})
+endif ()
 
 install (TARGETS glretrace RUNTIME DESTINATION bin) 
 
index ad248e129818632eeb1d268d1dc406c1664938a3..dce248a2649bc87caf721f2d7db8243595871c2f 100644 (file)
 #define _GLIMPORTS_HPP_
 
 
+// Prevent including system's glext.h
+#define __glext_h_
+
+
 #if defined(_WIN32)
 
 #ifndef WIN32_LEAN_AND_MEAN
 #endif
 
 #include <windows.h>
+#include <GL/gl.h>
 
 #elif defined(__APPLE__)
 
+#include <OpenGL/gl.h>
+
 #else
 
 #include <X11/Xlib.h>
+#include <GL/gl.h>
 
 #endif /* !_WIN32 */
 
 
-// Prevent including system's glext.h
-#define __glext_h_
-
-#include <GL/gl.h>
-
+// Include our own glext.h
 #undef __glext_h_
-
 #include "glext/glext.h"
 
+
 #ifndef GL_TEXTURE_INDEX_SIZE_EXT
 #define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED
 #endif
index 30de2f45b8ba8fa0b1b3cbdcd009346a85504c4b..95cdab078951eef107b8936d8a56fa34f3df58b4 100644 (file)
 #include <stdlib.h>
 #include <iostream>
 
-#include "glimports.hpp"
 #include "glws.hpp"
 
 #include <X11/Xlib.h>
+#include <GL/gl.h>
 #include <GL/glx.h>