[kdelibs/KDE/4.11] cmake/modules: Always enable exceptions when building with clang.
Raphael Kubo da Costa
rakuco at FreeBSD.org
Sun Nov 17 23:33:39 UTC 2013
Git commit daa54a25217cb1061708e4868426cbab950944d9 by Raphael Kubo da Costa.
Committed on 17/11/2013 at 23:23.
Pushed by rkcosta into branch 'KDE/4.11'.
Always enable exceptions when building with clang.
Passing -fdelayed-template-parsing to clang to work around the issue of code
that includes non-instantiated templates that throw exceptions causes a lot
of problems, as described in
http://lists.kde.org/?l=kde-core-devel&m=138157459706783&w=2.
Instead of adding workarounds, just enable exceptions by default and live
with the fact that the generated code will be slightly larger.
CCMAIL: kde-buildsystem at kde.org
M +12 -11 cmake/modules/FindKDE4Internal.cmake
http://commits.kde.org/kdelibs/daa54a25217cb1061708e4868426cbab950944d9
diff --git a/cmake/modules/FindKDE4Internal.cmake b/cmake/modules/FindKDE4Internal.cmake
index c343393..784f18e 100644
--- a/cmake/modules/FindKDE4Internal.cmake
+++ b/cmake/modules/FindKDE4Internal.cmake
@@ -1323,7 +1323,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${_dirs})
+ # Note that exceptions are enabled by default when building with clang. That
+ # is, -fno-exceptions is not set in CMAKE_CXX_FLAGS below. This is because a
+ # lot of code in different KDE modules ends up including code that throws
+ # exceptions. Most (or all) of the occurrences are in template code that
+ # never gets instantiated. Contrary to GCC, ICC and MSVC, clang (most likely
+ # rightfully) complains about that. Trying to work around the issue by
+ # passing -fdelayed-template-parsing brings other problems, as noted in
+ # http://lists.kde.org/?l=kde-core-devel&m=138157459706783&w=2.
+ # The generated code will be slightly bigger, but there is no way to avoid
+ # it.
set(KDE4_ENABLE_EXCEPTIONS "-fexceptions -UQT_NO_EXCEPTIONS")
+
# Select flags.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG")
@@ -1337,19 +1348,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
- # As of Qt 4.6.x we need to override the new exception macros if we want compile with -fno-exceptions
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-exceptions -DQT_NO_EXCEPTIONS -fno-common -fvisibility=hidden -Werror=return-type -fvisibility-inlines-hidden")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -fvisibility=hidden -Werror=return-type -fvisibility-inlines-hidden")
set(KDE4_C_FLAGS "-fvisibility=hidden")
- # There is a lot of code out there that includes headers that throw
- # exceptions, but we disable exceptions by default.
- # GCC, MSVC and ICC do not complain about these cases when the exceptions
- # are thrown inside some template code that is not expanded/used, which is
- # what happens most of the time.
- # We have to follow suit and be less strict in order not to break the build
- # in many places.
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdelayed-template-parsing")
-
# At least kdepim exports one function with C linkage that returns a
# QString in a plugin, but clang does not like that.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
More information about the Kde-buildsystem
mailing list