]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
Use SGI gl.h and glx.h headers.
[apitrace] / CMakeLists.txt
index 39afc05d63461ea2e8ebe3342ba580964ef53356..a87021ceb6ad03bb287da72abca947b200ecd7e2 100755 (executable)
@@ -17,20 +17,21 @@ endif ()
 # prescribed in http://www.gentoo.org/proj/en/qa/automagic.xml
 set (ENABLE_GUI "AUTO" CACHE STRING "Enable Qt GUI.")
 
-set (ENABLE_EGL "AUTO" CACHE STRING "Enable EGL support.")
+set (ENABLE_CLI true CACHE BOOL "Enable command Line interface.")
+
+set (ENABLE_EGL true CACHE BOOL "Enable EGL support.")
 
 
 ##############################################################################
 # Find dependencies
 
-include (FindPkgConfig)
-
 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 
 set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
 
 find_package (PythonInterp REQUIRED)
-find_package (OpenGL REQUIRED)
+
+find_package (Threads)
 
 if (ENABLE_GUI)
     if (NOT (ENABLE_GUI STREQUAL "AUTO"))
@@ -40,11 +41,11 @@ if (ENABLE_GUI)
     find_package (QJSON ${REQUIRE_GUI})
 endif ()
 
-include_directories (${OPENGL_INCLUDE_DIR})
-
 if (WIN32)
     find_package (DirectX)
+    set (ENABLE_EGL false)
 elseif (APPLE)
+    set (ENABLE_EGL false)
 else ()
     find_package (X11)
 
@@ -54,16 +55,7 @@ else ()
     endif ()
 
     if (ENABLE_EGL)
-        if (NOT ENABLE_EGL STREQUAL "AUTO")
-            set (REQUIRE_EGL REQUIRED)
-        endif ()
-        pkg_check_modules (EGL egl glesv1_cm glesv2 ${REQUIRE_EGL})
-        if (EGL_FOUND)
-            include_directories (${EGL_INCLUDE_DIR})
-            add_definitions (-DHAVE_EGL)
-        endif ()
-    else ()
-        set (EGL_FOUND 0)
+        add_definitions (-DHAVE_EGL)
     endif ()
 endif ()
 
@@ -74,9 +66,6 @@ endif ()
 include (CheckCXXCompilerFlag)
 
 if (WIN32)
-    # MSVC & MinGW only define & use APIENTRY
-    add_definitions (-DGLAPIENTRY=__stdcall)
-
     # http://msdn.microsoft.com/en-us/library/aa383745.aspx
     add_definitions (-D_WIN32_WINNT=0x0500 -DWINVER=0x0500)
 else (WIN32)
@@ -201,12 +190,11 @@ if (QT4_FOUND AND NOT QJSON_FOUND AND (ENABLE_GUI STREQUAL "AUTO"))
     set (QJSON_FOUND TRUE)
 endif ()
 
-# For glext headers.  Needs to be before system includes as often system's GL
-# headers bundle and include glext.h and glxext.h
-include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glext)
-
-# For EGL headers
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khr)
+# We use bundled headers for all Khronos APIs, to guarantee support for both
+# OpenGL and OpenGL ES at build time, because the OpenGL and OpenGL ES 1 APIs
+# are so intertwined that conditional compilation extremely difficult. This
+# also avoids missing/inconsistent declarations in system headers.
+include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khronos)
 
 ##############################################################################
 # Installation directories
@@ -424,7 +412,7 @@ elseif (APPLE)
     )
 
     target_link_libraries (cgltrace
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -457,7 +445,7 @@ elseif (X11_FOUND)
 
     target_link_libraries (glxtrace
         ${X11_X11_LIB}
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -465,7 +453,7 @@ elseif (X11_FOUND)
 endif ()
 
 
-if (EGL_FOUND)
+if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
     # libEGL.so/libGL.so
     add_custom_command (
         OUTPUT egltrace.cpp
@@ -498,7 +486,7 @@ if (EGL_FOUND)
     )
 
     target_link_libraries (egltrace
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -559,7 +547,7 @@ if (WIN32 OR APPLE OR X11_FOUND)
             target_link_libraries (glretrace
                 "-framework Cocoa"
                 "-framework ApplicationServices" # CGS*
-                ${OPENGL_gl_LIBRARY} # CGL*
+                #"-framework OpenGL" # CGL*
             )
         else ()
             target_link_libraries (glretrace ${X11_X11_LIB})
@@ -569,7 +557,7 @@ if (WIN32 OR APPLE OR X11_FOUND)
             # gdb doesn't like when pthreads is loaded through dlopen (which happens
             # when dlopen'ing libGL), so link pthreads to avoid this issue.  See also
             # http://stackoverflow.com/questions/2702628/gdb-cannot-find-new-threads-generic-error
-            pthread
+            ${CMAKE_THREAD_LIBS_INIT}
             dl
         )
 
@@ -582,7 +570,7 @@ if (WIN32 OR APPLE OR X11_FOUND)
     install (TARGETS glretrace RUNTIME DESTINATION bin) 
 endif ()
 
-if (EGL_FOUND AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
+if (ENABLE_EGL AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
     add_executable (eglretrace
         ${retrace_sources}
         glws_egl_xlib.cpp
@@ -601,7 +589,7 @@ if (EGL_FOUND AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
     target_link_libraries (eglretrace
         common
         ${X11_X11_LIB}
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -615,7 +603,9 @@ endif ()
 ##############################################################################
 # CLI
 
-add_subdirectory(cli)
+if (ENABLE_CLI)
+    add_subdirectory(cli)
+endif ()
 
 ##############################################################################
 # Scripts (to support the CLI)
@@ -645,7 +635,6 @@ install (
         LICENSE
         NEWS.markdown
         README.markdown
-        TODO.markdown
     DESTINATION ${DOC_INSTALL_DIR}
 )