root/trunk/CMakeLists.txt

Revision 951 (checked in by robert, 2 months ago)

Updated versions for 0.9.9 dev release

Line 
1 IF(WIN32)
2     CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
3 ELSE(WIN32)
4     IF(APPLE)
5         CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
6         IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
7             MESSAGE("Warning: A critical CMake bug exists in 2.4.6 and below. Trying to build Universal Binaries will result in a compile error that seems unrelated. Either avoid building Universal Binaries by changing the CMAKE_OSX_ARCHITECTURES field to list only your architecture, or upgrade to the current CVS version of CMake or a newer stable version if it exists.")
8         ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
9     ELSE(APPLE)
10         CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR)
11     ENDIF(APPLE)
12 ENDIF(WIN32)
13
14 if(COMMAND cmake_policy)
15     # Works around warnings libraries linked against that don't
16     # have absolute paths (e.g. -lpthreads)
17     cmake_policy(SET CMP0003 NEW)
18
19     # Works around warnings about escaped quotes in ADD_DEFINITIONS
20     # statements.
21     cmake_policy(SET CMP0005 OLD)
22 endif(COMMAND cmake_policy)
23
24 PROJECT(VIRTUALPLANETBUILDER)
25
26 SET(VIRTUALPLANETBUILDER_MAJOR_VERSION 0)
27 SET(VIRTUALPLANETBUILDER_MINOR_VERSION 9)
28 SET(VIRTUALPLANETBUILDER_PATCH_VERSION 9)
29 SET(VIRTUALPLANETBUILDER_SOVERSION 9)
30
31 # set to 0 when not a release candidate, non zero means that any generated
32 # svn tags will be treated as release candidates of given number
33 SET(VIRTUALPLANETBUILDER_RELEASE_CANDIDATE 0)
34
35 SET(VIRTUALPLANETBUILDER_VERSION ${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION})
36
37 # We want to build SONAMES shared librariess
38 SET(VIRTUALPLANETBUILDER_SONAMES TRUE)
39 SET(OPENTHREADS_SONAMES TRUE)
40
41 SET(OpenThreads_SOURCE_DIR ${VIRTUALPLANETBUILDER_SOURCE_DIR})
42
43 # We have some custom .cmake scripts not in the official distribution.
44 # Maybe this can be used override existing behavior if needed?
45 SET(CMAKE_MODULE_PATH "${VIRTUALPLANETBUILDER_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
46
47
48 # Okay, here's the problem: On some platforms, linking against OpenThreads
49 # is not enough and explicit linking to the underlying thread library
50 # is also required (e.g. FreeBSD). But OpenThreads may be built with different
51 # backends (Pthreads, Sproc, Windows) so we don't know what the underlying
52 # thread library is because some platforms support multiple backends (e.g.
53 # IRIX supports Sproc and Pthreads). Linking all libraries won't work
54 # because the libraries may be incompatible.
55 # So the current solution is to attempt best guess linking and exempt certain
56 # cases. With IRIX, we're going to hope explicit linking to the underlying
57 # library is not necessary. We currently don't case for pthreads on Windows
58 # which might be an issue on things like Cygwin. This may need to be fixed.
59 FIND_PACKAGE(Threads)
60 IF(CMAKE_SYSTEM MATCHES IRIX)
61     # Erase CMAKE_THREAD_LIBS_INIT and hope it works
62     SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
63 ENDIF(CMAKE_SYSTEM MATCHES IRIX)
64
65 OPTION(VPB_MAINTAINER "Enable VirtualPlanetBuilder maintainer build methods, such as making svn branches, tags, updating ChangeLog." OFF)
66 IF (VPB_MAINTAINER)
67
68     SET(VIRTUALPLANETBUILDER_SVN "trunk")
69     #SET(VIRTUALPLANETBUILDER_SVN "branches")
70     SET(VIRTUALPLANETBUILDER_BRANCH VIRTUALPLANETBUILDER-${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION})
71
72     #
73     # Provide target for tagging a release
74     #
75     SET(SVNCOMMAND svn)
76     SET(SVNTRUNKDIR     http://www.openscenegraph.org/svn/VirtualPlanetBuilder/trunk)
77     SET(SVNTAGDIR       http://www.openscenegraph.org/svn/VirtualPlanetBuilder/tags)
78     SET(SVNBRANCHDIR    http://www.openscenegraph.org/svn/VirtualPlanetBuilder/branch)
79
80     IF   (VIRTUALPLANETBUILDER_SVN STREQUAL "trunk")
81         SET(SVNSOURCEDIR ${SVNTRUNKDIR})
82     ELSE (VIRTUALPLANETBUILDER_SVN STREQUAL "trunk")
83         SET(SVNSOURCEDIR ${SVNBRANCH_DIR}/${VIRTUALPLANETBUILDER_BRANCH})
84     ENDIF(VIRTUALPLANETBUILDER_SVN STREQUAL "trunk")
85
86
87     IF   (VIRTUALPLANETBUILDER_RELEASE_CANDIDATE EQUAL 0)
88         SET(RELEASE_NAME VirtualPlanetBuilder-${VIRTUALPLANETBUILDER_VERSION})
89     ELSE (VIRTUALPLANETBUILDER_RELEASE_CANDIDATE EQUAL 0)
90         SET(RELEASE_NAME VirtualPlanetBuilder-${VIRTUALPLANETBUILDER_VERSION}-rc${VIRTUALPLANETBUILDER_RELEASE_CANDIDATE})
91     ENDIF(VIRTUALPLANETBUILDER_RELEASE_CANDIDATE EQUAL 0)
92
93
94     ADD_CUSTOM_TARGET(tag-test
95         COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
96     )
97
98     ADD_CUSTOM_TARGET(tag-run
99         COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNTAGDIR}/${RELEASE_NAME} -m "Release ${RELEASE_NAME}"
100     )
101
102     ADD_CUSTOM_TARGET(branch-test
103         COMMAND echo ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${VIRTUALPLANETBUILDER_BRANCH} -m "Branch ${VIRTUALPLANETBUILDER_BRANCH}"
104     )
105
106     ADD_CUSTOM_TARGET(branch-run
107         COMMAND ${SVNCOMMAND} copy ${SVNSOURCEDIR} ${SVNBRANCHDIR}/${VIRTUALPLANETBUILDER_BRANCH} -m "Branch ${VIRTUALPLANETBUILDER_BRANCH}"
108     )
109
110     #
111     # Provide target for generating ChangeLog
112     #
113     SET(SVN2LOG ~/bin/svn2log.py)
114     SET(GENERATELOGS ${SVNCOMMAND} log -v --xml | python ${SVN2LOG} -L -H)
115
116     ADD_CUSTOM_TARGET(ChangeLog
117         COMMAND ${SVNCOMMAND} update
118         COMMAND ${GENERATELOGS}
119     )
120    
121 ENDIF(VPB_MAINTAINER)
122
123
124
125 # Find OpenGL
126 FIND_PACKAGE(OpenGL)
127
128 IF(UNIX)
129     # Not sure what this will do on Cygwin and Msys
130     # Also, remember OS X X11 is a user installed option so it may not exist.
131     FIND_PACKAGE(X11)
132     # Some Unicies need explicit linkage to the Math library or the build fails.
133     FIND_LIBRARY(MATH_LIBRARY m)
134 ENDIF(UNIX)
135
136 FIND_PACKAGE(CURL)
137
138
139 # Make the headers visible to everything
140 INCLUDE_DIRECTORIES(
141     ${VIRTUALPLANETBUILDER_SOURCE_DIR}/include
142     ${OPENGL_INCLUDE_DIR}
143 )
144
145 # Common global definitions
146 #ADD_DEFINITIONS(-D)
147 # Platform specific definitions
148
149 ########################################################################################################
150 ##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
151 ########################################################################################################
152 #luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
153 #luigi#SET(CMAKE_SKIP_RPATH TRUE)
154 #luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
155 #luigi#IF(UNIX)
156 #luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
157 #luigi#    IF (contains)
158 #luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  CMAKE_CXX_COMPILER to g++")
159 #luigi#        SET(CMAKE_CXX_COMPILER "g++")
160 #luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
161 #luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
162 #luigi#    ENDIF (contains)
163 #luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
164 #luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
165 #luigi#ENDIF(UNIX)
166 ########################################################################################################
167
168 # Common to all platforms:
169 SET(OSG_DIR "" CACHE PATH "set to base osg install path")
170
171 SET(CMAKE_DEBUG_POSTFIX  "d")
172
173 FIND_PACKAGE(OSG)
174 FIND_PACKAGE(GDAL)
175 # FIND_PACKAGE(ShapeLib)
176
177 ################################################################################
178 # Create bin and lib directories if required
179
180 IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
181    FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib)
182 ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
183
184
185 ################################################################################
186 # Installation stuff
187
188
189 IF(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(CMAKE_SIZEOF_VOID_P MATCHES "8")
194 ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
195 IF(NOT DEFINED LIB_POSTFIX)
196     SET(LIB_POSTFIX "")
197 ENDIF(NOT DEFINED LIB_POSTFIX)
198
199 #SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
200 SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
201 MAKE_DIRECTORY(${OUTPUT_BINDIR})
202 SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
203
204 #SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
205 SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
206 MAKE_DIRECTORY(${OUTPUT_LIBDIR})
207 SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
208
209
210
211 #SET(INSTALL_BINDIR VIRTUALPLANETBUILDER/bin)
212 #SET(INSTALL_INCDIR VIRTUALPLANETBUILDER/include)
213 #SET(INSTALL_LIBDIR VIRTUALPLANETBUILDER/lib)
214 #SET(INSTALL_DOCDIR VIRTUALPLANETBUILDER/doc)
215
216 ################################################################################
217 # User Options
218
219
220 # Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
221 # may set these values without needing to manipulate the environment.
222 SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
223 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
224 # We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
225 # to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
226 # A formal feature request has been submited to CMake, Bug #4947.
227 # It is intended for those users who have common prefixes for their INCLUDE
228 # and LIBRARY locations. So if users have headers in /usr/local/include
229 # and libraries in /usr/local/lib, the common prefix is /usr/local.
230 # It should also cover the case where headers and libraries are
231 # in the same directory.
232 # Our proposal expects that FIND_* commands will automatically search for
233 # CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
234 # Obviously, since CMake does not currently support this, we must write
235 # our Find*.cmake modules to explicitly support this. Otherwise, this variable
236 # will have no impact.
237 # This is unofficial so this may be removed or changed at anytime.
238 SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
239
240 # Dynamic vs Static Linking
241 OPTION(DYNAMIC_VIRTUALPLANETBUILDER "Set to ON to build VIRTUALPLANETBUILDER for dynamic linking.  Use OFF for static." ON)
242 IF   (DYNAMIC_VIRTUALPLANETBUILDER)
243     SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
244 ELSE (DYNAMIC_VIRTUALPLANETBUILDER)
245     SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
246 ENDIF(DYNAMIC_VIRTUALPLANETBUILDER)
247
248 INCLUDE(VpbMacroUtils)
249
250 # VPB Core
251 ADD_SUBDIRECTORY(src)
252
253 # VPB Applications
254 OPTION(BUILD_APPLICATIONS "Enable to build VPB Applications (e.g. osgdem)" ON)
255 IF   (BUILD_APPLICATIONS)
256     ADD_SUBDIRECTORY(applications)
257 ENDIF(BUILD_APPLICATIONS)
258
259
260
261 # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
262 # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
263 IF(APPLE)
264     # These are just defaults/recommendations, but how we want to build
265     # out of the box. But the user needs to be able to change these options.
266     # So we must only set the values the first time CMake is run, or we
267     # will overwrite any changes the user sets.
268     # FORCE is used because the options are not reflected in the UI otherwise.
269     # Seems like a good place to add version specific compiler flags too.
270     IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
271         # This is really fragile, but CMake doesn't provide the OS system
272         # version information we need. (Darwin versions can be changed
273         # independently of OS X versions.)
274         # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
275         IF(EXISTS /Developer/SDKs/10.5.sdk)
276             SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
277             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)
278         ELSE(EXISTS /Developer/SDKs/10.5.sdk)
279             IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
280                 SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
281                 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)
282             ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
283                 # No Universal Binary support
284                 # Should break down further to set the -mmacosx-version-min,
285                 # but the SDK detection is too unreliable here.
286             ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
287         ENDIF(EXISTS /Developer/SDKs/10.5.sdk)
288     ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
289
290     OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
291
292 ENDIF(APPLE)
293
294
295 # This needs to be run very last so other parts of the scripts can take
296 # advantage of this.
297 IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
298     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")
299 ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
300
301
302 #-----------------------------------------------------------------------------
303 ### uninstall target
304 #-----------------------------------------------------------------------------
305 CONFIGURE_FILE(
306   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
307   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
308   IMMEDIATE @ONLY)
309 ADD_CUSTOM_TARGET(uninstall
310   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
311
Note: See TracBrowser for help on using the browser.