diff --git a/CMakeLists.txt b/CMakeLists.txt index 5569866e1..1ccd7b156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -824,10 +824,25 @@ ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # remain unset. IF (APPLE) - # set standard lib, clang defaults to c++0x - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++ -Wno-overloaded-virtual -Wno-conversion") + SET(OSG_CXX_LANGUAGE_STANDARD "C++11" CACHE STRING "set the c++ language standard (C++98 / C++11) for OSG" ) + MARK_AS_ADVANCED(OSG_CXX_LANGUAGE_STANDARD) + # remove existing flags + REMOVE_CXX_FLAG(-std=c++98) + REMOVE_CXX_FLAG(-std=c++11) + REMOVE_CXX_FLAG(-stdlib=libstdc++) + REMOVE_CXX_FLAG(-stdlib=libc++) + + IF(${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "c++98" OR ${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "C++98") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++") + ELSE() + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") + ENDIF() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-conversion") set(WARNING_CFLAGS "") ENDIF() ENDIF() diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 7575995ab..835457106 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -532,3 +532,7 @@ MACRO(HANDLE_MSVC_DLL) # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/osg${OPENSCENEGRAPH_SOVERSION}-") # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../") ENDMACRO(HANDLE_MSVC_DLL) + +MACRO(REMOVE_CXX_FLAG flag) + STRING(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +ENDMACRO()