root/trunk/CMakeLists.txt

Revision 40 (checked in by robert, 1 month ago)

Fixed P3D_CONFIG_HAS_BEEN_RUN_BEFORE typo

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