]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
Add another enum.
[apitrace] / CMakeLists.txt
index 1131ae4c61d62601976e10468fd9ffdd531583cb..9dcb14f33a31f0158d30826b0527a21f7f6146ec 100755 (executable)
@@ -1,5 +1,7 @@
 cmake_minimum_required (VERSION 2.8)
 
+include (CheckCXXCompilerFlag)
+
 project (apitrace)
 
 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
@@ -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)
@@ -71,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})
@@ -196,9 +213,18 @@ 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 ()
 
@@ -210,7 +236,7 @@ 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 (tracedump tracedump.cpp)
 target_link_libraries (tracedump trace)
@@ -251,8 +277,6 @@ set_property (
 target_link_libraries (glretrace
     trace
     ${OPENGL_gl_LIBRARY}
-    ${OPENGL_glu_LIBRARY}
-    ${X11_LIBRARIES}
 )
 
 if (NOT WIN32)