root/OpenSceneGraph/trunk/src/osgViewer/CMakeLists.txt @ 11273

Revision 10887, 6.4 kB (checked in by robert, 8 years ago)

From Stephan Huber, "attached you'll find the missing GraphicsHandleCocoa?-implementation."

  • Property svn:eol-style set to native
Line 
1
2# FIXME: For OS X, need flag for Framework or dylib
3IF(DYNAMIC_OPENSCENEGRAPH)
4    ADD_DEFINITIONS(-DOSGVIEWER_LIBRARY)
5ELSE()
6    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
7ENDIF()
8
9SET(LIB_NAME osgViewer)
10
11SET(HEADER_PATH ${OpenSceneGraph_SOURCE_DIR}/include/${LIB_NAME})
12SET(LIB_PUBLIC_HEADERS
13    ${HEADER_PATH}/CompositeViewer
14    ${HEADER_PATH}/Export
15    ${HEADER_PATH}/GraphicsWindow
16    ${HEADER_PATH}/Renderer
17    ${HEADER_PATH}/Scene
18    ${HEADER_PATH}/Version
19    ${HEADER_PATH}/View
20    ${HEADER_PATH}/Viewer
21    ${HEADER_PATH}/ViewerBase
22    ${HEADER_PATH}/ViewerEventHandlers
23)
24
25SET(LIB_COMMON_FILES
26    CompositeViewer.cpp
27    HelpHandler.cpp
28    Renderer.cpp
29    Scene.cpp
30    ScreenCaptureHandler.cpp
31    StatsHandler.cpp
32    Version.cpp
33    View.cpp
34    Viewer.cpp
35    ViewerBase.cpp
36    ViewerEventHandlers.cpp
37    ${OPENSCENEGRAPH_VERSIONINFO_RC}
38)
39
40SET(LIB_EXTRA_LIBS)
41
42IF(WIN32)
43    #
44    # Enable workaround for OpenGL driver issues when used in multithreaded/multiscreen with NVidia drivers on Windows XP
45    # For example: osgviewer dumptruck.osg was showing total garbage (screen looked like shattered, splashed hedgehog)
46    # There were also serious issues with render to texture cameras.
47    # Workaround repeats makeCurrentContext call as it was found that this causes the problems to dissapear.
48    #
49    OPTION(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND "Set to ON if you have NVidia board and drivers earlier than 177.92 ver" OFF)
50    MARK_AS_ADVANCED(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
51    IF(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
52        ADD_DEFINITIONS(-DOSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
53    ENDIF()
54
55    SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
56        ${HEADER_PATH}/api/Win32/GraphicsHandleWin32
57        ${HEADER_PATH}/api/Win32/GraphicsWindowWin32
58        ${HEADER_PATH}/api/Win32/PixelBufferWin32
59    )
60       
61    SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
62        GraphicsWindowWin32.cpp
63        PixelBufferWin32.cpp
64    )
65ELSE()
66    IF(APPLE)
67        SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
68    ELSE()
69        SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation. options only X11")
70    ENDIF()
71   
72    IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Cocoa")
73        ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION)
74        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
75            ${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa
76            ${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa
77            ${HEADER_PATH}/api/Cocoa/PixelBufferCocoa
78        )
79        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
80            GraphicsWindowCocoa.mm
81            DarwinUtils.h
82            DarwinUtils.mm
83            PixelBufferCocoa.mm
84        )
85    SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS})
86    ELSEIF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
87        ADD_DEFINITIONS(-DUSE_DARWIN_CARBON_IMPLEMENTATION)
88        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
89            ${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon
90            ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
91            ${HEADER_PATH}/api/Carbon/PixelBufferCarbon
92        )
93        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
94            GraphicsWindowCarbon.cpp
95            DarwinUtils.h
96            DarwinUtils.mm
97            PixelBufferCarbon.cpp
98        )
99        SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS})
100    ELSE()
101        # X11 for everybody else
102        INCLUDE(FindPkgConfig OPTIONAL)
103        IF(PKG_CONFIG_FOUND)
104            PKG_CHECK_MODULES(XRANDR xrandr)
105            IF(XRANDR_FOUND)
106                OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support for GraphicsWindowX11." ON)
107            ELSE()
108                SET(OSGVIEWER_USE_XRANDR OFF)
109            ENDIF()
110        ELSE()
111            SET(OSGVIEWER_USE_XRANDR OFF)
112        ENDIF()
113
114        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
115            ${HEADER_PATH}/api/X11/GraphicsHandleX11
116            ${HEADER_PATH}/api/X11/GraphicsWindowX11
117            ${HEADER_PATH}/api/X11/PixelBufferX11
118        )
119
120        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
121            GraphicsWindowX11.cpp
122            PixelBufferX11.cpp
123        )
124       
125        IF(OSGVIEWER_USE_XRANDR)
126            ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
127            SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XRANDR_INCLUDE_DIRS} )
128
129            IF(X11_Xrandr_LIB)
130                SET(LIB_EXTRA_LIBS ${X11_Xrandr_LIB} ${LIB_EXTRA_LIBS})
131            ELSE()
132                SET(LIB_EXTRA_LIBS ${XRANDR_LIBRARIES} ${LIB_EXTRA_LIBS})
133            ENDIF()
134        ENDIF()
135
136        # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
137        IF(APPLE)
138            # Find GL/glx.h
139            IF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
140                SET(OPENGL_INCLUDE_DIR /usr/X11/include)
141                SET(OPENGL_LIBRARIES /usr/X11/lib/libGL.dylib)
142            ELSEIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11R6/include/GL/glx.h)
143                SET(OPENGL_INCLUDE_DIR /usr/X11R6/include)
144                SET(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib)
145            ENDIF()
146            INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OPENGL_INCLUDE_DIR})
147
148            SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${OPENGL_LIBRARIES} ${LIB_EXTRA_LIBS})
149            SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib")
150        ENDIF(APPLE)
151    ENDIF()
152ENDIF()
153
154
155ADD_LIBRARY(${LIB_NAME}
156    ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
157    ${LIB_PUBLIC_HEADERS}
158    ${LIB_PRIVATE_HEADERS}
159    ${LIB_COMMON_FILES}
160)
161
162
163LINK_INTERNAL(${LIB_NAME}     
164    osgGA
165    osgText
166    osgDB
167    osgUtil
168    osg
169    OpenThreads
170)
171
172LINK_EXTERNAL(${LIB_NAME} ${LIB_EXTRA_LIBS})
173
174LINK_CORELIB_DEFAULT(${LIB_NAME})
175
176IF(MINGW OR CYGWIN)
177    LINK_EXTERNAL(${LIB_NAME} gdi32 )
178ENDIF()
179
180INCLUDE(ModuleInstall OPTIONAL)
181
182FOREACH(INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
183   FILE(RELATIVE_PATH REL_INCLUDEFILE ${HEADER_PATH} ${INCLUDEFILE})
184   GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH)
185   INSTALL(
186   FILES        ${INCLUDEFILE}
187   DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH}
188   COMPONENT libopenscenegraph-dev
189   )
190ENDFOREACH()
Note: See TracBrowser for help on using the browser.