diff options
author | Kevin Funk <kfunk@kde.org> | 2016-12-29 12:23:20 +0100 |
---|---|---|
committer | Kevin Funk <kfunk@kde.org> | 2017-01-16 08:46:43 +0100 |
commit | a5f3a76e14799c68b5e8f74e375baa5f6f6ab4dc (patch) | |
tree | 9d7ddcf483386c471fcf09aaea25cf7298d28256 /kde-modules | |
parent | 01f52b2b03f9e2050cc47ba58f48948ac29d1d77 (diff) | |
download | extra-cmake-modules-a5f3a76e14799c68b5e8f74e375baa5f6f6ab4dc.tar.gz extra-cmake-modules-a5f3a76e14799c68b5e8f74e375baa5f6f6ab4dc.tar.bz2 |
Pass -fno-operator-names when supported
Summary:
Disables alternative tokens for &&, ||, etc.. They're are not supported
by MSVC out of the box, thus using them will limit the portability of
the code. There *are* options to make alternative tokens available under
MSVC [1], but I think we shouldn't promote the usage of them.
From the GCC documentation:
-fno-operator-names: Do not treat the operator name keywords and,
bitand, bitor, compl, not, or and xor as synonyms as keywords.
[1] http://stackoverflow.com/questions/555505/when-were-the-and-and-or-alternative-tokens-introduced-in-c
Reviewers: #frameworks, #buildsystem, ivan
Reviewed By: ivan
Subscribers: rakuco, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D3850
Diffstat (limited to 'kde-modules')
-rw-r--r-- | kde-modules/KDECompilerSettings.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 24eea3a7..583dfb57 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -211,6 +211,14 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-common") endif() +# Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords. +# They're not supported under Visual Studio out of the box thus using them limits the portability of code +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID STREQUAL "Clang" OR + (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32)) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names") +endif() + # Default to hidden visibility for symbols set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) |