diff --git a/adm/cmake/occt_defs_flags.cmake b/adm/cmake/occt_defs_flags.cmake index 484002d1aa..0ed941e496 100644 --- a/adm/cmake/occt_defs_flags.cmake +++ b/adm/cmake/occt_defs_flags.cmake @@ -111,7 +111,18 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMP endif() endif() -if(MINGW) +if ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") + if (APPLE) + # CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated. + set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}") + elseif(NOT WIN32) + # CLang for Windows (at least CLang 8.0 distributed with VS 2019) + # does not support option "-std=c++0x" + set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") + endif() + # Optimize size of binaries + set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS}") +elseif(MINGW) # Set default release optimization option to O2 instead of O3, since in # some OCCT related examples, this gives significantly smaller binaries # at comparable performace with MinGW-w64. @@ -122,25 +133,19 @@ if(MINGW) set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") endif() - set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}") add_definitions(-D_WIN32_WINNT=0x0501) # workaround bugs in mingw with vtable export set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols") -elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") - if (APPLE) - # CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated. - set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}") - elseif(NOT WIN32) - # CLang for Windows (at least CLang 8.0 distributed with VS 2019) - # does not support option "-std=c++0x" - set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") - endif() -elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX) - set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") -endif() -# Optimize size of binaries -if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR MINGW) + # Require C++11 + set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}") + # Optimize size of binaries + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") + set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") +elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX) + # Require C++11 + set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") + # Optimize size of binaries set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") endif()