C++ CMake Qt模块禁用异常处理

C++ CMake Qt模块禁用异常处理,c++,qt,cmake,kde,C++,Qt,Cmake,Kde,My CMakeLists.txt包含: find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED) if (${QT4_FOUND}) include(${QT_USE_FILE}) include_directories(${QT_INCLUDE_DIR}) endif () find_package(KDE4 REQUIRED) if (${KDE4_FOUND}) include(KDE4Defaults)

My CMakeLists.txt包含:

find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)

if (${QT4_FOUND})
    include(${QT_USE_FILE})
    include_directories(${QT_INCLUDE_DIR})
endif ()

find_package(KDE4 REQUIRED)

if (${KDE4_FOUND})
    include(KDE4Defaults)
    include_directories(${KDE4_INCLUDE_DIR} ${KDE4_INCLUDES})
    link_directories(${KDE4_LIB_DIR})
endif ()
在构建过程中,它表示:

error: exception handling disabled, use -fexceptions to enable

我记得这个问题,我怀疑Qt添加了编译选项,但为什么呢?

我想您需要启用异常。您可以在
CMakeLists.txt中的下一行添加标志:

add_definitions( -Wall -O2 -fexceptions )

我想您需要启用异常。您可以在
CMakeLists.txt中的下一行添加标志:

add_definitions( -Wall -O2 -fexceptions )