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

Revision 9424, 5.7 kB (checked in by robert, 5 years ago)

Added OPTIONAL into INCLUDE(FindPkgConfig?)

  • 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            ${XRANDR_INCLUDE_DIRS}
110        )
111        SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
112            GraphicsWindowX11.cpp
113            PixelBufferX11.cpp
114        )
115       
116        IF(OSGVIEWER_USE_XRANDR)
117            ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR)
118            SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} ${XRANDR_INCLUDE_DIRS})
119            LINK_LIBRARIES(Xrandr)
120        ENDIF(OSGVIEWER_USE_XRANDR)
121
122        # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
123        IF(APPLE)
124            # Find GL/glx.h
125            IF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
126                SET(OPENGL_INCLUDE_DIR /usr/X11/include)
127                SET(OPENGL_LIBRARIES /usr/X11/lib/libGL.dylib)
128            ELSEIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11R6/include/GL/glx.h)
129                SET(OPENGL_INCLUDE_DIR /usr/X11R6/include)
130                SET(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib)
131            ENDIF(EXISTS ${CMAKE_OSX_SYSROOT}/usr/X11/include/GL/glx.h)
132            INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OPENGL_INCLUDE_DIR})
133
134            SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${OPENGL_LIBRARIES} ${LIB_EXTRA_LIBS})
135            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")
136        ENDIF(APPLE)
137           
138
139    ENDIF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
140
141ENDIF(WIN32)
142
143
144ADD_LIBRARY(${LIB_NAME}
145    ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
146    ${LIB_PUBLIC_HEADERS}
147    ${LIB_PRIVATE_HEADERS}
148    ${LIB_COMMON_FILES}
149)
150
151
152LINK_INTERNAL(${LIB_NAME}     
153    osgGA
154    osgText
155    osgDB
156    osgUtil
157    osg
158    OpenThreads
159    ${LIB_EXTRA_LIBS}
160)
161
162LINK_CORELIB_DEFAULT(${LIB_NAME})
163
164IF(MINGW OR CYGWIN)
165    LINK_EXTERNAL(${LIB_NAME} gdi32 )
166ENDIF(MINGW OR CYGWIN)
167
168INCLUDE(ModuleInstall OPTIONAL)
169
170FOREACH( INCLUDEFILE ${LIB_PUBLIC_HEADERS} )
171   FILE(RELATIVE_PATH REL_INCLUDEFILE ${HEADER_PATH} ${INCLUDEFILE})
172   GET_FILENAME_COMPONENT(REL_INCLUDE_PATH ${REL_INCLUDEFILE} PATH)
173   INSTALL(
174   FILES        ${INCLUDEFILE}
175   DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}/${REL_INCLUDE_PATH}
176   COMPONENT libopenscenegraph-dev
177   )
178ENDFOREACH( INCLUDEFILE)
Note: See TracBrowser for help on using the browser.