]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
cmake: Link (e)glretrace against dl.
[apitrace] / CMakeLists.txt
index f0ef513a5e562d9405791fee6f0c577ba8895587..09386aa2a6a699c2f25572b9502e9258aeb0b2ce 100755 (executable)
@@ -238,6 +238,7 @@ add_definitions(
 # Common libraries / utilities
 
 include_directories (
+    ${CMAKE_CURRENT_BINARY_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}/common
 )
@@ -248,6 +249,11 @@ add_custom_command (
     DEPENDS glproc.py dispatch.py specs/wglapi.py specs/glxapi.py specs/cglapi.py specs/eglapi.py specs/glesapi.py specs/glapi.py specs/gltypes.py specs/stdapi.py
 )
 
+# Wrap glproc.hpp as a target to prevent the command from being executed
+# multiple times simulatenously, when the targets that depend on it are built
+# in parallel.
+add_custom_target (glproc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
+
 if (WIN32)
     set (os os_win32.cpp)
     set (glws_os glws_wgl.cpp)
@@ -378,8 +384,8 @@ if (WIN32)
         wgltrace.cpp
         glcaps.cpp
         glproc_gl.cpp
-        ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
     )
+    add_dependencies (wgltrace glproc)
     set_target_properties (wgltrace PROPERTIES
         PREFIX ""
         OUTPUT_NAME opengl32
@@ -400,9 +406,10 @@ elseif (APPLE)
         cgltrace.cpp
         glcaps.cpp
         glproc_gl.cpp
-        ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
     )
 
+    add_dependencies (cgltrace glproc)
+
     set_target_properties (cgltrace PROPERTIES
         # OpenGL framework name
         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
@@ -424,12 +431,13 @@ else ()
     )
 
     add_library (glxtrace SHARED
-        ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
         glxtrace.cpp
         glcaps.cpp
         glproc_gl.cpp
     )
 
+    add_dependencies (glxtrace glproc)
+
     set_target_properties (glxtrace PROPERTIES
         # avoid the default "lib" prefix
         PREFIX ""
@@ -455,12 +463,13 @@ if (EGL_FOUND)
     )
 
     add_library (egltrace SHARED
-        ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
         egltrace.cpp
         glcaps.cpp
         glproc_egl.cpp
     )
 
+    add_dependencies (egltrace glproc)
+
     set_property (
         TARGET egltrace
         APPEND
@@ -497,11 +506,6 @@ add_custom_command (
     DEPENDS glstate.py specs/glparams.py specs/gltypes.py specs/stdapi.py
 )
 
-include_directories (
-    ${CMAKE_CURRENT_BINARY_DIR}
-    ${OPENGL_INCLUDE_PATH}
-)
-
 set (retrace_sources
     glretrace_gl.cpp
     glretrace_cgl.cpp
@@ -514,7 +518,6 @@ set (retrace_sources
     retrace.cpp
     retrace_stdc.cpp
     glws.cpp
-    ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
 )
 
 add_executable (glretrace
@@ -523,6 +526,8 @@ add_executable (glretrace
     glproc_gl.cpp
 )
 
+add_dependencies (glretrace glproc)
+
 set_property (
     TARGET glretrace
     APPEND
@@ -545,10 +550,13 @@ else ()
         target_link_libraries (glretrace ${X11_X11_LIB})
     endif ()
 
-    # 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
-    target_link_libraries (glretrace pthread)
+    target_link_libraries (glretrace
+        # 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
+        dl
+    )
 endif ()
 
 install (TARGETS glretrace RUNTIME DESTINATION bin) 
@@ -560,6 +568,8 @@ if (EGL_FOUND AND NOT WIN32 AND NOT APPLE)
         glproc_egl.cpp
     )
 
+    add_dependencies (eglretrace glproc)
+
     set_property (
         TARGET eglretrace
         APPEND
@@ -571,6 +581,7 @@ if (EGL_FOUND AND NOT WIN32 AND NOT APPLE)
         common
         ${X11_X11_LIB}
         pthread
+        dl
     )
 
     install (TARGETS eglretrace RUNTIME DESTINATION bin)