]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
Specify the Qt version which we require.
[apitrace] / CMakeLists.txt
old mode 100644 (file)
new mode 100755 (executable)
index ab70358..2777857
@@ -1,5 +1,7 @@
 cmake_minimum_required (VERSION 2.8)
 
+include (CheckCXXCompilerFlag)
+
 project (apitrace)
 
 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
@@ -16,7 +18,7 @@ set (CMAKE_USE_PYTHON_VERSION 2.6)
 
 find_package (PythonInterp REQUIRED)
 find_package (OpenGL REQUIRED)
-find_package (Qt4 COMPONENTS QtCore QtGui QtWebKit)
+find_package (Qt4 4.7 COMPONENTS QtCore QtGui QtWebKit)
 find_package (QJSON)
 
 if (NOT WIN32)
@@ -25,6 +27,12 @@ if (NOT WIN32)
     find_package (ZLIB)
     find_package (PNG)
     find_package (X11 REQUIRED)
+
+    # We use GLX on MacOSX, which is in a separate library
+    if (APPLE)
+        find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
+        set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_GL_LIB})
+    endif (APPLE)
 else (NOT WIN32)
     find_package (DirectX)
 endif (NOT WIN32)
@@ -32,6 +40,11 @@ endif (NOT WIN32)
 if (WIN32)
     # MSVC & MinGW only define & use APIENTRY
     add_definitions (-DGLAPIENTRY=__stdcall)
+else (WIN32)
+    CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
+    if (CXX_COMPILER_FLAG_VISIBILITY)
+        add_definitions ("-fvisibility=hidden")
+    endif (CXX_COMPILER_FLAG_VISIBILITY)
 endif (WIN32)
 
 if (MSVC)
@@ -41,6 +54,9 @@ if (MSVC)
     # Enable math constants defines
     add_definitions (-D_USE_MATH_DEFINES)
 
+    # No min/max macros
+    add_definitions (-DNOMINMAX)
+
     # Adjust warnings
     add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
     add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
@@ -68,6 +84,10 @@ else ()
     add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
 endif ()
 
+# Put all executables into the same top level build directory, regardless of
+# which subdirectory they are declared
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+
 # Use bundled ZLIB if system one can't be found
 if (ZLIB_FOUND)
     include_directories (${ZLIB_INCLUDE_DIRS})
@@ -191,6 +211,20 @@ else ()
     )
 
     add_library (glxtrace SHARED glxtrace.cpp trace_write.cpp os_posix.cpp ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
+
+    set_target_properties (glxtrace PROPERTIES
+        # avoid the default "lib" prefix
+        PREFIX ""
+    )
+
+    # Prevent symbol relocations internal to our wrapper library to be
+    # overwritten by the application.
+    if (NOT APPLE)
+        set_target_properties (glxtrace PROPERTIES
+            LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+        )
+    endif (NOT APPLE)
+
     target_link_libraries (glxtrace dl)
 endif ()
 
@@ -202,10 +236,10 @@ else (WIN32)
     set (glws glws_glx.cpp)
 endif (WIN32)
 
-add_library (trace trace_model.cpp trace_parser.cpp ${os})
+add_library (trace trace_model.cpp trace_parser.cpp trace_write.cpp ${os})
 
-add_executable (dump dump.cpp)
-target_link_libraries (dump trace)
+add_executable (tracedump tracedump.cpp)
+target_link_libraries (tracedump trace)
 
 add_custom_command (
     OUTPUT glretrace_gl.cpp
@@ -216,7 +250,7 @@ add_custom_command (
 add_custom_command (
     OUTPUT glretrace_state.cpp
     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_state.cpp
-    DEPENDS glstate.py glenum.py stdapi.py
+    DEPENDS glstate.py glapi.py glenum.py stdapi.py
 )
 
 include_directories (
@@ -243,8 +277,6 @@ set_property (
 target_link_libraries (glretrace
     trace
     ${OPENGL_gl_LIBRARY}
-    ${OPENGL_glu_LIBRARY}
-    ${X11_LIBRARIES}
 )
 
 if (NOT WIN32)