root/tags/VirtualPlanetBuilder-0.9.1/CMakeLists.txt

Revision 637 (checked in by robert, 1 year ago)

Moved the GDAL plugin back into the core OpenSceneGraph? to make it easier
to manage the plugin paths, and to keep VirtualPlanetBuilder? purely focused
on database building.

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
15 PROJECT(VIRTUALPLANETBUILDER)
16
17 SET(VIRTUALPLANETBUILDER_MAJOR_VERSION 0)
18 SET(VIRTUALPLANETBUILDER_MINOR_VERSION 9)
19 SET(VIRTUALPLANETBUILDER_PATCH_VERSION 1)
20 SET(VIRTUALPLANETBUILDER_SOVERSION 1)
21
22 SET(VIRTUALPLANETBUILDER_VERSION ${VIRTUALPLANETBUILDER_MAJOR_VERSION}.${VIRTUALPLANETBUILDER_MINOR_VERSION}.${VIRTUALPLANETBUILDER_PATCH_VERSION})
23
24 # We want to build SONAMES shared librariess
25 SET(VIRTUALPLANETBUILDER_SONAMES TRUE)
26 SET(OPENTHREADS_SONAMES TRUE)
27
28 SET(OpenThreads_SOURCE_DIR ${VIRTUALPLANETBUILDER_SOURCE_DIR})
29
30 # We have some custom .cmake scripts not in the official distribution.
31 # Maybe this can be used override existing behavior if needed?
32 SET(CMAKE_MODULE_PATH "${VIRTUALPLANETBUILDER_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
33
34
35 # Okay, here's the problem: On some platforms, linking against OpenThreads
36 # is not enough and explicit linking to the underlying thread library
37 # is also required (e.g. FreeBSD). But OpenThreads may be built with different
38 # backends (Pthreads, Sproc, Windows) so we don't know what the underlying
39 # thread library is because some platforms support multiple backends (e.g.
40 # IRIX supports Sproc and Pthreads). Linking all libraries won't work
41 # because the libraries may be incompatible.
42 # So the current solution is to attempt best guess linking and exempt certain
43 # cases. With IRIX, we're going to hope explicit linking to the underlying
44 # library is not necessary. We currently don't case for pthreads on Windows
45 # which might be an issue on things like Cygwin. This may need to be fixed.
46 FIND_PACKAGE(Threads)
47 IF(CMAKE_SYSTEM MATCHES IRIX)
48     # Erase CMAKE_THREAD_LIBS_INIT and hope it works
49     SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")   
50 ENDIF(CMAKE_SYSTEM MATCHES IRIX)
51
52 # Find OpenGL
53 FIND_PACKAGE(OpenGL)
54
55 IF(UNIX)
56     # Not sure what this will do on Cygwin and Msys
57     # Also, remember OS X X11 is a user installed option so it may not exist.
58     FIND_PACKAGE(X11)
59     # Some Unicies need explicit linkage to the Math library or the build fails.
60     FIND_LIBRARY(MATH_LIBRARY m)
61 ENDIF(UNIX)
62    
63 # Make the headers visible to everything
64 INCLUDE_DIRECTORIES(
65     ${VIRTUALPLANETBUILDER_SOURCE_DIR}/include
66     ${OPENGL_INCLUDE_DIR}
67 )
68    
69 # Common global definitions
70 #ADD_DEFINITIONS(-D)
71 # Platform specific definitions
72
73 ########################################################################################################
74 ##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
75 ########################################################################################################
76 #luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
77 #luigi#SET(CMAKE_SKIP_RPATH TRUE)
78 #luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
79 #luigi#IF(UNIX)
80 #luigi#    LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
81 #luigi#    IF (contains)
82 #luigi#        MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting  CMAKE_CXX_COMPILER to g++")
83 #luigi#        SET(CMAKE_CXX_COMPILER "g++")
84 #luigi#        SET(CMAKE_CXX_COMPILER_LOADED 2)
85 #luigi#        SET(CMAKE_CXX_COMPILER_WORKS 2)
86 #luigi#    ENDIF (contains)
87 #luigi#    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
88 #luigi#    SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
89 #luigi#ENDIF(UNIX)
90 ########################################################################################################
91
92 # Common to all platforms:
93 SET(OSG_DIR "" CACHE PATH "set to base osg install path")
94
95 SET(CMAKE_DEBUG_POSTFIX  "d")
96
97 FIND_PACKAGE(OSG)
98 FIND_PACKAGE(GDAL)
99
100 ################################################################################
101 # Create bin and lib directories if required
102
103 IF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
104    FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib)
105 ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
106
107
108 ################################################################################
109 # Installation stuff
110
111
112 IF(UNIX AND NOT WIN32 AND NOT APPLE)
113   IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
114       SET(LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement")
115       MARK_AS_ADVANCED(LIB_POSTFIX)
116   ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
117 ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
118 IF(NOT DEFINED LIB_POSTFIX)
119     SET(LIB_POSTFIX "")
120 ENDIF(NOT DEFINED LIB_POSTFIX)
121    
122 #SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
123 SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
124 MAKE_DIRECTORY(${OUTPUT_BINDIR})
125 SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
126
127 #SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
128 SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
129 MAKE_DIRECTORY(${OUTPUT_LIBDIR})
130 SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
131
132
133
134 #SET(INSTALL_BINDIR VIRTUALPLANETBUILDER/bin)
135 #SET(INSTALL_INCDIR VIRTUALPLANETBUILDER/include)
136 #SET(INSTALL_LIBDIR VIRTUALPLANETBUILDER/lib)
137 #SET(INSTALL_DOCDIR VIRTUALPLANETBUILDER/doc)
138
139 ################################################################################
140 # User Options
141
142
143 # Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
144 # may set these values without needing to manipulate the environment.
145 SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
146 SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths.")
147 # We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
148 # to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
149 # A formal feature request has been submited to CMake, Bug #4947.
150 # It is intended for those users who have common prefixes for their INCLUDE
151 # and LIBRARY locations. So if users have headers in /usr/local/include
152 # and libraries in /usr/local/lib, the common prefix is /usr/local.
153 # It should also cover the case where headers and libraries are
154 # in the same directory.
155 # Our proposal expects that FIND_* commands will automatically search for
156 # CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
157 # Obviously, since CMake does not currently support this, we must write
158 # our Find*.cmake modules to explicitly support this. Otherwise, this variable
159 # will have no impact.
160 # This is unofficial so this may be removed or changed at anytime.
161 SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths.")
162
163
164 # Dynamic vs Static Linking
165 OPTION(DYNAMIC_VIRTUALPLANETBUILDER "Set to ON to build VIRTUALPLANETBUILDER for dynamic linking.  Use OFF for static." ON)
166 IF   (DYNAMIC_VIRTUALPLANETBUILDER)
167     SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED")
168 ELSE (DYNAMIC_VIRTUALPLANETBUILDER)
169     SET(VIRTUALPLANETBUILDER_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC")
170 ENDIF(DYNAMIC_VIRTUALPLANETBUILDER)
171
172 INCLUDE(VpbMacroUtils)
173
174 # VPB Core
175 ADD_SUBDIRECTORY(src)
176
177 # VPB Applications
178 OPTION(BUILD_APPLICATIONS "Enable to build VPB Applications (e.g. osgdem)" ON)
179 IF   (BUILD_APPLICATIONS)
180     ADD_SUBDIRECTORY(applications)
181 ENDIF(BUILD_APPLICATIONS)
182
183
184
185 # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
186 # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
187 IF(APPLE)
188     # These are just defaults/recommendations, but how we want to build
189     # out of the box. But the user needs to be able to change these options.
190     # So we must only set the values the first time CMake is run, or we
191     # will overwrite any changes the user sets.
192     # FORCE is used because the options are not reflected in the UI otherwise.
193     # Seems like a good place to add version specific compiler flags too.
194     IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
195         # This is really fragile, but CMake doesn't provide the OS system
196         # version information we need. (Darwin versions can be changed
197         # independently of OS X versions.)
198         # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
199         IF(EXISTS /Developer/SDKs/10.5.sdk)
200             SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
201             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)
202         ELSE(EXISTS /Developer/SDKs/10.5.sdk)
203             IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
204                 SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
205                 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)
206             ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
207                 # No Universal Binary support
208                 # Should break down further to set the -mmacosx-version-min,
209                 # but the SDK detection is too unreliable here.
210             ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
211         ENDIF(EXISTS /Developer/SDKs/10.5.sdk)
212     ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
213    
214     OPTION(VPB_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
215    
216 ENDIF(APPLE)
217
218
219 # This needs to be run very last so other parts of the scripts can take
220 # advantage of this.
221 IF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
222     SET(VOB_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")
223 ENDIF(NOT VPB_CONFIG_HAS_BEEN_RUN_BEFORE)
224
225
226 #-----------------------------------------------------------------------------
227 ### uninstall target
228 #-----------------------------------------------------------------------------
229 CONFIGURE_FILE(
230   "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
231   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
232   IMMEDIATE @ONLY)
233 ADD_CUSTOM_TARGET(uninstall
234   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
235
Note: See TracBrowser for help on using the browser.