Only use -Werror for our code

This commit is contained in:
Nicolas Werner 2020-01-25 00:58:22 +01:00
parent 96ad385331
commit d9aac3ee19

View file

@ -6,11 +6,9 @@ option(ASAN "Compile with address sanitizers" OFF)
option(QML_DEBUGGING "Enable qml debugging" OFF) option(QML_DEBUGGING "Enable qml debugging" OFF)
set( set(
CMAKE_TOOLCHAIN_FILE CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
"${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
CACHE CACHE
FILEPATH FILEPATH "Default toolchain"
"Default toolchain"
) )
@ -121,9 +119,9 @@ if (APPLE)
endif(APPLE) endif(APPLE)
if (Qt5Widgets_FOUND) if (Qt5Widgets_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.7.0) if (Qt5Widgets_VERSION VERSION_LESS 5.9.0)
message(STATUS "Qt version ${Qt5Widgets_VERSION}") message(STATUS "Qt version ${Qt5Widgets_VERSION}")
message(WARNING "Minimum supported Qt5 version is 5.7!") message(WARNING "Minimum supported Qt5 version is 5.9!")
endif() endif()
endif(Qt5Widgets_FOUND) endif(Qt5Widgets_FOUND)
@ -146,9 +144,6 @@ if(NOT MSVC)
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
endif() endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif() endif()
if (MSVC) if (MSVC)
@ -477,30 +472,6 @@ qt5_wrap_cpp(MOC_HEADERS
include(Translations) include(Translations)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC}) set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
set(COMMON_LIBS
MatrixClient::MatrixClient
Boost::iostreams
Boost::system
Boost::thread
cmark::cmark
spdlog::spdlog
Qt5::Widgets
Qt5::Svg
Qt5::Concurrent
Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
Qt5::QuickWidgets
nlohmann_json::nlohmann_json
lmdbxx::lmdbxx
tweeny)
if(USE_BUNDLED_LMDB)
set(NHEKO_LIBS ${COMMON_LIBS} liblmdb::lmdb)
else()
set(NHEKO_LIBS ${COMMON_LIBS} PkgConfig::lmdb)
endif()
if (APPLE) if (APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa")
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm) set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm)
@ -531,23 +502,53 @@ if(ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
endif() endif()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
if(APPLE) if(APPLE)
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS}) target_link_libraries (nheko PRIVATE Qt5::MacExtras)
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::MacExtras)
elseif(WIN32) elseif(WIN32)
add_executable (nheko ${OS_BUNDLE} ${ICON_FILE} ${NHEKO_DEPS})
target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN) target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
target_link_libraries (nheko ${NTDLIB} ${NHEKO_LIBS} Qt5::WinMain) target_link_libraries (nheko PRIVATE ${NTDLIB} Qt5::WinMain)
else() else()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS}) target_link_libraries (nheko PRIVATE Qt5::DBus)
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::DBus)
endif() endif()
target_include_directories(nheko PRIVATE src includes) target_include_directories(nheko PRIVATE src includes)
target_link_libraries(nheko PRIVATE
MatrixClient::MatrixClient
Boost::iostreams
Boost::system
Boost::thread
cmark::cmark
spdlog::spdlog
Qt5::Widgets
Qt5::Svg
Qt5::Concurrent
Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
Qt5::QuickWidgets
nlohmann_json::nlohmann_json
lmdbxx::lmdbxx
tweeny)
if(USE_BUNDLED_LMDB)
target_link_libraries(nheko PRIVATE liblmdb::lmdb)
else()
target_link_libraries(nheko PRIVATE PkgConfig::lmdb)
endif()
if(QML_DEBUGGING) if(QML_DEBUGGING)
target_compile_definitions(nheko PRIVATE QML_DEBUGGING) target_compile_definitions(nheko PRIVATE QML_DEBUGGING)
endif() endif()
if(NOT MSVC)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
target_compile_options(nheko PRIVATE "-Werror")
endif()
endif()
set_target_properties(nheko PROPERTIES SKIP_BUILD_RPATH TRUE) set_target_properties(nheko PROPERTIES SKIP_BUILD_RPATH TRUE)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)