diff --git a/CMakeLists.txt b/CMakeLists.txt index 84c68dcd8..2d0101c71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,6 @@ IF(WIN32) ELSE(WIN32) IF(APPLE) CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) - 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) ELSE(APPLE) CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0 FATAL_ERROR) ENDIF(APPLE) @@ -197,7 +194,7 @@ IF(WIN32) ADD_DEFINITIONS(-DNOMINMAX) ENDIF(UNIX) ######################################################################################################## -# the foolowing options are MSVC specific, +# the following 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 @@ -260,7 +257,7 @@ MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX) OPTION(OSG_USE_UTF8_FILENAME "Set to ON to use a UTF8 locale for filenames instead of the default locale." OFF) MARK_AS_ADVANCED(OSG_USE_UTF8_FILENAME) -OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC wartnings genertated by OSG headers." ON) +OPTION(OSG_DISABLE_MSVC_WARNINGS "Set to OFF to not disable MSVC warnings generated by OSG headers." ON) MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS) OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON) @@ -518,6 +515,57 @@ SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE STRING "You may add additiona # 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.") +# 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. + # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another + # interesting C-specific flag. + # 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. + SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive") +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 "/W4") + + + 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" ON) + MARK_AS_ADVANCED(OSG_USE_AGGRESSIVE_WARNINGS) + + IF(OSG_USE_AGGRESSIVE_WARNINGS) + # Add flags defined by OSG_AGGRESSIVE_WARNING_FLAGS if they aren't already there + FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS}) + IF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") + ENDIF(NOT CMAKE_CXX_FLAGS MATCHES "${flag}") + ENDFOREACH(flag) + ELSE(OSG_USE_AGGRESSIVE_WARNINGS) + # Remove all flags considered aggresive + FOREACH(flag ${OSG_AGGRESSIVE_WARNING_FLAGS}) + STRING(REGEX REPLACE "${flag}" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + ENDFOREACH(flag) + ENDIF(OSG_USE_AGGRESSIVE_WARNINGS) +ENDIF(OSG_AGGRESSIVE_WARNING_FLAGS) + # Dynamic vs Static Linking OPTION(DYNAMIC_OPENSCENEGRAPH "Set to ON to build OpenSceneGraph for dynamic linking. Use OFF for static." ON) @@ -543,58 +591,6 @@ IF (BUILD_OSG_EXAMPLES) ADD_SUBDIRECTORY(examples) ENDIF(BUILD_OSG_EXAMPLES) -# 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. - # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another - # interesting C-specific flag. - # 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. - SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive") -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 "/W4 /wd4706 /wd4127") - - 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" ON) - 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)