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

Revision 9949, 6.1 kB (checked in by robert, 6 years ago)

From Philip Lowman, "Here's the promised cleanup of the OSG's CMakeLists.txt files for the src/ folder. I'll submit the others separately.

Also, there was also a small bug in osgDB's CMakeLists.txt that was causing an error when I tested with CMake 2.4.4.

IF(${OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX} STREQUAL "quicktime")
was changed to
IF(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX STREQUAL "quicktime")
"

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