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

Revision 9879, 6.9 kB (checked in by robert, 5 years ago)

From Stephan Huber, support for Cocoa windowing under OSX.

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