]> git.cworth.org Git - apitrace/blob - CMakeLists.txt
More D2D spec tweaks.
[apitrace] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8)
2
3 project (apitrace)
4
5
6 ##############################################################################
7 # Options
8
9 # On Mac OS X build fat binaries with i386 and x86_64 architectures by default.
10 if (APPLE AND NOT CMAKE_OSX_ARCHITECTURES)
11     set (CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
12 endif ()
13
14 # We use a cached string variable instead of the standard (boolean) OPTION
15 # command so that we can default to auto-detecting optional depencies, while
16 # still providing a mechanism to force/disable these optional dependencies, as
17 # prescribed in http://www.gentoo.org/proj/en/qa/automagic.xml
18 set (ENABLE_GUI "AUTO" CACHE STRING "Enable Qt GUI.")
19
20
21 ##############################################################################
22 # Find dependencies
23
24 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
25
26 set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
27
28 find_package (PythonInterp REQUIRED)
29 find_package (OpenGL REQUIRED)
30
31 if (ENABLE_GUI)
32     if (NOT (ENABLE_GUI STREQUAL "AUTO"))
33         set (REQUIRE_GUI REQUIRED)
34     endif ()
35     find_package (Qt4 4.7 COMPONENTS QtCore QtGui QtWebKit ${REQUIRE_GUI})
36     find_package (QJSON ${REQUIRE_GUI})
37 endif ()
38
39 if (NOT WIN32)
40     find_package (X11 REQUIRED)
41
42     # On Mac OS X, GLX is provided as a separate OpenGL implementation, different
43     # from the standard OpenGL framework which provides support for native Mac OS X
44     # applications.
45     if (APPLE)
46         find_path (X11_GL_INCLUDE_PATH GL/glx.h ${X11_INC_SEARCH_PATH})
47         if (NOT X11_GL_INCLUDE_PATH)
48             message (SEND_ERROR "Could not find GL/glx.h")
49         endif (NOT X11_GL_INCLUDE_PATH)
50         set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_GL_INCLUDE_PATH})
51
52         find_library (X11_GL_LIB GL ${X11_LIB_SEARCH_PATH})
53         if (NOT X11_GL_LIB)
54             message (SEND_ERROR "Could not find libGL.dylib")
55         endif (NOT X11_GL_LIB)
56     else ()
57         set (X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
58         set (X11_GL_LIB ${OPENGL_gl_LIBRARY})
59     endif ()
60
61     include_directories (${X11_INCLUDE_DIR})
62 endif (NOT WIN32)
63
64 if (WIN32)
65     find_package (DirectX)
66 endif (WIN32)
67
68
69 ##############################################################################
70 # Set global build options
71
72 include (CheckCXXCompilerFlag)
73
74 if (WIN32)
75     # MSVC & MinGW only define & use APIENTRY
76     add_definitions (-DGLAPIENTRY=__stdcall)
77
78     # http://msdn.microsoft.com/en-us/library/aa383745.aspx
79     add_definitions (-D_WIN32_WINNT=0x0500 -DWINVER=0x0500)
80 else (WIN32)
81     CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
82     if (CXX_COMPILER_FLAG_VISIBILITY)
83         add_definitions ("-fvisibility=hidden")
84     endif (CXX_COMPILER_FLAG_VISIBILITY)
85 endif (WIN32)
86
87 if (MSVC)
88     # C99 includes for msvc
89     include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/msvc)
90
91     # Enable math constants defines
92     add_definitions (-D_USE_MATH_DEFINES)
93
94     # No min/max macros
95     add_definitions (-DNOMINMAX)
96
97     # Adjust warnings
98     add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
99     add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
100     add_definitions (-W4)
101     add_definitions (-wd4063) # not a valid value for switch of enum
102     add_definitions (-wd4127) # conditional expression is constant
103     add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
104     add_definitions (-wd4505) # unreferenced local function has been removed
105     add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
106     # XXX: it's safer to use ssize_t everywhere instead of disabling warning
107     add_definitions (-wd4018) # signed/unsigned mismatch
108     
109     # Use static runtime
110     # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
111     foreach (flag_var
112         CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
113         CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
114     )
115         if (${flag_var} MATCHES "/MD")
116             string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
117         endif (${flag_var} MATCHES "/MD")
118     endforeach (flag_var)
119 else ()
120     # Adjust warnings
121     add_definitions (-Wall)
122     # XXX: it's safer to use ssize_t everywhere instead of disabling warning
123     add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
124 endif ()
125
126
127 # Put all executables into the same top level build directory, regardless of
128 # which subdirectory they are declared
129 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
130
131
132 ##############################################################################
133 # Bundled dependencies
134 #
135 # We always use the bundled zlib, libpng, and snappy sources:
136 # - on Windows to make it easy to deploy the wrappers DLLs
137 # - on unices to prevent symbol collisions when tracing applications that link
138 # against other versions of these libraries
139
140 set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib)
141 set (ZLIB_LIBRARIES z_bundled)
142 add_subdirectory (thirdparty/zlib EXCLUDE_FROM_ALL)
143
144 include_directories (${ZLIB_INCLUDE_DIRS})
145 link_libraries (${ZLIB_LIBRARIES})
146
147 set (SNAPPY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/snappy)
148 set (SNAPPY_LIBRARIES snappy_bundled)
149 add_subdirectory (thirdparty/snappy EXCLUDE_FROM_ALL)
150
151 include_directories (${SNAPPY_INCLUDE_DIRS})
152 link_libraries (${SNAPPY_LIBRARIES})
153
154 set (PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpng)
155 set (PNG_DEFINITIONS "")
156 set (PNG_LIBRARIES png_bundled)
157
158 add_subdirectory (thirdparty/libpng EXCLUDE_FROM_ALL)
159 include_directories (${PNG_INCLUDE_DIR})
160 add_definitions (${PNG_DEFINITIONS})
161 link_libraries (${PNG_LIBRARIES})
162
163 # The Qt website provides binaries for Windows and MacOSX, and they are
164 # automatically found by cmake without any manual intervention.  The situation
165 # for QJSON is substantially different: there are no binaries for QJSON
166 # available, and there is no standard installation directory that is detected
167 # by cmake.
168 #
169 # By bundling the QJSON source, we make it much more easier to build the GUI on
170 # Windows and MacOSX.  But we only use the bundled sources when ENABLE_GUI is
171 # AUTO.
172 if (QT4_FOUND AND NOT QJSON_FOUND AND (ENABLE_GUI STREQUAL "AUTO"))
173     add_subdirectory (thirdparty/qjson EXCLUDE_FROM_ALL)
174     set (QJSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/qjson)
175     set (QJSON_LIBRARY_DIRS)
176     set (QJSON_LIBRARIES qjson_bundled)
177     set (QJSON_FOUND TRUE)
178 endif ()
179
180 # For glext headers
181 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty)
182
183
184 ##############################################################################
185 # Common libraries / utilities
186
187 include_directories (
188     ${CMAKE_CURRENT_SOURCE_DIR}
189     ${CMAKE_CURRENT_SOURCE_DIR}/common
190 )
191
192 add_custom_command (
193     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
194     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
195     DEPENDS glproc.py dispatch.py specs/wglapi.py specs/glxapi.py specs/cglapi.py specs/glapi.py specs/gltypes.py specs/stdapi.py
196 )
197
198 if (WIN32)
199     set (os os_win32.cpp)
200     set (glws_os glws_wgl.cpp)
201 else (WIN32)
202     set (os os_posix.cpp)
203     set (glws_os glws_glx.cpp)
204 endif (WIN32)
205
206 add_library (common STATIC
207     common/trace_file.cpp
208     common/trace_snappyfile.cpp
209     common/trace_model.cpp
210     common/trace_parser.cpp
211     common/trace_writer.cpp
212     common/trace_local_writer.cpp
213     common/trace_model_writer.cpp
214     common/trace_loader.cpp
215     common/image.cpp
216     common/image_bmp.cpp
217     common/image_pnm.cpp
218     common/image_png.cpp
219     common/${os}
220 )
221
222 set_target_properties (common PROPERTIES
223     # Ensure it can be statically linked in shared libraries
224     COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
225 )
226
227 link_libraries (common)
228
229 add_executable (tracedump tracedump.cpp)
230 install (TARGETS tracedump RUNTIME DESTINATION bin) 
231
232
233 ##############################################################################
234 # API tracers
235
236 if (WIN32)
237     if (MINGW)
238         # Silence warnings about @nn suffix mismatch
239         set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-stdcall-fixup")
240     endif (MINGW)
241
242     # ddraw.dll
243     if (DirectX_D3D_INCLUDE_DIR)
244         include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR})
245         add_custom_command (
246             OUTPUT ddrawtrace.cpp
247             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp
248             DEPENDS ddrawtrace.py trace.py specs/d3d.py specs/d3dtypes.py specs/d3dcaps.py specs/ddraw.py specs/winapi.py specs/stdapi.py
249         )
250         add_library (ddraw MODULE specs/ddraw.def ddrawtrace.cpp)
251         set_target_properties (ddraw
252             PROPERTIES PREFIX ""
253             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
254             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
255         )
256         install (TARGETS ddraw LIBRARY DESTINATION wrappers)
257     endif (DirectX_D3D_INCLUDE_DIR)
258
259     # d3d8.dll
260     if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
261         include_directories (SYSTEM ${DirectX_D3D8_INCLUDE_DIR} ${DirectX_D3DX9_INCLUDE_DIR})
262         add_custom_command (
263             OUTPUT d3d8trace.cpp
264             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp
265             DEPENDS d3d8trace.py trace.py specs/d3d8.py specs/d3d8types.py specs/d3d8caps.py specs/winapi.py specs/stdapi.py
266         )
267         add_library (d3d8 MODULE specs/d3d8.def d3d8trace.cpp d3dshader.cpp)
268         set_target_properties (d3d8
269             PROPERTIES PREFIX ""
270             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
271             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
272         )
273         install (TARGETS d3d8 LIBRARY DESTINATION wrappers)
274     endif (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
275
276     # d3d9.dll
277     if (DirectX_D3DX9_INCLUDE_DIR)
278         include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
279         add_custom_command (
280             OUTPUT d3d9trace.cpp
281             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp
282             DEPENDS d3d9trace.py trace.py specs/d3d9.py specs/d3d9types.py specs/d3d9caps.py specs/winapi.py specs/stdapi.py
283         )
284         add_library (d3d9 MODULE specs/d3d9.def d3d9trace.cpp d3dshader.cpp)
285         set_target_properties (d3d9
286             PROPERTIES PREFIX ""
287             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
288             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
289         )
290         install (TARGETS d3d9 LIBRARY DESTINATION wrappers)
291     endif (DirectX_D3DX9_INCLUDE_DIR)
292
293     # d3d10.dll
294     if (DirectX_D3D10_INCLUDE_DIR)
295         include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR})
296         add_custom_command (
297             OUTPUT d3d10trace.cpp
298             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
299             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
300         )
301         add_library (d3d10 MODULE specs/d3d10.def d3d10trace.cpp)
302         set_target_properties (d3d10
303             PROPERTIES PREFIX ""
304             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
305             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
306         )
307         install (TARGETS d3d10 LIBRARY DESTINATION wrappers)
308     endif (DirectX_D3D10_INCLUDE_DIR)
309
310     # d2d1.dll, dwrite.dll
311     if (DirectX_D2D1_INCLUDE_DIR)
312         include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
313
314         add_custom_command (
315             OUTPUT d2d1trace.cpp
316             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
317             DEPENDS d2d1trace.py trace.py specs/d2d1.py specs/d2d1.py specs/d2dbasetypes.py specs/d2derr.py specs/dwrite.py specs/dcommon.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
318         )
319         add_library (d2d1 MODULE specs/d2d1.def d2d1trace.cpp)
320         set_target_properties (d2d1
321             PROPERTIES PREFIX ""
322             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
323             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
324         )
325         install (TARGETS d2d1 LIBRARY DESTINATION wrappers)
326
327         add_custom_command (
328             OUTPUT dwritetrace.cpp
329             COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
330             DEPENDS dwritetrace.py trace.py specs/d2d1.py specs/d2d1.py specs/d2dbasetypes.py specs/d2derr.py specs/dwrite.py specs/dcommon.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
331         )
332         add_library (dwrite MODULE specs/dwrite.def dwritetrace.cpp)
333         set_target_properties (dwrite
334             PROPERTIES PREFIX ""
335             RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
336             LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
337         )
338         install (TARGETS dwrite LIBRARY DESTINATION wrappers)
339     endif (DirectX_D2D1_INCLUDE_DIR)
340
341     # opengl32.dll
342     add_custom_command (
343         OUTPUT wgltrace.cpp
344         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
345         DEPENDS wgltrace.py gltrace.py trace.py specs/wglapi.py specs/wglenum.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/winapi.py specs/stdapi.py
346     )
347     add_library (wgltrace MODULE specs/opengl32.def
348         wgltrace.cpp
349         glcaps.cpp
350         ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
351     )
352     set_target_properties (wgltrace PROPERTIES
353         PREFIX ""
354         OUTPUT_NAME opengl32
355         RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
356         LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
357     )
358     install (TARGETS wgltrace LIBRARY DESTINATION wrappers)
359
360 elseif (APPLE)
361     # OpenGL framework
362     add_custom_command (
363         OUTPUT cgltrace.cpp
364         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
365         DEPENDS cgltrace.py gltrace.py trace.py specs/cglapi.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/stdapi.py
366     )
367
368     add_library (cgltrace SHARED
369         cgltrace.cpp
370         glcaps.cpp
371         ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
372     )
373
374     set_target_properties (cgltrace PROPERTIES
375         # OpenGL framework name
376         PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
377         # Specificy the version and reexport GLU symbols
378         LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
379         RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
380         LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
381     )
382
383     target_link_libraries (cgltrace dl)
384
385     install (TARGETS cgltrace LIBRARY DESTINATION wrappers)
386 else ()
387     # libGL.so
388     add_custom_command (
389         OUTPUT glxtrace.cpp
390         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
391         DEPENDS glxtrace.py gltrace.py trace.py specs/glxapi.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/stdapi.py
392     )
393
394     add_library (glxtrace SHARED
395         ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
396         glxtrace.cpp
397         glcaps.cpp
398         glsnapshot.cpp
399     )
400
401     set_target_properties (glxtrace PROPERTIES
402         # avoid the default "lib" prefix
403         PREFIX ""
404     )
405
406     # Prevent symbol relocations internal to our wrapper library to be
407     # overwritten by the application.
408     set_target_properties (glxtrace PROPERTIES
409         LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
410     )
411
412     target_link_libraries (glxtrace dl ${X11_X11_LIB})
413
414     install (TARGETS glxtrace LIBRARY DESTINATION lib)
415 endif ()
416
417
418 ##############################################################################
419 # API retracers
420
421 add_custom_command (
422     OUTPUT glretrace_gl.cpp
423     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
424     DEPENDS glretrace.py retrace.py specs/glapi.py specs/gltypes.py specs/stdapi.py
425 )
426
427 add_custom_command (
428     OUTPUT glstate_params.cpp
429     COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp
430     DEPENDS glstate.py specs/glparams.py specs/gltypes.py specs/stdapi.py
431 )
432
433 include_directories (
434     ${CMAKE_CURRENT_BINARY_DIR}
435     ${OPENGL_INCLUDE_PATH}
436 )
437
438 add_executable (glretrace
439     glretrace_gl.cpp
440     glretrace_cgl.cpp
441     glretrace_glx.cpp
442     glretrace_wgl.cpp
443     glretrace_main.cpp
444     glstate.cpp
445     glstate_params.cpp
446     retrace.cpp
447     glws.cpp
448     ${glws_os}
449     ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
450 )
451
452 set_property (
453     TARGET glretrace
454     APPEND
455     PROPERTY COMPILE_DEFINITIONS "RETRACE"
456 )
457
458 target_link_libraries (glretrace
459     common
460 )
461
462 if (WIN32)
463     target_link_libraries (glretrace ${OPENGL_gl_LIBRARY})
464 elseif (APPLE)
465     # XXX: We use GLX on MacOSX, which is in a separate library.
466     target_link_libraries (glretrace
467         ${X11_GL_LIB}
468         ${X11_X11_LIB}
469         "-framework ApplicationServices" # CGS*
470         ${OPENGL_gl_LIBRARY} # CGL*
471     )
472 else ()
473     target_link_libraries (glretrace ${OPENGL_gl_LIBRARY} ${X11_X11_LIB})
474 endif ()
475
476 install (TARGETS glretrace RUNTIME DESTINATION bin) 
477
478
479 ##############################################################################
480 # GUI
481
482 if (ENABLE_GUI AND QT4_FOUND AND QJSON_FOUND)
483     add_subdirectory(gui)
484 endif ()
485
486
487 ##############################################################################
488 # Packaging
489
490 install (
491     FILES
492         BUGS.markdown
493         LICENSE
494         NEWS.markdown
495         README.markdown
496         TODO.markdown
497     DESTINATION doc)
498
499 set (CPACK_PACKAGE_VERSION_MAJOR "2")
500 set (CPACK_PACKAGE_VERSION_MINOR "0")
501
502 # Use current date in YYYYMMDD format as patch number 
503 execute_process (
504     COMMAND ${PYTHON_EXECUTABLE} -c "import time, sys; sys.stdout.write(time.strftime('%Y%m%d'))"
505     OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH
506 )
507
508 # See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
509 if (WIN32)
510     set (CPACK_GENERATOR "ZIP")
511 elseif (APPLE)
512     set (CPACK_GENERATOR "DragNDrop")
513 else ()
514     set (CPACK_GENERATOR "TBZ2")
515 endif ()
516
517 include(CPack)