cmake: build with exceptions disabled by default
Only re-enable exceptions for the modules that do CONFIG+=exceptions in qmake Change-Id: I9f19078adbdc1b8fa3d4102fb51a099e7e35522e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
fecd9d90da
commit
bfa209dfa5
@ -982,6 +982,21 @@ function(qt_internal_add_target_aliases target)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Sets the exceptions flags for the given target
|
||||||
|
function(qt_internal_set_no_exceptions_flags target)
|
||||||
|
target_compile_definitions("${target}" PRIVATE "QT_NO_EXCEPTIONS")
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
target_compile_options("${target}" PRIVATE "/wd4530 /wd4577")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
target_compile_options("${target}" PRIVATE "-fno-exceptions")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
|
target_compile_options("${target}" PRIVATE "-fno-exceptions")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
target_compile_options("${target}" PRIVATE "-fno-exceptions")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||||
|
target_compile_options("${target}" PRIVATE "-fno-exceptions")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# This is the main entry function for creating a Qt module, that typically
|
# This is the main entry function for creating a Qt module, that typically
|
||||||
# consists of a library, public header files, private header files and configurable
|
# consists of a library, public header files, private header files and configurable
|
||||||
@ -998,7 +1013,7 @@ function(add_qt_module target)
|
|||||||
|
|
||||||
# Process arguments:
|
# Process arguments:
|
||||||
qt_parse_all_arguments(arg "add_qt_module"
|
qt_parse_all_arguments(arg "add_qt_module"
|
||||||
"NO_MODULE_HEADERS;STATIC;DISABLE_TOOLS_EXPORT"
|
"NO_MODULE_HEADERS;STATIC;DISABLE_TOOLS_EXPORT;EXCEPTIONS"
|
||||||
"CONFIG_MODULE_NAME"
|
"CONFIG_MODULE_NAME"
|
||||||
"${__default_private_args};${__default_public_args};QMAKE_MODULE_CONFIG" ${ARGN})
|
"${__default_private_args};${__default_public_args};QMAKE_MODULE_CONFIG" ${ARGN})
|
||||||
|
|
||||||
@ -1118,6 +1133,9 @@ function(add_qt_module target)
|
|||||||
if(FEATURE_largefile)
|
if(FEATURE_largefile)
|
||||||
target_compile_definitions("${target}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
target_compile_definitions("${target}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT ${arg_EXCEPTIONS})
|
||||||
|
qt_internal_set_no_exceptions_flags("${target}")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
|
set(configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
|
||||||
if(EXISTS "${configureFile}")
|
if(EXISTS "${configureFile}")
|
||||||
@ -1355,7 +1373,7 @@ function(add_qt_plugin target)
|
|||||||
|
|
||||||
qt_internal_set_qt_known_plugins("${QT_KNOWN_PLUGINS}" "${target}")
|
qt_internal_set_qt_known_plugins("${QT_KNOWN_PLUGINS}" "${target}")
|
||||||
|
|
||||||
qt_parse_all_arguments(arg "add_qt_plugin" "STATIC"
|
qt_parse_all_arguments(arg "add_qt_plugin" "STATIC;EXCEPTIONS"
|
||||||
"TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY"
|
"TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY"
|
||||||
"${__default_private_args};${__default_public_args}" ${ARGN})
|
"${__default_private_args};${__default_public_args}" ${ARGN})
|
||||||
|
|
||||||
@ -1447,6 +1465,9 @@ function(add_qt_plugin target)
|
|||||||
if(FEATURE_largefile)
|
if(FEATURE_largefile)
|
||||||
target_compile_definitions("${target}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
target_compile_definitions("${target}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT ${arg_EXCEPTIONS})
|
||||||
|
qt_internal_set_no_exceptions_flags("${target}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(qt_libs_private "")
|
set(qt_libs_private "")
|
||||||
@ -1512,7 +1533,7 @@ endfunction()
|
|||||||
# Please consider to use a more specific version target like the one created
|
# Please consider to use a more specific version target like the one created
|
||||||
# by add_qt_test or add_qt_tool below.
|
# by add_qt_test or add_qt_tool below.
|
||||||
function(add_qt_executable name)
|
function(add_qt_executable name)
|
||||||
qt_parse_all_arguments(arg "add_qt_executable" "GUI;BOOTSTRAP;NO_QT;NO_INSTALL" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ARGN})
|
qt_parse_all_arguments(arg "add_qt_executable" "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ARGN})
|
||||||
|
|
||||||
if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
|
if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
|
||||||
set(arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}")
|
set(arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}")
|
||||||
@ -1561,6 +1582,9 @@ function(add_qt_executable name)
|
|||||||
if(FEATURE_largefile)
|
if(FEATURE_largefile)
|
||||||
target_compile_definitions("${name}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
target_compile_definitions("${name}" PRIVATE "_LARGEFILE64_SOURCE;_LARGEFILE_SOURCE")
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT ${arg_EXCEPTIONS})
|
||||||
|
qt_internal_set_no_exceptions_flags("${name}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -1579,10 +1603,15 @@ endfunction()
|
|||||||
|
|
||||||
# This function creates a CMake test target with the specified name for use with CTest.
|
# This function creates a CMake test target with the specified name for use with CTest.
|
||||||
function(add_qt_test name)
|
function(add_qt_test name)
|
||||||
qt_parse_all_arguments(arg "add_qt_test" "RUN_SERIAL" "" "${__default_private_args}" ${ARGN})
|
qt_parse_all_arguments(arg "add_qt_test" "RUN_SERIAL;EXCEPTIONS" "" "${__default_private_args}" ${ARGN})
|
||||||
set(path "${CMAKE_CURRENT_BINARY_DIR}")
|
set(path "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
||||||
|
if (${arg_EXCEPTIONS})
|
||||||
|
set(EXCEPTIONS_TEXT "EXCEPTIONS")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_qt_executable("${name}"
|
add_qt_executable("${name}"
|
||||||
|
${EXCEPTIONS_TEXT}
|
||||||
NO_INSTALL
|
NO_INSTALL
|
||||||
OUTPUT_DIRECTORY "${path}"
|
OUTPUT_DIRECTORY "${path}"
|
||||||
SOURCES "${arg_SOURCES}"
|
SOURCES "${arg_SOURCES}"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
add_qt_module(Concurrent
|
add_qt_module(Concurrent
|
||||||
|
EXCEPTIONS
|
||||||
SOURCES
|
SOURCES
|
||||||
qtconcurrent_global.h
|
qtconcurrent_global.h
|
||||||
qtconcurrentcompilertest.h
|
qtconcurrentcompilertest.h
|
||||||
|
@ -17,6 +17,7 @@ endif()
|
|||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
add_qt_module(Core
|
add_qt_module(Core
|
||||||
|
EXCEPTIONS
|
||||||
QMAKE_MODULE_CONFIG moc resources
|
QMAKE_MODULE_CONFIG moc resources
|
||||||
SOURCES
|
SOURCES
|
||||||
# special case: remove ../3rdparty/harfbuzz
|
# special case: remove ../3rdparty/harfbuzz
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
add_qt_module(Test
|
add_qt_module(Test
|
||||||
CONFIG_MODULE_NAME testlib # special case
|
CONFIG_MODULE_NAME testlib # special case
|
||||||
|
EXCEPTIONS
|
||||||
SOURCES
|
SOURCES
|
||||||
qabstracttestlogger.cpp qabstracttestlogger_p.h
|
qabstracttestlogger.cpp qabstracttestlogger_p.h
|
||||||
qasciikey.cpp
|
qasciikey.cpp
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
add_qt_test(tst_qglobalstatic
|
add_qt_test(tst_qglobalstatic
|
||||||
|
EXCEPTIONS
|
||||||
SOURCES
|
SOURCES
|
||||||
tst_qglobalstatic.cpp
|
tst_qglobalstatic.cpp
|
||||||
DEFINES
|
DEFINES
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
add_qt_executable(exceptionthrow
|
add_qt_executable(exceptionthrow
|
||||||
|
EXCEPTIONS
|
||||||
NO_INSTALL # special case
|
NO_INSTALL # special case
|
||||||
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
|
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
|
||||||
GUI
|
GUI
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
add_qt_executable(verifyexceptionthrown
|
add_qt_executable(verifyexceptionthrown
|
||||||
|
EXCEPTIONS
|
||||||
NO_INSTALL # special case
|
NO_INSTALL # special case
|
||||||
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
|
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
|
||||||
GUI
|
GUI
|
||||||
|
@ -1545,6 +1545,9 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str,
|
|||||||
# Evaluate total condition of all scopes:
|
# Evaluate total condition of all scopes:
|
||||||
recursive_evaluate_scope(scope)
|
recursive_evaluate_scope(scope)
|
||||||
|
|
||||||
|
if 'exceptions' in scope.get('CONFIG'):
|
||||||
|
extra_lines.append('EXCEPTIONS')
|
||||||
|
|
||||||
# Get a flat list of all scopes but the main one:
|
# Get a flat list of all scopes but the main one:
|
||||||
scopes = flatten_scopes(scope)
|
scopes = flatten_scopes(scope)
|
||||||
total_scopes = len(scopes)
|
total_scopes = len(scopes)
|
||||||
|
Loading…
Reference in New Issue
Block a user