Amend2 26fa3b3d: Added support for sanity checks (Option LYX_ENABLE_ASSERTIONS)

This commit is contained in:
Kornel Benko 2020-07-13 13:51:44 +02:00
parent bdaad972cf
commit 25b4229c58

View File

@ -141,15 +141,18 @@ list(GET _version_list 4 LYX_RELEASE_PATCH)
if(LYX_BUILD_TYPE STREQUAL "development")
set(DefaultLyxDebug ON)
set(DefaultLyxRelease OFF)
set(DefaultStdlibDebug ON)
set(DefaultLyxStdlibDebug ON)
set(DefaultLyxEnableAssertions ON)
elseif(LYX_BUILD_TYPE STREQUAL "prerelease")
set(DefaultLyxDebug OFF)
set(DefaultLyxRelease OFF)
set(DefaultStdlibDebug OFF)
set(DefaultLyxStdlibDebug OFF)
set(DefaultLyxEnableAssertions OFF)
elseif(LYX_BUILD_TYPE STREQUAL "release")
set(DefaultLyxDebug OFF)
set(DefaultLyxRelease ON)
set(DefaultStdlibDebug OFF)
set(DefaultLyxStdlibDebug OFF)
set(DefaultLyxEnableAssertions OFF)
else()
message(FATAL_ERROR "Unknown build type (${LYX_BUILD_TYPE}) encountered")
endif()
@ -173,6 +176,7 @@ LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL)
LYX_OPTION(RELEASE "Build release version, build debug when disabled" ${DefaultLyxRelease} ALL)
LYX_OPTION(DEBUG "Enforce debug build" ${DefaultLyxDebug} ALL)
LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL)
LYX_OPTION(ENABLE_ASSERTIONS "Run sanity checks in the program" ${DefaultLyxEnableAssertions} ALL)
LYX_OPTION(PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL)
LYX_STRING(SUFFIX_VALUE "Use this string as suffix" "")
LYX_OPTION(PCH "Use precompiled headers" OFF ALL)
@ -209,7 +213,7 @@ LYX_OPTION(EXTERNAL_BOOST "Use external boost" OFF GCC)
LYX_OPTION(PROGRAM_SUFFIX "Append version suffix to binaries" ON GCC)
LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC)
LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" ${DefaultStdlibDebug} GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" ${DefaultLyxStdlibDebug} GCC)
# MSVC specific
LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC)
@ -644,17 +648,24 @@ else()
set(library_type STATIC)
endif()
if(LYX_ENABLE_ASSERTIONS)
set(LYX_CXX_FLAGS " -DENABLE_ASSERTIONS=1")
else()
set(LYX_CXX_FLAGS "")
endif()
if(MSVC)
if (CXX11_FLAG MATCHES "\\+\\+([0-9]+)")
set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${LYX_CXX_FLAGS}")
else()
if(NOT LYX_QUIET)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
if(LYX_CXX_FLAGS MATCHES "\\+\\+(14|11|98)")
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
if(LYX_GCC11_MODE MATCHES "\\+\\+(14|11|98)")
# Thanks to Brad King <brad.king@kitware.com>
# for the pointer to https://cmake.org/cmake/help/v3.6/variable/CMAKE_CXX_STANDARD.html
# This allows us to use QT5.7 with recent g++ (version >= 4.9) compilers