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

Revision 9548, 5.7 kB (checked in by robert, 6 years ago)

Moved the XRANDR include into LIB_PRIVATE_HEADERS to avoid FreeBSD build problem

  • 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 (DYNAMIC_OPENSCENEGRAPH)
6    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
7ENDIF(DYNAMIC_OPENSCENEGRAPH)
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)
38
39SET(LIB_EXTRA_LIBS)
40
41IF(WIN32)
42
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(OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND)
54
55    SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
56        ${HEADER_PATH}/api/Win32/GraphicsWindowWin32
57        ${HEADER_PATH}/api/Win32/PixelBufferWin32
58    )
59       
60    SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
61        GraphicsWindowWin32.cpp
62        PixelBufferWin32.cpp
63    )
64
65ELSE(WIN32)
66
67    IF(APPLE)
68        SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon or X11.")
69    ELSE(APPLE)
70        SET(OSG_WINDOWING_SYSTEM "X11" CACHE STRING "Windowing system type for graphics window creation. options only X11")
71    ENDIF(APPLE)
72   
73
74    IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
75
76        # FIXME: OS X needs selection mechanism for Cocoa, Carbon, X11
77        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
78            ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
79            ${HEADER_PATH}/api/Carbon/PixelBufferCarbon
80        )
81        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
82            GraphicsWindowCarbon.cpp
83            PixelBufferCarbon.cpp
84        )
85
86    ELSE(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
87
88        # X11 for everybody else
89
90
91        INCLUDE(FindPkgConfig OPTIONAL)
92        IF (PKG_CONFIG_FOUND)
93
94            PKG_CHECK_MODULES(XRANDR xrandr)
95           
96            IF (XRANDR_FOUND)
97                OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support for GraphicsWindowX11." ON)
98            ELSE(XRANDR_FOUND)
99                SET(OSGVIEWER_USE_XRANDR OFF)
100            ENDIF (XRANDR_FOUND)
101        ELSE(PKG_CONFIG_FOUND)
102            SET(OSGVIEWER_USE_XRANDR OFF)
103        ENDIF(PKG_CONFIG_FOUND)
104
105
106        SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
107            ${HEADER_PATH}/api/X11/GraphicsWindowX11
108            ${HEADER_PATH}/api/X11/PixelBufferX11
109        )
110
111
112        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
113            GraphicsWindowX11.cpp
114            PixelBufferX11.cpp
115        )
116       
117        IF(OSGVIEWER_USE_XRANDR)
118            ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
119            SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XRANDR_INCLUDE_DIRS} )
120            LINK_LIBRARIES(Xrandr)
121        ENDIF(OSGVIEWER_USE_XRANDR)
122
123        # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
124        IF(APPLE)
125            # Find GL/glx.h
126            IF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
127                SET(OPENGL_INCLUDE_DIR /usr/X11/include)
128                SET(OPENGL_LIBRARIES /usr/X11/lib/libGL.dylib)
129            ELSEIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11R6/include/GL/glx.h)
130                SET(OPENGL_INCLUDE_DIR /usr/X11R6/include)
131                SET(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib)
132            ENDIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
133            INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OPENGL_INCLUDE_DIR})
134
135            SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${OPENGL_LIBRARIES} ${LIB_EXTRA_LIBS})
136            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")
137        ENDIF(APPLE)
138           
139
140    ENDIF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
141
142ENDIF(WIN32)
143
144
145ADD_LIBRARY(${LIB_NAME}
146    ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
147    ${LIB_PUBLIC_HEADERS}
148    ${LIB_PRIVATE_HEADERS}
149    ${LIB_COMMON_FILES}
150)
151
152
153LINK_INTERNAL(${LIB_NAME}     
154    osgGA
155    osgText
156    osgDB
157    osgUtil
158    osg
159    OpenThreads
160    ${LIB_EXTRA_LIBS}
161)
162
163LINK_CORELIB_DEFAULT(${LIB_NAME})
164
165IF(MINGW OR CYGWIN)
166    LINK_EXTERNAL(${LIB_NAME} gdi32 )
167ENDIF(MINGW OR CYGWIN)
168
169INCLUDE(ModuleInstall OPTIONAL)
170
171FOREACH( INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
172   FILE(RELATIVE_PATH REL_INCLUDEFILE ${HEADER_PATH} ${INCLUDEFILE})
173   GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH)
174   INSTALL(
175   FILES        ${INCLUDEFILE}
176   DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH}
177   COMPONENT libopenscenegraph-dev
178   )
179ENDFOREACH( INCLUDEFILE)
Note: See TracBrowser for help on using the browser.