Index: kde-modules/KDECompilerSettings.cmake =================================================================== --- kde-modules/KDECompilerSettings.cmake +++ kde-modules/KDECompilerSettings.cmake @@ -219,6 +219,31 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names") endif() +# allow projects that do require named operators to (re)activate them +# (this includes projects using boost) +function(KDE_ENABLE_NAMED_OPERATORS) + if (MSVC) + # calculation of CMAKE_CXX_COMPILER_VERSION (for recent versions): + # MSVC_VERSION/100 . MSVC_VERSION%100 . _MSC_FULL_VER%100000 + # VS2015 up3 thus becomes: + if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 19.0.24210) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Za") + elseif() + # /permissive- became the preferred switch to obtain standards-compliant + # behaviour somewhere after MSVC_VERSION 1900 (MSVC 2015 Update 3 to be exact; _MSC_FULL_VER==190024210) + # Note the trailing dash, that's not a typo! See: + # https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/ + # and + # https://blogs.msdn.microsoft.com/vcblog/2016/06/07/standards-version-switches-in-the-compiler/ + # https://sourceforge.net/p/predef/wiki/Compilers/ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") + endif() + else() + string(REPLACE "-fno-operator-names" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" PARENT_SCOPE) +endfunction() + # Default to hidden visibility for symbols set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden)