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

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

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

  • Property svn:eol-style set to native
RevLine 
[6321]1
2# FIXME: For OS X, need flag for Framework or dylib
[9949]3IF(DYNAMIC_OPENSCENEGRAPH)
[6660]4    ADD_DEFINITIONS(-DOSGVIEWER_LIBRARY)
[9949]5ELSE()
[6660]6    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
[9949]7ENDIF()
[6321]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)
[9001]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    #
[9165]49    OPTION(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND "Set to ON if you have NVidia board and drivers earlier than 177.92 ver" OFF)
[9001]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)
[9949]53    ENDIF()
[9001]54
[7012]55    SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
[10813]56        ${HEADER_PATH}/api/Win32/GraphicsHandleWin32
[7012]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    )
[9949]65ELSE()
[6660]66    IF(APPLE)
[9879]67        SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
[9949]68    ELSE()
[8479]69        SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation. options only X11")
[9949]70    ENDIF()
[8479]71   
[9879]72    IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Cocoa")
[9949]73        ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION)
[7039]74        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
[10887]75            ${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa
[9879]76            ${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa
77            ${HEADER_PATH}/api/Cocoa/PixelBufferCocoa
[7039]78        )
79        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
[9879]80            GraphicsWindowCocoa.mm
81            DarwinUtils.h
82            DarwinUtils.mm
83            PixelBufferCocoa.mm
[7039]84        )
[9949]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}
[10813]89            ${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon
[9949]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()
[9363]108                SET(OSGVIEWER_USE_XRANDR OFF)
[9949]109            ENDIF()
110        ELSE()
111            SET(OSGVIEWER_USE_XRANDR OFF)
112        ENDIF()
[9363]113
[10703]114        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
[10813]115            ${HEADER_PATH}/api/X11/GraphicsHandleX11
[10703]116            ${HEADER_PATH}/api/X11/GraphicsWindowX11
117            ${HEADER_PATH}/api/X11/PixelBufferX11
118        )
[9363]119
[10703]120        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
121            GraphicsWindowX11.cpp
122            PixelBufferX11.cpp
123        )
[10813]124       
[9949]125        IF(OSGVIEWER_USE_XRANDR)
126            ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
127            SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XRANDR_INCLUDE_DIRS} )
[9548]128
[9949]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()
[9548]135
[9949]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})
[7727]147
[9949]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()
[8737]153
154
[6735]155ADD_LIBRARY(${LIB_NAME}
156    ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
[8211]157    ${LIB_PUBLIC_HEADERS}
158    ${LIB_PRIVATE_HEADERS}
[6735]159    ${LIB_COMMON_FILES}
160)
161
162
[6660]163LINK_INTERNAL(${LIB_NAME}     
164    osgGA
165    osgText
166    osgDB
167    osgUtil
168    osg
169    OpenThreads
[6321]170)
[6403]171
[9994]172LINK_EXTERNAL(${LIB_NAME} ${LIB_EXTRA_LIBS})
173
[6402]174LINK_CORELIB_DEFAULT(${LIB_NAME})
[6321]175
[6403]176IF(MINGW OR CYGWIN)
177    LINK_EXTERNAL(${LIB_NAME} gdi32 )
[9949]178ENDIF()
[6363]179
[6743]180INCLUDE(ModuleInstall OPTIONAL)
[6403]181
[9949]182FOREACH(INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
[6743]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}
[9342]188   COMPONENT libopenscenegraph-dev
[6743]189   )
[9949]190ENDFOREACH()
Note: See TracBrowser for help on using the browser.