source: osgVisual/CMakeLists.txt @ 65

Last change on this file since 65 was 65, checked in by Torben Dannhauer, 14 years ago

new cluster implementation added: ENet
ENet is a reliable UDP implementation with quite simple usage and high performance for transmission with small or medium size packet.

File size: 15.0 KB
Line 
1#################################################################################################
2# This file allows to configure osgVisual with CMAKE to generate native build solutions.                #
3#                                                                                                                                                                                               #
4# Specify the following environment variables to use osgVisual and this CMAKE script:                   #
5#       * OSG_ROOT: Path to your 32 bit (x86) OSG, e.g. D:\OSG\OpenSceneGraph-2.9.8_x86                         #
6#       * OSG_ROOT_X64: Path to your 64 bit (x64) OSG, e.g. D:\OSG\OpenSceneGraph-2.9.8_x64                     #
7#       * OSG: Path to your 32 bit (x86) OSG and 3rdParty binary folder,                                                        #
8#                e.g. %OSG_ROOT%\bin;D:\OSG\3rdParty\bin\x86                                                                                    #
9#       * OSG_X64: Path to your 64 bit (x64) OSG and 3rdParty binary folder,                                            #
10#                e.g. %OSG_ROOT_X64%\bin;D:\OSG\3rdParty\bin\x64                                                                                #
11#       * PATH: Extend with %OSG% or %OSG_X64% to use OSG and osgVisual from command line,                      #
12#                e.g. PATH=%PATH%;%OSG%                                                                                                                                 #
13#                                                                                                                                                                                               #
14#       NOTE:   On Visual Studio and x64 Arch, CMAKE uses the project settings to specify the           #
15#                       correct x64 OSG path, so you can use osg as 32 bit in your system path.                         #
16#                                                                                                                                                                                               #
17#                                                                                                                                                                                               #
18#################################################################################################
19
20cmake_minimum_required(VERSION 2.8)
21
22
23PROJECT(osgVisual)
24#SET(CMAKE_MODULE_PATH "${osgVisual_SOURCE_DIR}/../CMakeModules;${CMAKE_MODULE_PATH}")
25
26#INCLUDE( CheckTypeSize )
27#CHECK_TYPE_SIZE( "void*" SIZE_OF_VOID_P )
28IF( CMAKE_SIZEOF_VOID_P EQUAL 4 )
29    MESSAGE( STATUS "32 bit architecture detected" )
30    SET(DESTINATION_ARCH "x86")
31ENDIF()
32IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
33    MESSAGE( STATUS "64 bit architecture detected" )
34    SET(DESTINATION_ARCH "x64")
35ENDIF()
36
37
38# Get OSG Settings
39IF(DESTINATION_ARCH STREQUAL "x64")
40        SET(OSG_ROOT_BKP $ENV{OSG_ROOT})        # BACKUP old OSG_ROOT
41        SET(ENV{OSG_ROOT} $ENV{OSG_ROOT_X64})   # Replace OSGROOT with OSG_ROOT_X64 to force CMAKE to find the correct OSG version (64 bit)
42ENDIF ()
43
44SET(OpenSceneGraph_MARK_AS_ADVANCED ON)
45FIND_PACKAGE(OpenSceneGraph 2.9.8 REQUIRED osgViewer OpenThreads osgDB osgTerrain osgGA osgText osgSim osgUtil)
46FIND_PACKAGE(OpenGL REQUIRED)
47
48IF(DESTINATION_ARCH STREQUAL "x64")
49        SET(ENV{OSG_ROOT} ${OSG_ROOT_BKP})      # Restore old OSG_ROOT
50        UNSET(OSG_ROOT_BKP)                                     # Delete backup
51ENDIF ()
52
53
54
55# Module sky-silverlining - At the moment only for Win32, will be opened to Unix ASAP
56# OPTION( OPTION_VAR "description string" [initial value] )
57IF ( WIN32 )
58       
59        SET(USE_SKY_SILVERLINING ON CACHE BOOL "Enable to use Sundog-soft's Silverlining SDK for sky & weather")
60        IF(USE_SKY_SILVERLINING )
61                SET(SOURCES
62                        ${SOURCES}
63                        include/sky_Silverlining/skySilverLining_AtmosphereReference.h
64                        include/sky_Silverlining/skySilverlining_cloudLayerSlot.h
65                        include/sky_Silverlining/skySilverLining_cloudsDrawable.h
66                        include/sky_Silverlining/skySilverLining_ProjectionMatrixCallback.h
67                        include/sky_Silverlining/skySilverLining_skyDrawable.h
68                        include/sky_Silverlining/visual_skySilverLining.h
69                        src/sky_Silverlining/skySilverLining_cloudsDrawable.cpp
70                        src/sky_Silverlining/skySilverLining_skyDrawable.cpp
71                        src/sky_Silverlining/visual_skySilverLining.cpp                 
72                )
73               
74                IF (DESTINATION_ARCH STREQUAL "x86")
75                        SET(SILVERLINING_ARCH "win32")
76                ELSEIF ( DESTINATION_ARCH STREQUAL "x64" )
77                        SET(SILVERLINING_ARCH "x64")
78                ENDIF ()
79                SET(SILVERLINING_LIBRARY_RELEASE $ENV{SILVERLINING_PATH}\\lib\\vc9\\${SILVERLINING_ARCH}\\SilverLining-MT-DLL.lib CACHE FILEPATH "Select the release library of Sundog-Soft's Silverlining SDK to link against." )
80                SET(SILVERLINING_LIBRARY_DEBUG $ENV{SILVERLINING_PATH}\\lib\\vc9\\${SILVERLINING_ARCH}\\SilverLining-MTD-DLL.lib CACHE FILEPATH "Select the debug library of Sundog-Soft's Silverlining SDK to link against." )
81                SET(SILVERLINING_INCLUDE_DIR "$ENV{SILVERLINING_PATH}\\Public Headers" CACHE PATH "Enter the path to the the public Include directory of Sundog-Soft's Silverlining SDK" )
82                SET(SILVERLINING_LICENSEE "Your user name" CACHE STRING "Enter your Silverlining licensee name. If you license available, osgVisual will work with silverlining as 5 minute demo with the default value." )
83                SET(SILVERLINING_LICENSE "Your license code" CACHE STRING "Enter your Silverlining license key. If you license available, osgVisual will work with silverlining as 5 minute demo with the default value." )
84                INCLUDE_DIRECTORIES(${SILVERLINING_INCLUDE_DIR} include/sky_Silverlining)
85                ADD_DEFINITIONS( "-DUSE_SKY_SILVERLINING" )
86                ADD_DEFINITIONS( "-DSILVERLINING_LICENSEE=\"${SILVERLINING_LICENSEE}\"" )
87                ADD_DEFINITIONS( "-DSILVERLINING_LICENSE=\"${SILVERLINING_LICENSE}\"" )
88               
89        ELSE(USE_SKY_SILVERLINING)
90                UNSET(SILVERLINING_LIBRARY_RELEASE CACHE)
91                UNSET(SILVERLINING_LIBRARY_DEBUG CACHE)
92                UNSET(SILVERLINING_INCLUDE_DIR CACHE)
93                UNSET(SILVERLINING_LICENSEE)
94                UNSET(SILVERLINING_LICENSE)
95        ENDIF(USE_SKY_SILVERLINING)
96ENDIF(WIN32)
97
98
99# Module distortion
100SET(USE_DISTORTION OFF CACHE BOOL "Enable to use distortion with Projection Designer's distortion maps")
101IF(USE_DISTORTION)
102        SET(SOURCES
103                ${SOURCES}
104                include/distortion/visual_distortion.h
105                src/distortion/visual_distortion.cpp
106        )
107        INCLUDE_DIRECTORIES(include/distortion)
108        ADD_DEFINITIONS( "-DUSE_DISTORTION" )
109ENDIF(USE_DISTORTION)
110
111
112# Module Vista2D - Only available under Win32
113if( WIN32 )
114        SET(USE_VISTA2D OFF CACHE BOOL "Enable to use Vista2D by Wetzel Technology")
115        IF( USE_VISTA2D )
116                INCLUDE_DIRECTORIES( include/vista2D )
117                SET(SOURCES
118                        ${SOURCES}
119                        include/vista2D/visual_vista2D.h
120                        src/vista2D/visual_vista2D.cpp 
121                )
122                SET(VISTA2D_INCLUDE_DIR . CACHE PATH "Select the INCLUDE directory path for Vista2D by Wetzel Technology." )
123                SET(VISTA2D_LIBRARY_DEBUG . CACHE FILEPATH "Select debug LIBRARY path for linking against Vista2D by Wetzel Technology." )
124                SET(VISTA2D_LIBRARY_RELEASE . CACHE FILEPATH "Select release LIBRARY path for linking against Vista2D by Wetzel Technology." )
125                INCLUDE_DIRECTORIES(${VISTA2D_INCLUDE_DIR})
126                ADD_DEFINITIONS( "-DUSE_VISTA2D" )
127        ELSE(USE_VISTA2D)
128                UNSET(VISTA2D_INCLUDE_DIR CACHE)
129                UNSET(VISTA2D_LIBRARY_DEBUG CACHE)
130                UNSET(VISTA2D_LIBRARY_RELEASE CACHE)
131        ENDIF(USE_VISTA2D)
132ENDIF(WIN32)
133
134
135# Module Spacenavigator manipulator - ONLY under WIN32
136if( WIN32 )
137        # No header or linking required, because WIN32 COM interface used.
138        SET(USE_SPACEMOUSE ON CACHE BOOL "Enable to use camera manipulator based on Spacenavigator by 3DConnexion")
139        IF( USE_SPACEMOUSE )
140                SET(SOURCES
141                        ${SOURCES}
142                        include/manip_Spacemouse/manip_spaceMouse.h
143                        include/manip_Spacemouse/manip_freeSpaceMouse.h
144                        include/manip_Spacemouse/manip_nodeTrackerSpaceMouse.h
145                        src/manip_Spacemouse/manip_spaceMouse.cpp
146                        src/manip_Spacemouse/manip_freeSpaceMouse.cpp
147                        src/manip_Spacemouse/manip_nodeTrackerSpaceMouse.cpp
148                )
149                INCLUDE_DIRECTORIES(include/manip_Spacemouse)
150                ADD_DEFINITIONS( "-DUSE_SPACENAVIGATOR" )
151        ENDIF(USE_SPACEMOUSE)
152ENDIF(WIN32)
153
154
155# Module cluster
156SET(USE_CLUSTER_UDP OFF CACHE BOOL "Enable to use the UDP Implementation for the cluster interface")
157SET(USE_CLUSTER_ASIO_TCP_IOSTREAM OFF CACHE BOOL "Enable to use the Boost ASIO TCP iostream implementation for the cluster interface")
158SET(USE_CLUSTER_ENET ON CACHE BOOL "Enable to use the ENet reliable UDP library implementation for the cluster interface")
159IF( USE_CLUSTER_UDP   )
160                SET(SOURCES
161                        ${SOURCES}
162                        include/cluster/dataIO_cluster.h
163                        include/cluster/dataIO_clusterUDP.h
164                        include/cluster/dataIO_clusterUDP_Transmission.h
165                        src/cluster/dataIO_clusterUDP.cpp
166                        src/cluster/dataIO_clusterUDP_Transmission.cpp
167                )
168                ADD_DEFINITIONS( "-DUSE_CLUSTER_UDP" )
169ENDIF()
170
171IF( USE_CLUSTER_ASIO_TCP_IOSTREAM )
172                SET(SOURCES
173                        ${SOURCES}
174                        include/cluster/dataIO_cluster.h
175                        include/cluster/dataIO_clusterAsioTcpIostream.h
176                        src/cluster/dataIO_clusterAsioTcpIostream.cpp
177                )
178                ADD_DEFINITIONS( "-DUSE_CLUSTER_ASIO_TCP_IOSTREAM" )
179                ADD_DEFINITIONS( "-D_WIN32_WINNT=0x0501" )
180                SET(BOOST_LIBRARY_PATH "../../3rdParty_x86_x64/lib/${DESTINATION_ARCH}/" CACHE PATH "Select the library folder of Boost libraries to link against." )
181                SET(BOOST_INCLUDE_DIR "../../3rdParty_x86_x64/include/boost-1.43.0/" CACHE PATH "Enter the path to the the include directory of Boost" )
182                INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIR})
183                LINK_DIRECTORIES(${BOOST_LIBRARY_PATH})
184ELSE()
185                UNSET(BOOST_LIBRARY_PATH CACHE)
186                UNSET(BOOST_ASIO_INCLUDE_DIR CACHE)     
187ENDIF()
188
189IF( USE_CLUSTER_ENET )
190                SET(SOURCES
191                        ${SOURCES}
192                        include/cluster/dataIO_cluster.h
193                        include/cluster/dataIO_clusterENet.h
194                        src/cluster/dataIO_clusterENet.cpp
195                        include/cluster/dataIO_clusterENet_implementation.h
196                        src/cluster/dataIO_clusterENet_implementation.cpp
197                        src/cluster/enet/callbacks.c
198                        src/cluster/enet/compress.c
199                        src/cluster/enet/host.c
200                        src/cluster/enet/list.c
201                        src/cluster/enet/packet.c
202                        src/cluster/enet/peer.c
203                        src/cluster/enet/protocol.c
204                        src/cluster/enet/unix.c
205                        src/cluster/enet/win32.c
206                        include/cluster/enet/callbacks.h
207                        include/cluster/enet/enet.h
208                        include/cluster/enet/list.h
209                        include/cluster/enet/protocol.h
210                        include/cluster/enet/time.h
211                        include/cluster/enet/types.h
212                        include/cluster/enet/unix.h
213                        include/cluster/enet/utility.h
214                        include/cluster/enet/win32.h
215                )
216                ADD_DEFINITIONS( "-DUSE_CLUSTER_ENET" )
217               
218ENDIF()
219
220IF(NOT USE_CLUSTER_UDP AND NOT USE_CLUSTER_ASIO_TCP_IOSTREAM AND NOT USE_CLUSTER_ENET)
221                SET(SOURCES
222                        ${SOURCES}
223                        include/cluster/dataIO_cluster.h
224                        include/cluster/dataIO_clusterDummy.h
225                        src/cluster/dataIO_clusterDummy.cpp
226                )
227                ADD_DEFINITIONS( "-DUSE_CLUSTER_DUMMY" )
228ENDIF()
229
230
231# Module extLink
232SET(SOURCES
233        ${SOURCES}
234        include/extLink/dataIO_extLink.h
235        include/extLink/manip_extLink.h
236        src/extLink/manip_extLink.cpp
237)
238IF ( WIN32 )
239        SET(USE_EXTLINK_VCL ON CACHE BOOL "Enable to use the VCL Implementation for the externalLink interface")
240        IF( USE_EXTLINK_VCL )
241                SET(EXTLINK_VCL_INCLUDE_DIR ../VCL_1.0.3.4/source/include/VCL CACHE PATH "Select the INCLUDE directory path for extLink VCL Implementation." )
242                SET(SOURCES
243                        ${SOURCES}
244                        include/extLink/dataIO_extLinkVCL.h
245                        src/extLink/dataIO_extLinkVCL.cpp
246                )
247                INCLUDE_DIRECTORIES(${EXTLINK_VCL_INCLUDE_DIR})
248                ADD_DEFINITIONS( "-DUSE_EXTLINK_VCL" )
249                #Linking: VCL uses #pragma to link, no need for linking configuration in CMAKE
250        ELSE(USE_EXTLINK_VCL)
251                SET(SOURCES
252                        ${SOURCES}
253                        include/extLink/dataIO_extLinkDummy.h
254                        src/extLink/dataIO_extLinkDummy.cpp
255                )
256                UNSET(EXTLINK_VCL_INCLUDE_DIR CACHE)
257                ADD_DEFINITIONS( "-DUSE_EXTLINK_DUMMY" )
258        ENDIF(USE_EXTLINK_VCL)
259ELSE(WIN32)
260        UNSET(EXTLINK_VCL_INCLUDE_DIR CACHE)
261        SET(SOURCES
262                ${SOURCES}
263                include/extLink/dataIO_extLinkDummy.h
264                src/extLink/dataIO_extLinkDummy.cpp
265        )
266        ADD_DEFINITIONS( "-DUSE_EXTLINK_DUMMY" )
267ENDIF(WIN32)
268
269
270
271# Set core sources
272SET(SOURCES
273        ${SOURCES}
274        # Core
275        include/core/visual_core.h
276        src/core/visual_core.cpp
277        src/core/osgVisual.cpp
278        # Util
279        include/util/visual_util.h
280        src/util/visual_util.cpp
281        # Draw 2D
282        include/draw2D/visual_draw2D.h
283        src/draw2D/visual_draw2D.cpp
284        # Debug HUD
285        include/draw2D/visual_debug_hud.h
286        src/draw2D/visual_debug_hud.cpp
287        # Example HUD
288        include/draw2D/visual_hud.h
289        src/draw2D/visual_hud.cpp
290        # Draw 3D
291        include/draw3D/visual_draw3D.h
292        src/draw3D/visual_draw3D.cpp
293        # Object Mounted Manipulator
294        include/manip_ObjectMounted/manip_objectMounted.h
295        src/manip_ObjectMounted/manip_objectMounted.cpp
296        # Objects
297        include/object/visual_object.h
298        include/object/object_updater.h
299        src/object/visual_object.cpp
300        src/object/object_updater.cpp
301        # DataIO
302        include/dataIO/visual_dataIO.h
303        include/dataIO/dataIO_transportContainer.h
304        include/dataIO/dataIO_slot.h
305        include/dataIO/dataIO_executer.h
306        src/dataIO/visual_dataIO.cpp
307        src/dataIO/dataIO_transportContainer.cpp
308        src/dataIO/dataIO_slot.cpp
309        src/dataIO/dataIO_executer.cpp
310)
311
312INCLUDE_DIRECTORIES(include/core include/util include/draw2D include/draw3D include/object include/manip_ObjectMounted)
313INCLUDE_DIRECTORIES(include/dataIO include/cluster include/extLink ${OPENSCENEGRAPH_INCLUDE_DIRS} .)
314
315
316# Executable Output
317SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
318ADD_EXECUTABLE(osgVisual ${SOURCES})
319
320
321# Linking
322TARGET_LINK_LIBRARIES(osgVisual ${OPENSCENEGRAPH_LIBRARIES} "OpenGL32.lib")
323IF(USE_SKY_SILVERLINING )
324        TARGET_LINK_LIBRARIES(osgVisual "winmm.lib" debug ${SILVERLINING_LIBRARY_DEBUG} optimized ${SILVERLINING_LIBRARY_RELEASE})
325ENDIF(USE_SKY_SILVERLINING)
326               
327IF(USE_VISTA2D)
328        TARGET_LINK_LIBRARIES(osgVisual  debug ${VISTA2D_LIBRARY_DEBUG} optimized ${VISTA2D_LIBRARY_RELEASE})
329ENDIF(USE_VISTA2D)
330
331IF(USE_CLUSTER_ENET)
332        TARGET_LINK_LIBRARIES(osgVisual "winmm.lib" "ws2_32.lib" )
333ENDIF(USE_CLUSTER_ENET)
334
335# CMAKE Fix for VS to not prepend build type to path.
336SET_TARGET_PROPERTIES(osgVisual PROPERTIES PREFIX "../")
337SET_TARGET_PROPERTIES( osgVisual PROPERTIES DEBUG_POSTFIX d )
338
339
340# Generating vcproj file, if MSVC to preset debugging parameter  - based on http://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test
341IF (MSVC)
342    # Set up a default .user file that contains the debugging setup
343    ## Find user and system name
344        SET(SYSTEM_NAME $ENV{USERDOMAIN} CACHE STRING "Build System Name")
345        SET(USER_NAME $ENV{USERNAME} CACHE STRING "Build System UserName")
346        SET(USERFILE_COMMAND_DEBUG "$(TargetPath)" CACHE STRING "Command to execute on debugging (VS Project settings)" )
347        SET(USERFILE_WORKING_DIRECTORY_DEBUG "bin" CACHE STRING "Working directory on debugging (VS Project settings)" )
348        SET(USERFILE_COMMAND_ARGUMENTS_DEBUG "-C center --window 100 100 800 600 -m D:/OpenSceneGraph/VPB-Testdatensatz/DB_Small/database.ive -p salzburg.path" CACHE STRING "Command arguments (VS Project settings)" )
349        SET(USERFILE_REMOTE_MACHINE_DEBUG ${USER_NAME} CACHE STRING "Remote Debugging Machine (VS Project settings)")
350        IF (DESTINATION_ARCH STREQUAL "x64")
351                SET(USERFILE_ENVIRONMENT "PATH=%OSG_X64%;%PATH%" CACHE STRING "Environment Variables that VS should merge on thy fly with system environment to run osgVisual (VS Project settings)")
352        ENDIF ()
353
354
355    # Only do this if one doesn't already exist
356    SET (USER_FILE ${PROJECT_NAME}.vcproj.${SYSTEM_NAME}.${USER_NAME}.user)
357    IF (NOT EXISTS "${USER_FILE}")
358        message (STATUS "Creating ${USER_FILE} with default debug settings")
359        # These are the configuration variables
360        IF (CMAKE_GENERATOR MATCHES "Win64")
361            SET (USERFILE_PLATFORM "x64")
362        ELSE ()
363            SET (USERFILE_PLATFORM "Win32")
364        ENDIF ()
365
366                # Configure the template file
367                # MSC_VER 1300: MSC 13.0, VC 7.0, VS 2002
368                # MSC_VER 1310: MSC 13.1, VC 7.1, VS 2003
369                # MSC_VER 1400: MSC 14.0, VC 8.0, VS 2005
370                # MSC_VER 1500: MSC 15.0, VC 9.0, VS 2008
371                # MSC_VER 1600: MSC ??.0, VC 10.0, VS 2010
372                IF (MSVC_VERSION EQUAL 1400)
373                        CONFIGURE_FILE(VC80.vcproj.user.template ${USER_FILE} @ONLY)
374                ENDIF()
375                IF (MSVC_VERSION EQUAL 1500)
376                        CONFIGURE_FILE(VC90.vcproj.user.template ${USER_FILE} @ONLY)
377                ENDIF()         
378        ELSE()
379                message (STATUS "Userfile ${USER_FILE} already exist: Skipping")
380    ENDIF()
381ENDIF()
382
383
Note: See TracBrowser for help on using the repository browser.