option(WindowsStaticLink "Windows/MSVC only: Link statically against the dependencies and set /MT instead of /MD" ON)
option(UsePrerenderedPDF "Use prerendered PDFs included in the source for testing, instead of building with pdflatex" OFF)
option(CodeCoverage "Add coverage analysis code to the program. Will slow it down. A lot. Only supported on GCC right now." OFF)
+option(WarningAsError "Turn on -Werror and similar compiler settings. This can be useful during development, but is disabled by default for release build scripts." OFF)
include(cmake/platforms.cmake)
include(cmake/filelists.cmake)
# Turn on a lot of warnings, hopefully helping with code quality.
add_definitions(-Weverything)
-# And turn them into errors.
-add_definitions(-Werror)
# Disable warnings irrelevant to the project:
# c++98 compatibility warnings
add_definitions(-Wno-unreachable-code -Wno-disabled-macro-expansion)
endif()
-# Qt's moc (Meta Object Compiler) generates code that triggers warnings
-# about undefined behaviours.
+if(WarningAsError)
+ # Turn warnings into errors.
+ add_definitions(-Werror)
-# So don't set Werror for it.
-# FIXME: Set this only for the automoc files
-add_definitions(-Wno-error=undefined-reinterpret-cast)
-add_definitions(-Wno-error=redundant-parens)
-add_definitions(-Wno-error=extra-semi-stmt)
+ # Qt's moc (Meta Object Compiler) generates code that triggers warnings
+ # about undefined behaviours.
-# FIXME: These are apple-clang specific
-add_definitions(-Wno-error=poison-system-directories)
-add_definitions("-Wno-error=#warnings")
+ # So don't set Werror for it.
+ # FIXME: Set this only for the automoc files
+ add_definitions(-Wno-error=undefined-reinterpret-cast)
+ add_definitions(-Wno-error=redundant-parens)
+ add_definitions(-Wno-error=extra-semi-stmt)
-# Clang on recent XCode fails to compile the boost tests
-add_definitions(-Wno-error=disabled-macro-expansion)
+ # FIXME: These are apple-clang specific
+ add_definitions(-Wno-error=poison-system-directories)
+ add_definitions("-Wno-error=#warnings")
+ # Clang on recent XCode fails to compile the boost tests
+ add_definitions(-Wno-error=disabled-macro-expansion)
+
+ # unit_test_log from boost::test will trigger this warning
+ add_definitions(-Wno-error=used-but-marked-unused)
+endif()
# clang will complain about -isystem passed but not used.
# This adds unnecessary noise
add_definitions(-Wno-unused-command-line-argument)
-# unit_test_log from boost::test will trigger this warning
-add_definitions(-Wno-error=used-but-marked-unused)
# qrc system generates code that triggers a lot of the
# clang warnings.
include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++20" C20FLAG)
+CHECK_CXX_COMPILER_FLAG("-std=c++17" C17FLAG)
+CHECK_CXX_COMPILER_FLAG("-std=c++14" C14FLAG)
CHECK_CXX_COMPILER_FLAG("-std=c++11" C11FLAG)
-if(C11FLAG)
+if(C20FLAG)
+ message(STATUS "Compiler supports -std=c++20, using it.")
+ add_definitions(-std=c++20)
+elseif(C17FLAG)
+ message(STATUS "Compiler supports -std=c++17, using it.")
+ add_definitions(-std=c++17)
+elseif(C14FLAG)
+ message(STATUS "Compiler supports -std=c++14, using it.")
+ add_definitions(-std=c++14)
+elseif(C11FLAG)
message(STATUS "Compiler supports -std=c++11, using it.")
add_definitions(-std=c++11)
else()
-Weffc++
)
-# Turn all warnings into errors
-add_definitions(-Werror -pedantic-errors)
+if(WarningAsError)
+ # Turn all warnings into errors
+ add_definitions(-Werror -pedantic-errors)
+endif()
if(CodeCoverage)
message(STATUS "Adding gcov as test coverage helper")