]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
apitrace: Replace tracedump program with new "apitrace dump" command
[apitrace] / CMakeLists.txt
index d7deb4fd83c0c2197955aa7a0ed60304e0816e2c..0b4ab84f20c1c6e7aa59ba65b42ff97d3a530bdd 100755 (executable)
@@ -36,34 +36,17 @@ if (ENABLE_GUI)
     find_package (QJSON ${REQUIRE_GUI})
 endif ()
 
-if (NOT WIN32)
+if (WIN32)
+    find_package (DirectX)
+elseif (APPLE)
+else ()
     find_package (X11 REQUIRED)
 
-    # 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 ()
+    set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
+    set (X11_GL_LIB ${OPENGL_gl_LIBRARY})
 
     include_directories (${X11_INCLUDE_DIR})
-endif (NOT WIN32)
-
-if (WIN32)
-    find_package (DirectX)
-endif (WIN32)
+endif ()
 
 
 ##############################################################################
@@ -123,6 +106,22 @@ else ()
     add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
 endif ()
 
+if (MINGW)
+    # Avoid depending on MinGW runtime DLLs
+    check_cxx_compiler_flag (-static-libgcc HAVE_STATIC_LIBGCC_FLAG)
+    if (HAVE_STATIC_LIBGCC_FLAG)
+        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
+        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libgcc")
+    endif ()
+    check_cxx_compiler_flag (-static-libstdc++ HAVE_STATIC_LIBSTDCXX_FLAG)
+    if (HAVE_STATIC_LIBSTDCXX_FLAG)
+        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
+        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
+        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -static-libstdc++")
+    endif ()
+endif ()
+
 
 # Put all executables into the same top level build directory, regardless of
 # which subdirectory they are declared
@@ -197,20 +196,25 @@ add_custom_command (
 
 if (WIN32)
     set (os os_win32.cpp)
-    set (glws glws_wgl.cpp)
-else (WIN32)
+    set (glws_os glws_wgl.cpp)
+else ()
     set (os os_posix.cpp)
-    set (glws glws_glx.cpp)
-endif (WIN32)
+    if (APPLE)
+        set (glws_os glws_cocoa.mm)
+    else ()
+        set (glws_os glws_glx.cpp)
+    endif ()
+endif ()
 
-add_library (common
+add_library (common STATIC
     common/trace_file.cpp
-    common/trace_snappyfile.cpp
+    common/trace_file_zlib.cpp
+    common/trace_file_snappy.cpp
     common/trace_model.cpp
     common/trace_parser.cpp
     common/trace_writer.cpp
-    common/trace_local_writer.cpp
-    common/trace_model_writer.cpp
+    common/trace_writer_local.cpp
+    common/trace_writer_model.cpp
     common/trace_loader.cpp
     common/image.cpp
     common/image_bmp.cpp
@@ -221,19 +225,20 @@ add_library (common
 
 set_target_properties (common PROPERTIES
     # Ensure it can be statically linked in shared libraries
-    COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
+    COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
 )
 
 link_libraries (common)
 
-add_executable (tracedump tracedump.cpp)
-install (TARGETS tracedump RUNTIME DESTINATION bin) 
-
-
 ##############################################################################
 # API tracers
 
 if (WIN32)
+    if (MINGW)
+        # Silence warnings about @nn suffix mismatch
+        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-stdcall-fixup")
+    endif (MINGW)
+
     # ddraw.dll
     if (DirectX_D3D_INCLUDE_DIR)
         include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR})
@@ -291,7 +296,7 @@ if (WIN32)
         add_custom_command (
             OUTPUT d3d10trace.cpp
             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
-            DEPENDS d3d10trace.py trace.py specs/d3d10misc.py specs/d3d10.py specs/dxgi.py specs/winapi.py specs/stdapi.py
+            DEPENDS d3d10trace.py trace.py specs/d3d10misc.py specs/d3d10.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
         )
         add_library (d3d10 MODULE specs/d3d10.def d3d10trace.cpp)
         set_target_properties (d3d10
@@ -319,9 +324,6 @@ if (WIN32)
         RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
         LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
     )
-    if (MINGW)
-        set_target_properties(wgltrace PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
-    endif (MINGW)
     install (TARGETS wgltrace LIBRARY DESTINATION wrappers)
 
 elseif (APPLE)
@@ -388,7 +390,7 @@ endif ()
 add_custom_command (
     OUTPUT glretrace_gl.cpp
     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
-    DEPENDS glretrace.py retrace.py codegen.py specs/glapi.py specs/gltypes.py specs/stdapi.py
+    DEPENDS glretrace.py retrace.py specs/glapi.py specs/gltypes.py specs/stdapi.py
 )
 
 add_custom_command (
@@ -411,7 +413,9 @@ add_executable (glretrace
     glstate.cpp
     glstate_params.cpp
     retrace.cpp
-    ${glws}
+    retrace_stdc.cpp
+    glws.cpp
+    ${glws_os}
     ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
 )
 
@@ -428,10 +432,8 @@ target_link_libraries (glretrace
 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 Cocoa"
         "-framework ApplicationServices" # CGS*
         ${OPENGL_gl_LIBRARY} # CGL*
     )
@@ -441,6 +443,10 @@ endif ()
 
 install (TARGETS glretrace RUNTIME DESTINATION bin) 
 
+##############################################################################
+# CLI
+
+add_subdirectory(cli)
 
 ##############################################################################
 # GUI