root/trunk/CMakeLists.txt

Revision 1041, 15.3 kB (checked in by robert, 11 months ago)

Updated version number

Line 
1set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
2
3IF(WIN32)
4    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
5ELSE()
6    IF(APPLE)
7        CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
8    ELSE()
9        CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
10    ENDIF()
11ENDIF()
12
13if(COMMAND cmake_policy)
14    # Works around warnings libraries linked against that don't
15    # have absolute paths (e.g. -lpthreads)
16    cmake_policy(SET CMP0003 NEW)
17
18    # Works around warnings about escaped quotes in ADD_DEFINITIONS
19    # statements.
20    cmake_policy(SET CMP0005 NEW)
21
22    # cmake-2.6.1 introduces policy cmp0008 decide how to treat full path libraries that do not appear to be valid library file names
23    # quote from cvslog "Such libraries worked by accident in the VS IDE and Xcode generators in CMake 2.4 and below."
24    if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4 AND ${CMAKE_PATCH_VERSION} GREATER 0)
25        cmake_policy(SET CMP0008 OLD)
26    endif()
27endif()
28
29PROJECT(VIRTUALPLANETBUILDER)
30
31SET(VIRTUALPLANETBUILDER_MAJOR_VERSION 0)
32SET(VIRTUALPLANETBUILDER_MINOR_VERSION 9)
33SET(VIRTUALPLANETBUILDER_PATCH_VERSION 12)
34SET(VIRTUALPLANETBUILDER_SOVERSION 12)
35
36# set to 0 when not a release candidate, non zero means that any generated
37# svn tags will be treated as release candidates of given number
38SET(VIRTUALPLANETBUILDER_RELEASE_CANDIDATE 0)
39
40SET(VIRTUALPLANETBUILDER_VERSION ${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION})
41
42# We want to build SONAMES shared librariess
43SET(VIRTUALPLANETBUILDER_SONAMES TRUE)
44
45# We have some custom .cmake scripts not in the official distribution.
46# Maybe this can be used override existing behavior if needed?
47SET(CMAKE_MODULE_PATH "${VIRTUALPLANETBUILDER_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
48
49
50# Okay, here's the problem: On some platforms, linking against OpenThreads
51# is not enough and explicit linking to the underlying thread library
52# is also required (e.g. FreeBSD). But OpenThreads may be built with different
53# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
54# thread library is because some platforms support multiple backends (e.g.
55# IRIX supports Sproc and Pthreads). Linking all libraries won't work
56# because the libraries may be incompatible.
57# So the current solution is to attempt best guess linking and exempt certain
58# cases. With IRIX, we're going to hope explicit linking to the underlying
59# library is not necessary. We currently don't case for pthreads on Windows
60# which might be an issue on things like Cygwin. This may need to be fixed.
61FIND_PACKAGE(Threads)
62IF(CMAKE_SYSTEM MATCHES IRIX)
63    # Erase CMAKE_THREAD_LIBS_INIT and hope it works
64    SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
65ENDIF()
66
67OPTION(VPB_MAINTAINER "Enable VirtualPlanetBuilder maintainer build methods, such as making svn branches, tags, updating ChangeLog." OFF)
68IF (VPB_MAINTAINER)
69
70    SET(VIRTUALPLANETBUILDER_SVN "trunk")
71    #SET(VIRTUALPLANETBUILDER_SVN "branches")
72    SET(VIRTUALPLANETBUILDER_BRANCH VIRTUALPLANETBUILDER-${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION})
73
74    #
75    # Provide target for tagging a release
76    #
77    SET(SVNCOMMAND svn)
78    SET(SVNTRUNKDIR     http://www.openscenegraph.org/svn/VirtualPlanetBuilder/trunk)
79    SET(SVNTAGDIR       http://www.openscenegraph.org/svn/VirtualPlanetBuilder/tags)
80    SET(SVNBRANCHDIR    http://www.openscenegraph.org/svn/VirtualPlanetBuilder/branch)
81
82    IF   (VIRTUALPLANETBUILDER_SVN STREQUAL "trunk")
83        SET(SVNSOURCEDIR ${SVNTRUNKDIR})
84    ELSE ()
85        SET(SVNSOURCEDIR ${SVNBRANCH_DIR}/${VIRTUALPLANETBUILDER_BRANCH})
86    ENDIF()
87
88
89    IF   (VIRTUALPLANETBUILDER_RELEASE_CANDIDATE EQUAL 0)
90        SET(RELEASE_NAME VirtualPlanetBuilder-${VIRTUALPLANETBUILDER_VERSION})
91    ELSE ()
92        SET(RELEASE_NAME VirtualPlanetBuilder-${VIRTUALPLANETBUILDER_VERSION}-rc${VIRTUALPLANETBUILDER_RELEASE_CANDIDATE})
93    ENDIF()
94
95
96    ADD_CUSTOM_TARGET(tag-test
97        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
98    )
99
100    ADD_CUSTOM_TARGET(tag-run
101        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
102    )
103
104    ADD_CUSTOM_TARGET(branch-test
105        COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${VIRTUALPLANETBUILDER_BRANCH} -m "Branch ${VIRTUALPLANETBUILDER_BRANCH}"
106    )
107
108    ADD_CUSTOM_TARGET(branch-run
109        COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${VIRTUALPLANETBUILDER_BRANCH} -m "Branch ${VIRTUALPLANETBUILDER_BRANCH}"
110    )
111
112    #
113    # Provide target for generating ChangeLog
114    #
115    SET(GENERATELOGS svn2cl)
116
117    ADD_CUSTOM_TARGET(ChangeLog
118        COMMAND ${SVNCOMMAND} update
119        COMMAND ${GENERATELOGS}
120    )
121   
122ENDIF()
123
124
125
126# Find OpenGL
127FIND_PACKAGE(OpenGL)
128
129IF(UNIX)
130    # Not sure what this will do on Cygwin and Msys
131    # Also, remember OS X X11 is a user installed option so it may not exist.
132    FIND_PACKAGE(X11)
133    # Some Unicies need explicit linkage to the Math library or the build fails.
134    FIND_LIBRARY(MATH_LIBRARY m)
135ENDIF()
136
137
138# Make the headers visible to everything
139INCLUDE_DIRECTORIES(
140    ${VIRTUALPLANETBUILDER_SOURCE_DIR}/include
141    ${OPENGL_INCLUDE_DIR}
142)
143
144# Common global definitions
145#ADD_DEFINITIONS(-D)
146# Platform specific definitions
147
148########################################################################################################
149##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
150########################################################################################################
151#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
152#luigi#SET(CMAKE_SKIP_RPATH TRUE)
153#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
154#luigi#IF(UNIX)
155#luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
156#luigi#    IF (contains)
157#luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  CMAKE_CXX_COMPILER to g++")
158#luigi#        SET(CMAKE_CXX_COMPILER "g++")
159#luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
160#luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
161#luigi#    ENDIF ()
162#luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
163#luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
164#luigi#ENDIF()
165########################################################################################################
166
167# Common to all platforms:
168SET(OSG_DIR "" CACHE PATH "set to base osg install path")
169
170SET(3rdPartyRoot "" CACHE PATH "set to base 3rd party dependancy path")
171
172SET(CMAKE_DEBUG_POSTFIX  "d")
173
174FIND_PACKAGE(OpenSceneGraph 2.9.8 REQUIRED osgDB osgFX osgUtil osgSim osgTerrain osgViewer osgGA osgText)
175FIND_PACKAGE(GDAL)
176
177################################################################################
178# Create bin and lib directories if required
179
180IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
181   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib)
182ENDIF()
183
184
185################################################################################
186# Installation stuff
187
188
189IF(UNIX AND NOT WIN32 AND NOT APPLE)
190  IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
191      SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
192      MARK_AS_ADVANCED(LIB_POSTFIX)
193  ENDIF()
194ENDIF()
195IF(NOT DEFINED LIB_POSTFIX)
196    SET(LIB_POSTFIX "")
197ENDIF()
198
199# Here we apparantly do some funky stuff with making the bin/ and lib/
200# folders which is probably needed to work around a very old CMake bug?
201
202#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
203SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
204MAKE_DIRECTORY(${OUTPUT_BINDIR})
205SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
206
207#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
208SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
209MAKE_DIRECTORY(${OUTPUT_LIBDIR})
210SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
211
212
213
214#SET(INSTALL_BINDIR VirtualPlanetBuilder/bin)
215#SET(INSTALL_INCDIR VirtualPlanetBuilder/include)
216#SET(INSTALL_LIBDIR VirtualPlanetBuilder/lib)
217#SET(INSTALL_DOCDIR VirtualPlanetBuilder/doc)
218
219################################################################################
220# User Options
221
222
223# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
224# may set these values without needing to manipulate the environment.
225SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
226SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
227# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
228# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
229# A formal feature request has been submited to CMake, Bug #4947.
230# It is intended for those users who have common prefixes for their INCLUDE
231# and LIBRARY locations. So if users have headers in /usr/local/include
232# and libraries in /usr/local/lib, the common prefix is /usr/local.
233# It should also cover the case where headers and libraries are
234# in the same directory.
235# Our proposal expects that FIND_* commands will automatically search for
236# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
237# Obviously, since CMake does not currently support this, we must write
238# our Find*.cmake modules to explicitly support this. Otherwise, this variable
239# will have no impact.
240# This is unofficial so this may be removed or changed at anytime.
241SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
242
243# This is for an advanced option to give aggressive warnings
244# under different compilers. If yours is not implemented, this option
245# will not be made available.
246IF(CMAKE_COMPILER_IS_GNUCXX)
247    # To be complete, we might also do GNUCC flags,
248    # but everything here is C++ code.
249    # -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
250    # returns too many hits.
251    # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
252    # interesting C-specific flag.
253    # Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
254    # errors instead of warnings for certain issues, including superfluous
255    # semicolons and commas, and the use of long long. -fpermissive seems
256    # to be the workaround.
257    SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive)
258
259    # Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
260
261
262ELSE()
263    IF(MSVC)
264        # FIXME: What are good aggressive warning flags for Visual Studio?
265        # And do we need to further subcase this for different versions of VS?
266        # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
267        SET(OSG_AGGRESSIVE_WARNING_FLAGS /W4 /wd4706 /wd4127 /wd4100)
268
269
270    ELSE()
271        # CMake lacks an elseif, so other non-gcc, non-VS compilers need
272        # to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
273        # remain unset.
274    ENDIF()
275ENDIF()
276
277# This part is for the CMake menu option to toggle the warnings on/off.
278# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
279IF(OSG_AGGRESSIVE_WARNING_FLAGS)
280
281    IF (APPLE)
282        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS OFF)
283    ELSE()
284        SET(DEFAULT_USE_AGGRESSIVE_WARNINGS ON)
285    ENDIF()
286
287    OPTION(OSG_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" ${DEFAULT_USE_AGGRESSIVE_WARNINGS})
288    MARK_AS_ADVANCED(OSG_USE_AGGRESSIVE_WARNINGS)
289
290    IF(OSG_USE_AGGRESSIVE_WARNINGS)
291        # Add flags defined by OSG_AGGRESSIVE_WARNING_FLAGS if they aren't already there
292        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
293            IF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}")
294                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
295            ENDIF()
296        ENDFOREACH()
297    ELSE()
298        # Remove all flags considered aggresive
299        FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS})
300            STRING(REGEX REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
301        ENDFOREACH()
302    ENDIF()
303ENDIF()
304
305# Dynamic vs Static Linking
306OPTION(DYNAMIC_VIRTUALPLANETBUILDER "Set to ON to build VIRTUALPLANETBUILDER for dynamic linking.  Use OFF for static." ON)
307IF   (DYNAMIC_VIRTUALPLANETBUILDER)
308    SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
309ELSE ()
310    SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
311ENDIF()
312
313INCLUDE(VpbMacroUtils)
314
315# VPB Core
316IF(NOT OSG_FOUND)
317    message(FATAL_ERROR "OSG was not found")
318ENDIF()
319IF(NOT GDAL_FOUND)
320    message(FATAL_ERROR "GDAL was not found")
321ENDIF()
322
323ADD_SUBDIRECTORY(src)
324ADD_SUBDIRECTORY(applications)
325
326
327# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
328# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
329IF(APPLE)
330    # These are just defaults/recommendations, but how we want to build
331    # out of the box. But the user needs to be able to change these options.
332    # So we must only set the values the first time CMake is run, or we
333    # will overwrite any changes the user sets.
334    # FORCE is used because the options are not reflected in the UI otherwise.
335    # Seems like a good place to add version specific compiler flags too.
336    IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
337        # This is really fragile, but CMake doesn't provide the OS system
338        # version information we need. (Darwin versions can be changed
339        # independently of OS X versions.)
340        # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
341        IF(EXISTS /Developer/SDKs/10.5.sdk)
342            SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
343            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
344        ELSE()
345            IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
346                SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
347                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
348            ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
349                # No Universal Binary support
350                # Should break down further to set the -mmacosx-version-min,
351                # but the SDK detection is too unreliable here.
352            ENDIF()
353        ENDIF()
354    ENDIF()
355
356    OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
357
358ENDIF()
359
360
361# This needs to be run very last so other parts of the scripts can take
362# advantage of this.
363IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
364    SET(VPB_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
365ENDIF()
366
367
368#-----------------------------------------------------------------------------
369### uninstall target
370#-----------------------------------------------------------------------------
371CONFIGURE_FILE(
372  "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
373  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
374  IMMEDIATE @ONLY)
375ADD_CUSTOM_TARGET(uninstall
376  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
377
Note: See TracBrowser for help on using the browser.