2007-04-12 18:14:10 +08:00
IF ( WIN32 )
CMAKE_MINIMUM_REQUIRED ( VERSION 2.4.6 FATAL_ERROR )
ELSE ( WIN32 )
IF ( APPLE )
CMAKE_MINIMUM_REQUIRED ( VERSION 2.4.6 FATAL_ERROR )
2007-04-25 17:14:01 +08:00
IF ( ${ CMAKE_MAJOR_VERSION } EQUAL 2 AND ${ CMAKE_MINOR_VERSION } EQUAL 4 AND ${ CMAKE_PATCH_VERSION } LESS 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." )
ENDIF ( ${ CMAKE_MAJOR_VERSION } EQUAL 2 AND ${ CMAKE_MINOR_VERSION } EQUAL 4 AND ${ CMAKE_PATCH_VERSION } LESS 7 )
2007-04-12 18:14:10 +08:00
ELSE ( APPLE )
CMAKE_MINIMUM_REQUIRED ( VERSION 2.4.0 FATAL_ERROR )
ENDIF ( APPLE )
ENDIF ( WIN32 )
2007-03-09 17:07:05 +08:00
PROJECT ( OpenSceneGraph )
2007-06-15 18:15:54 +08:00
SET ( OPENSCENEGRAPH_MAJOR_VERSION 2 )
2007-12-18 05:08:52 +08:00
SET ( OPENSCENEGRAPH_MINOR_VERSION 3 )
2008-01-21 19:40:27 +08:00
SET ( OPENSCENEGRAPH_PATCH_VERSION 3 )
SET ( OPENSCENEGRAPH_SOVERSION 29 )
2007-04-27 18:29:48 +08:00
2007-05-21 01:38:11 +08:00
SET ( OPENSCENEGRAPH_VERSION ${ OPENSCENEGRAPH_MAJOR_VERSION } . ${ OPENSCENEGRAPH_MINOR_VERSION } . ${ OPENSCENEGRAPH_PATCH_VERSION } )
SET ( OSG_PLUGINS osgPlugins- ${ OPENSCENEGRAPH_VERSION } )
2007-10-03 05:26:22 +08:00
SET ( OSG_PLUGIN_PREFIX "" )
IF ( CYGWIN )
SET ( OSG_PLUGIN_PREFIX "cygwin_" )
ENDIF ( CYGWIN )
IF ( MINGW )
SET ( OSG_PLUGIN_PREFIX "mingw_" )
ENDIF ( MINGW )
2007-05-21 01:38:11 +08:00
# We want to build SONAMES shared librariess
SET ( OPENSCENEGRAPH_SONAMES TRUE )
SET ( OPENTHREADS_SONAMES TRUE )
2007-05-20 20:29:11 +08:00
2007-05-03 16:50:06 +08:00
SET ( OpenThreads_SOURCE_DIR ${ OpenSceneGraph_SOURCE_DIR } )
2007-03-09 17:07:05 +08:00
# We have some custom .cmake scripts not in the official distribution.
# Maybe this can be used override existing behavior if needed?
SET ( CMAKE_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}" )
# Mainly for Windows as a convenience. This will find a directory in parallel with the
# OSG source that contains 3rd party headers and libraries.
# Use of relative paths in CMake is ill-advised, but don't know of any alternatives in this case
2007-03-28 05:44:02 +08:00
#SET(CMAKE_INCLUDE_PATH "${OpenSceneGraph_SOURCE_DIR}/../3rdParty/include;${CMAKE_INCLUDE_PATH}")
#SET(CMAKE_LIBRARY_PATH "${OpenSceneGraph_SOURCE_DIR}/../3rdParty/lib;${CMAKE_LIBRARY_PATH}")
2007-03-09 17:07:05 +08:00
IF ( USING_OSG_OP_OT_TRIPLE_SET )
2007-04-11 16:33:40 +08:00
SET ( CMAKE_INCLUDE_PATH "${OpenSceneGraph_SOURCE_DIR}/../../3rdParty/include;${CMAKE_INCLUDE_PATH}" )
SET ( CMAKE_LIBRARY_PATH "${OpenSceneGraph_SOURCE_DIR}/../../3rdParty/lib;${CMAKE_LIBRARY_PATH}" )
2007-03-09 17:07:05 +08:00
ENDIF ( USING_OSG_OP_OT_TRIPLE_SET )
2007-03-29 18:56:07 +08:00
# Okay, here's the problem: On some platforms, linking against OpenThreads
# is not enough and explicit linking to the underlying thread library
# is also required (e.g. FreeBSD). But OpenThreads may be built with different
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
# thread library is because some platforms support multiple backends (e.g.
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
# because the libraries may be incompatible.
# So the current solution is to attempt best guess linking and exempt certain
# cases. With IRIX, we're going to hope explicit linking to the underlying
# library is not necessary. We currently don't case for pthreads on Windows
# which might be an issue on things like Cygwin. This may need to be fixed.
FIND_PACKAGE ( Threads )
IF ( CMAKE_SYSTEM MATCHES IRIX )
2007-04-11 16:33:40 +08:00
# Erase CMAKE_THREAD_LIBS_INIT and hope it works
SET ( CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "" )
2007-03-29 18:56:07 +08:00
ENDIF ( CMAKE_SYSTEM MATCHES IRIX )
2007-03-20 17:50:24 +08:00
# Find OpenGL
2007-03-09 17:07:05 +08:00
FIND_PACKAGE ( OpenGL )
IF ( APPLE )
2007-04-11 16:33:40 +08:00
FIND_LIBRARY ( CARBON_LIBRARY Carbon )
FIND_LIBRARY ( COCOA_LIBRARY Cocoa )
2007-03-09 17:07:05 +08:00
ENDIF ( APPLE )
IF ( UNIX )
2007-04-11 16:33:40 +08:00
# Not sure what this will do on Cygwin and Msys
# Also, remember OS X X11 is a user installed option so it may not exist.
FIND_PACKAGE ( X11 )
# Some Unicies need explicit linkage to the Math library or the build fails.
FIND_LIBRARY ( MATH_LIBRARY m )
2007-03-09 17:07:05 +08:00
ENDIF ( UNIX )
2007-04-11 16:33:40 +08:00
2007-03-09 17:07:05 +08:00
# Make the headers visible to everything
INCLUDE_DIRECTORIES (
2007-04-11 16:33:40 +08:00
$ { O p e n S c e n e G r a p h _ S O U R C E _ D I R } / i n c l u d e
$ { O P E N G L _ I N C L U D E _ D I R }
2007-03-09 17:07:05 +08:00
)
2007-04-11 16:33:40 +08:00
2007-03-09 17:07:05 +08:00
# Common global definitions
#ADD_DEFINITIONS(-D)
# Platform specific definitions
2007-10-04 07:01:33 +08:00
IF ( NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT )
2007-10-03 05:26:22 +08:00
2007-10-04 07:01:33 +08:00
SET ( DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT OFF )
IF ( CMAKE_SYSTEM MATCHES "AIX.*" )
SET ( DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON )
ENDIF ( CMAKE_SYSTEM MATCHES "AIX.*" )
IF ( APPLE )
SET ( DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON )
ENDIF ( APPLE )
ENDIF ( NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT )
OPTION ( OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with (...) version of GLU tesselator callback" ${ DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT } )
IF ( OSG_GLU_TESS_CALLBACK_TRIPLEDOT )
2007-10-04 04:21:01 +08:00
ADD_DEFINITIONS ( -DGLU_TESS_CALLBACK_TRIPLEDOT )
2007-10-04 07:01:33 +08:00
ENDIF ( OSG_GLU_TESS_CALLBACK_TRIPLEDOT )
2007-10-03 05:26:22 +08:00
2007-03-09 17:07:05 +08:00
IF ( WIN32 )
2007-05-17 18:59:05 +08:00
ADD_DEFINITIONS ( -D_SCL_SECURE_NO_WARNINGS )
2007-07-11 23:30:14 +08:00
ADD_DEFINITIONS ( -D_CRT_SECURE_NO_DEPRECATE )
2007-04-11 16:33:40 +08:00
#needed for net plugin
2007-10-03 04:56:56 +08:00
SET ( OSG_SOCKET_LIBS wsock32 )
2007-04-11 16:33:40 +08:00
# Both Cygwin and Msys need -DNOMINMAX ???
IF ( UNIX )
ADD_DEFINITIONS ( -DNOMINMAX )
ENDIF ( UNIX )
2007-08-30 18:41:15 +08:00
########################################################################################################
# the foolowing options are MSVC specific,
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
# fron bin folder without requiring installation step.
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
# it also use a hack to get rid of Debug and Release folder in MSVC projects
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
#
# the second option disable incremental linking in debug build , that is enabled by default by CMake
##########################################################################################################
2007-09-11 00:06:23 +08:00
IF ( MSVC )
IF ( ${ CMAKE_MAJOR_VERSION } EQUAL 2 AND ${ CMAKE_MINOR_VERSION } EQUAL 4 AND ${ CMAKE_PATCH_VERSION } LESS 7 )
MESSAGE ( "Warning: disabling versioned options 2.4.6 exibits inconsintencies in .pdb naming, at least under MSVC, suggested upgrading at least to 2.4.7" )
SET ( OSG_MSVC_VERSIONED_DLL OFF )
SET ( OSG_MSVC_DEBUG_INCREMENTAL_LINK ON )
ELSE ( ${ CMAKE_MAJOR_VERSION } EQUAL 2 AND ${ CMAKE_MINOR_VERSION } EQUAL 4 AND ${ CMAKE_PATCH_VERSION } LESS 7 )
OPTION ( OSG_MSVC_VERSIONED_DLL "Set to ON to build OpenSceneGraph with versioned dll names" ON )
MARK_AS_ADVANCED ( OSG_MSVC_VERSIONED_DLL )
OPTION ( OSG_MSVC_DEBUG_INCREMENTAL_LINK "Set to OFF to build OpenSceneGraph without incremental linking in debug (release is off by default)" ON )
MARK_AS_ADVANCED ( OSG_MSVC_DEBUG_INCREMENTAL_LINK )
IF ( NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK )
SET ( CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" )
SET ( CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" )
SET ( CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:NO" )
ENDIF ( NOT OSG_MSVC_DEBUG_INCREMENTAL_LINK )
ENDIF ( ${ CMAKE_MAJOR_VERSION } EQUAL 2 AND ${ CMAKE_MINOR_VERSION } EQUAL 4 AND ${ CMAKE_PATCH_VERSION } LESS 7 )
ENDIF ( MSVC )
2007-03-09 17:07:05 +08:00
ENDIF ( WIN32 )
2007-03-10 00:25:11 +08:00
########################################################################################################
##### these were settings located in SetupCommon.cmake used in Luigi builds.... find out what are useful
########################################################################################################
#luigi#SET(CMAKE_VERBOSE_MAKEFILE TRUE)
#luigi#SET(CMAKE_SKIP_RPATH TRUE)
#luigi#SET(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
#luigi#IF(UNIX)
2007-04-11 16:33:40 +08:00
#luigi# LIST_CONTAINS(contains "g++" ${CMAKE_CXX_COMPILER_LIST})
#luigi# IF (contains)
#luigi# MESSAGE(${MY_MESSAGE_DEFAULT} "${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} setting CMAKE_CXX_COMPILER to g++")
#luigi# SET(CMAKE_CXX_COMPILER "g++")
#luigi# SET(CMAKE_CXX_COMPILER_LOADED 2)
#luigi# SET(CMAKE_CXX_COMPILER_WORKS 2)
#luigi# ENDIF (contains)
#luigi# SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
#luigi# SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb -gstabs")
2007-03-10 00:25:11 +08:00
#luigi#ENDIF(UNIX)
########################################################################################################
2007-05-20 19:45:09 +08:00
OPTION ( OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float matrix instead of double." OFF )
MARK_AS_ADVANCED ( OSG_USE_FLOAT_MATRIX )
IF ( OSG_USE_FLOAT_MATRIX )
ADD_DEFINITIONS ( -DOSG_USE_FLOAT_MATRIX )
ENDIF ( OSG_USE_FLOAT_MATRIX )
OPTION ( OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float matrix instead of double." OFF )
MARK_AS_ADVANCED ( OSG_USE_FLOAT_PLANE )
IF ( OSG_USE_FLOAT_PLANE )
ADD_DEFINITIONS ( -DOSG_USE_FLOAT_PLANE )
ENDIF ( OSG_USE_FLOAT_PLANE )
2007-03-09 17:07:05 +08:00
################################################################################
# 3rd Party Dependency Stuff
2007-03-29 18:56:07 +08:00
IF ( WIN32 )
2007-04-11 16:33:40 +08:00
INCLUDE ( Find3rdPartyDependencies )
2007-03-29 18:56:07 +08:00
ENDIF ( WIN32 )
2007-03-09 17:07:05 +08:00
# Common to all platforms:
FIND_PACKAGE ( FreeType )
2007-03-22 22:44:05 +08:00
FIND_PACKAGE ( FLTK )
2007-03-22 21:38:23 +08:00
FIND_PACKAGE ( GLUT )
FIND_PACKAGE ( SDL )
2007-07-24 22:02:53 +08:00
FIND_PACKAGE ( FOX )
2007-03-20 17:50:24 +08:00
FIND_PACKAGE ( Inventor )
2007-05-04 21:20:48 +08:00
FIND_PACKAGE ( Jasper )
2007-05-04 22:25:02 +08:00
FIND_PACKAGE ( COLLADA )
2007-05-05 03:17:49 +08:00
FIND_PACKAGE ( Xine )
2007-05-06 00:11:30 +08:00
FIND_PACKAGE ( OpenVRML )
2007-05-06 00:24:07 +08:00
FIND_PACKAGE ( Performer )
2007-06-06 23:22:31 +08:00
FIND_PACKAGE ( ZLIB )
2007-08-07 18:33:25 +08:00
FIND_PACKAGE ( GDAL )
2007-03-09 17:07:05 +08:00
2007-05-11 20:46:38 +08:00
SET ( wxWidgets_USE_LIBS base core gl net )
FIND_PACKAGE ( wxWidgets )
2007-10-03 04:56:56 +08:00
# To select a specific version of QT define DESIRED_QT_VERSION
# via cmake -DDESIRED_QT_VERSION=4
IF ( DESIRED_QT_VERSION )
IF ( DESIRED_QT_VERSION MATCHES 4 )
FIND_PACKAGE ( Qt4 )
ELSE ( DESIRED_QT_VERSION MATCHES 4 )
FIND_PACKAGE ( Qt3 )
ENDIF ( DESIRED_QT_VERSION MATCHES 4 )
ELSE ( DESIRED_QT_VERSION )
FIND_PACKAGE ( Qt4 )
IF ( NOT QT4_FOUND )
FIND_PACKAGE ( Qt3 )
ENDIF ( NOT QT4_FOUND )
ENDIF ( DESIRED_QT_VERSION )
2007-03-09 17:07:05 +08:00
# Platform specific:
# (We can approach this one of two ways. We can try to FIND everything
# and simply check if we found the packages before actually building
# or we can hardcode the cases. The advantage of the former is that
# packages that are installed on platforms that don't require them
# will still get built (presuming no compatibility issues). But this
# also means modules that are redundant may get built. For example,
# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
# Also, it will clutter the CMake menu with "NOT_FOUND".
# The downside to the latter is that it is harder to build those
# potentially redundant modules.)
# Image readers/writers depend on 3rd party libraries except for OS X which
# can use Quicktime.
IF ( NOT APPLE )
2007-04-11 16:33:40 +08:00
FIND_PACKAGE ( GIFLIB )
FIND_PACKAGE ( JPEG )
FIND_PACKAGE ( PNG )
FIND_PACKAGE ( TIFF )
# QuickTime is required for OS X, but optional for Windows.
IF ( WIN32 )
FIND_PACKAGE ( QuickTime )
ENDIF ( WIN32 )
2007-03-09 17:07:05 +08:00
ELSE ( NOT APPLE )
2007-04-11 16:33:40 +08:00
FIND_PACKAGE ( QuickTime )
2007-03-09 17:07:05 +08:00
ENDIF ( NOT APPLE )
2007-03-23 16:53:06 +08:00
################################################################################
# Create bin and lib directories if required
IF ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
2007-05-20 20:29:11 +08:00
FILE ( MAKE_DIRECTORY ${ CMAKE_BINARY_DIR } /bin ${ CMAKE_BINARY_DIR } /lib ${ CMAKE_BINARY_DIR } /lib/ ${ OSG_PLUGINS } )
2007-03-23 16:53:06 +08:00
ENDIF ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
2007-03-09 17:07:05 +08:00
################################################################################
# Installation stuff
SET ( CMAKE_DEBUG_POSTFIX "d" )
2007-03-29 18:56:07 +08:00
IF ( UNIX AND NOT WIN32 AND NOT APPLE )
IF ( CMAKE_SIZEOF_VOID_P MATCHES "8" )
2007-05-20 17:55:34 +08:00
SET ( LIB_POSTFIX "64" CACHE STRING "suffix for 32/64 dir placement" )
MARK_AS_ADVANCED ( LIB_POSTFIX )
2007-03-29 18:56:07 +08:00
ENDIF ( CMAKE_SIZEOF_VOID_P MATCHES "8" )
ENDIF ( UNIX AND NOT WIN32 AND NOT APPLE )
2007-05-20 17:55:34 +08:00
IF ( NOT DEFINED LIB_POSTFIX )
SET ( LIB_POSTFIX "" )
ENDIF ( NOT DEFINED LIB_POSTFIX )
2007-03-13 05:23:09 +08:00
#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
SET ( OUTPUT_BINDIR ${ PROJECT_BINARY_DIR } /bin )
2007-03-09 17:07:05 +08:00
MAKE_DIRECTORY ( ${ OUTPUT_BINDIR } )
SET ( EXECUTABLE_OUTPUT_PATH ${ OUTPUT_BINDIR } )
2007-03-13 05:23:09 +08:00
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
SET ( OUTPUT_LIBDIR ${ PROJECT_BINARY_DIR } /lib )
2007-03-09 17:07:05 +08:00
MAKE_DIRECTORY ( ${ OUTPUT_LIBDIR } )
2007-08-30 18:41:15 +08:00
IF ( NOT MSVC )
2008-01-29 02:29:38 +08:00
MAKE_DIRECTORY ( ${ OUTPUT_LIBDIR } / ${ OSG_PLUGINS } )
2007-08-30 18:41:15 +08:00
ENDIF ( NOT MSVC )
2007-03-09 17:07:05 +08:00
SET ( LIBRARY_OUTPUT_PATH ${ OUTPUT_LIBDIR } )
#SET(INSTALL_BINDIR OpenSceneGraph/bin)
#SET(INSTALL_INCDIR OpenSceneGraph/include)
#SET(INSTALL_LIBDIR OpenSceneGraph/lib)
#SET(INSTALL_DOCDIR OpenSceneGraph/doc)
################################################################################
# User Options
2007-04-27 18:29:48 +08:00
# Expose CMAKE_INCLUDE_PATH and CMAKE_LIBARY_PATH to the GUI so users
# may set these values without needing to manipulate the environment.
SET ( CMAKE_INCLUDE_PATH ${ CMAKE_INCLUDE_PATH } CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths." )
SET ( CMAKE_LIBRARY_PATH ${ CMAKE_LIBRARY_PATH } CACHE STRING "You may add additional search paths here. Use ; to separate multiple paths." )
# We are proposing that a new variable called CMAKE_PREFIX_PATH be introduced
# to CMake to compliment CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH.
# A formal feature request has been submited to CMake, Bug #4947.
# It is intended for those users who have common prefixes for their INCLUDE
# and LIBRARY locations. So if users have headers in /usr/local/include
# and libraries in /usr/local/lib, the common prefix is /usr/local.
# It should also cover the case where headers and libraries are
# in the same directory.
# Our proposal expects that FIND_* commands will automatically search for
# CMAKE_PREFIX_PATH right after CMAKE_INCLUDE_PATH or CMAKE_LIBRARY_PATH.
# Obviously, since CMake does not currently support this, we must write
# our Find*.cmake modules to explicitly support this. Otherwise, this variable
# will have no impact.
# This is unofficial so this may be removed or changed at anytime.
SET ( CMAKE_PREFIX_PATH ${ CMAKE_PREFIX_PATH } CACHE STRING "(EXPERIMENTAL) You may add additional search paths here. Use ; to separate multiple paths." )
2007-03-09 17:07:05 +08:00
# Dynamic vs Static Linking
OPTION ( DYNAMIC_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking. Use OFF for static." ON )
IF ( DYNAMIC_OPENSCENEGRAPH )
2007-04-11 16:33:40 +08:00
SET ( OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "SHARED" )
2007-03-09 17:07:05 +08:00
ELSE ( DYNAMIC_OPENSCENEGRAPH )
2007-04-11 16:33:40 +08:00
SET ( OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC "STATIC" )
2007-03-09 17:07:05 +08:00
ENDIF ( DYNAMIC_OPENSCENEGRAPH )
2007-03-19 20:30:26 +08:00
INCLUDE ( OsgMacroUtils )
2007-03-09 17:07:05 +08:00
# OSG Core
ADD_SUBDIRECTORY ( src )
# OSG Applications
OPTION ( BUILD_OSG_APPLICATIONS "Enable to build OSG Applications (e.g. osgviewer)" ON )
IF ( BUILD_OSG_APPLICATIONS )
2007-04-11 16:33:40 +08:00
ADD_SUBDIRECTORY ( applications )
2007-03-09 17:07:05 +08:00
ENDIF ( BUILD_OSG_APPLICATIONS )
# OSG Examples
OPTION ( BUILD_OSG_EXAMPLES "Enable to build OSG Examples" OFF )
IF ( BUILD_OSG_EXAMPLES )
2007-04-11 16:33:40 +08:00
ADD_SUBDIRECTORY ( examples )
2007-03-09 17:07:05 +08:00
ENDIF ( BUILD_OSG_EXAMPLES )
2007-04-11 16:35:39 +08:00
# This is for an advanced option to give aggressive warnings
# under different compilers. If yours is not implemented, this option
# will not be made available.
IF ( CMAKE_COMPILER_IS_GNUCXX )
# To be complete, we might also do GNUCC flags,
# but everything here is C++ code.
# -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
# returns too many hits.
2007-04-12 18:06:09 +08:00
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
2007-04-11 16:35:39 +08:00
# interesting C-specific flag.
2007-04-25 17:14:01 +08:00
# Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
# errors instead of warnings for certain issues, including superfluous
# semicolons and commas, and the use of long long. -fpermissive seems
# to be the workaround.
2007-09-07 21:54:32 +08:00
SET ( OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive" )
2007-04-11 16:35:39 +08:00
ELSE ( CMAKE_COMPILER_IS_GNUCXX )
IF ( MSVC )
# FIXME: What are good aggressive warning flags for Visual Studio?
# And do we need to further subcase this for different versions of VS?
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
SET ( OSG_AGGRESSIVE_WARNING_FLAGS "/Wall /W4" )
2007-08-30 18:41:15 +08:00
2007-04-11 16:35:39 +08:00
ELSE ( MSVC )
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
# remain unset.
ENDIF ( MSVC )
ENDIF ( CMAKE_COMPILER_IS_GNUCXX )
# This part is for the CMake menu option to toggle the warnings on/off.
# This will only be made available if we set values for OSG_AGGRESSIVE_WARNING_FLAGS.
IF ( OSG_AGGRESSIVE_WARNING_FLAGS )
OPTION ( OSG_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" OFF )
MARK_AS_ADVANCED ( OSG_USE_AGGRESSIVE_WARNINGS )
IF ( OSG_USE_AGGRESSIVE_WARNINGS )
IF ( NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}" )
SET ( OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "Old CXX flags" )
SET ( OLD_CMAKE_CXX_FLAGS_WAS_SET 1 CACHE INTERNAL "Old CXX flags was set" )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OSG_AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE )
ENDIF ( NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}" )
ELSE ( OSG_USE_AGGRESSIVE_WARNINGS )
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
# set. The better way would be to parse the string and remove each
# option explicitly.
IF ( "${OLD_CMAKE_CXX_FLAGS_WAS_SET}" )
SET ( CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE )
SET ( OLD_CMAKE_CXX_FLAGS_WAS_SET 0 CACHE INTERNAL "Old CXX flags was set" )
ENDIF ( "${OLD_CMAKE_CXX_FLAGS_WAS_SET}" )
ENDIF ( OSG_USE_AGGRESSIVE_WARNINGS )
ENDIF ( OSG_AGGRESSIVE_WARNING_FLAGS )
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
IF ( APPLE )
# These are just defaults/recommendations, but how we want to build
# out of the box. But the user needs to be able to change these options.
# So we must only set the values the first time CMake is run, or we
# will overwrite any changes the user sets.
# FORCE is used because the options are not reflected in the UI otherwise.
# Seems like a good place to add version specific compiler flags too.
2007-04-25 17:14:01 +08:00
IF ( NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE )
2007-04-11 16:35:39 +08:00
# This is really fragile, but CMake doesn't provide the OS system
# version information we need. (Darwin versions can be changed
# independently of OS X versions.)
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
IF ( EXISTS /Developer/SDKs/10.5.sdk )
SET ( CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE )
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 )
ELSE ( EXISTS /Developer/SDKs/10.5.sdk )
IF ( EXISTS /Developer/SDKs/MacOSX10.4u.sdk )
SET ( CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE )
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 )
ELSE ( EXISTS /Developer/SDKs/MacOSX10.4u.sdk )
# No Universal Binary support
# Should break down further to set the -mmacosx-version-min,
# but the SDK detection is too unreliable here.
ENDIF ( EXISTS /Developer/SDKs/MacOSX10.4u.sdk )
ENDIF ( EXISTS /Developer/SDKs/10.5.sdk )
2007-04-25 17:14:01 +08:00
ENDIF ( NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE )
2007-06-05 05:02:15 +08:00
OPTION ( OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF )
2007-04-11 16:35:39 +08:00
ENDIF ( APPLE )
2007-03-09 17:07:05 +08:00
2008-01-29 02:29:38 +08:00
OPTION ( BUILD_REF_DOCS "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF )
2008-01-21 22:41:58 +08:00
2008-01-29 02:29:38 +08:00
IF ( BUILD_REF_DOCS )
2008-01-21 22:41:58 +08:00
SET ( BUILD_DOCUMENTATION YES )
2008-01-29 02:29:38 +08:00
OPTION ( BUILD_REF_DOCS_SEARCHENGINE "Enable doxygen's search engine (requires that documentation to be installed on a php enabled web server)" OFF )
OPTION ( BUILD_REF_DOCS_TAGFILE "Generate a tag file named osg.tag on the documentation web server" OFF )
ENDIF ( BUILD_REF_DOCS )
2008-01-21 22:41:58 +08:00
2007-03-09 17:07:05 +08:00
# For Doxygen
#FIXME: I haven't figured out what to do with OSG's multiple doxyfiles
# and footer.
INCLUDE ( ${ CMAKE_ROOT } /Modules/Documentation.cmake OPTIONAL )
2008-01-29 02:29:38 +08:00
OPTION ( BUILD_DOCUMENTATION "Build osg documentation" OFF )
2007-03-09 17:07:05 +08:00
# To build the documention, you will have to enable it
# and then do the equivalent of "make DoxygenDoc".
IF ( BUILD_DOCUMENTATION )
2008-01-21 22:41:58 +08:00
SET ( BUILD_DOCUMENTATION YES )
2008-01-29 02:29:38 +08:00
IF ( BUILD_REF_DOCS )
SET ( SEARCHENGINE YES )
ELSE ( BUILD_REF_DOCS )
SET ( SEARCHENGINE NO )
ENDIF ( BUILD_REF_DOCS )
IF ( BUILD_REF_DOCS_TAGFILE )
SET ( GENERATE_TAGFILE "doc/OpenSceneGraphReferenceDocs/osg.tag" )
ELSE ( BUILD_REF_DOCS_TAGFILE )
SET ( GENERATE_TAGFILE "" )
ENDIF ( BUILD_REF_DOCS_TAGFILE )
2007-04-11 16:33:40 +08:00
IF ( DOT )
SET ( HAVE_DOT YES )
ELSE ( DOT )
SET ( HAVE_DOT NO )
ENDIF ( DOT )
# This processes our Doxyfile.in and substitutes paths to generate
# a final Doxyfile
CONFIGURE_FILE ( ${ PROJECT_SOURCE_DIR } /doc/Doxyfiles/doxyfile.cmake
$ { P R O J E C T _ B I N A R Y _ D I R } / d o c / d o x y f i l e
)
# This creates a new target to build documentation.
# It runs ${DOXYGEN} which is the full path and executable to
# Doxygen on your system, set by the FindDoxygen.cmake module
# (called by FindDocumentation.cmake).
# It runs the final generated Doxyfile against it.
# The DOT_PATH is substituted into the Doxyfile.
ADD_CUSTOM_TARGET ( DoxygenDoc ${ DOXYGEN }
2007-12-24 20:56:19 +08:00
$ { P R O J E C T _ B I N A R Y _ D I R } / d o c / d o x y f i l e
2007-04-11 16:33:40 +08:00
)
2007-03-09 17:07:05 +08:00
ENDIF ( BUILD_DOCUMENTATION )
2007-04-11 16:35:39 +08:00
# This needs to be run very last so other parts of the scripts can take
# advantage of this.
2007-04-25 17:14:01 +08:00
IF ( NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE )
2007-04-11 16:35:39 +08:00
SET ( OSG_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" )
2007-04-25 17:14:01 +08:00
ENDIF ( NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE )
2007-04-11 16:35:39 +08:00
2007-05-17 19:48:30 +08:00
#-----------------------------------------------------------------------------
### uninstall target
#-----------------------------------------------------------------------------
CONFIGURE_FILE (
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C M a k e M o d u l e s / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
ADD_CUSTOM_TARGET ( uninstall
" $ { C M A K E _ C O M M A N D } " - P " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e " )