X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=90853559a82efc4eef4b400dd2ec9c247acb8d7a;hb=3d46cc302bcff979a874ef2ea9c8a56a85aaec77;hp=2ffe6d3f2612203671417d9e49c7529c5e8f959a;hpb=bdaad972cfe638e15df90ce9e41ff3a9463ff333;p=lyx.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ffe6d3f26..90853559a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 3.1.0) +set(CMAKE_CXX_STANDARD 20) +set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017) +set(LYX_USE_QT "QT5") +set(LYX_REQUIRE_SPELLCHECK true) + set(LYX_PROJECT LyX) # Instruct cmake to not use gnu extensions, @@ -136,30 +141,56 @@ list(GET _version_list 4 LYX_RELEASE_PATCH) # 3. parameter: default value, ON or OFF # 4. parameter: system on which option is used: ALL, GCC, MSVC, ... +# Usage LYX_COMBO +# 1. parameter: name without prefix 'LYX_' +# 2. parameter: description +# 3. parameter: default value +# 4-n parameter: possible other string values + +LYX_OPTION_INIT() +LYX_COMBO(ENABLE_BUILD_TYPE "Allows to tweak the compiled code" AUTO release prerelease development gprof) + +if(LYX_ENABLE_BUILD_TYPE MATCHES "AUTO") + message(STATUS "Selecting build type defaults from configure.ac") +else() + set(LYX_BUILD_TYPE "${LYX_ENABLE_BUILD_TYPE}") + message(STATUS "Selecting build type defaults from LYX_ENABLE_BUILD_TYPE") +endif() # Select some defaults depending on LYX_BUILD_TYPE +# they can always be overwritten by the respective command line settings +# These settings are only effective on fresh(==empty) CMakeCache.txt if(LYX_BUILD_TYPE STREQUAL "development") set(DefaultLyxDebug ON) set(DefaultLyxRelease OFF) - set(DefaultStdlibDebug ON) + set(DefaultLyxStdlibDebug ON) + set(DefaultLyxEnableAssertions ON) + set(DefaultLyxProfile OFF) + set(DefaultExternalLibs OFF) elseif(LYX_BUILD_TYPE STREQUAL "prerelease") set(DefaultLyxDebug OFF) set(DefaultLyxRelease OFF) - set(DefaultStdlibDebug OFF) + set(DefaultLyxStdlibDebug OFF) + set(DefaultLyxEnableAssertions OFF) + set(DefaultLyxProfile OFF) + set(DefaultExternalLibs ON) elseif(LYX_BUILD_TYPE STREQUAL "release") set(DefaultLyxDebug OFF) set(DefaultLyxRelease ON) - set(DefaultStdlibDebug OFF) + set(DefaultLyxStdlibDebug OFF) + set(DefaultLyxEnableAssertions OFF) + set(DefaultLyxProfile OFF) + set(DefaultExternalLibs ON) +elseif(LYX_BUILD_TYPE STREQUAL "gprof") + set(DefaultLyxDebug ON) + set(DefaultLyxRelease OFF) + set(DefaultLyxStdlibDebug OFF) + set(DefaultLyxEnableAssertions OFF) + set(DefaultLyxProfile ON) + set(DefaultExternalLibs OFF) else() - message(FATAL_ERROR "Unknown build type (${LYX_BUILD_TYPE}) encountered") + message(FATAL_ERROR "Invalid build type (${LYX_BUILD_TYPE}) encountered") endif() -# Usage LYX_COMBO -# 1. parameter: name without prefix 'LYX_' -# 2. parameter: description -# 3. parameter: default value -# 4-n parameter: possible other string values - -LYX_OPTION_INIT() # Options for all compilers/systems LYX_OPTION(CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL) @@ -173,6 +204,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) @@ -197,19 +229,19 @@ LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5) LYX_COMBO(USE_IPO "Interprocedural optimization" OFF AUTO ON) #LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL) LYX_OPTION(DISABLE_CALLSTACK_PRINTING "do not print a callstack when crashing" OFF ALL) -LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ON ALL) -LYX_OPTION(EXTERNAL_DTL "OFF := Build 3rdparty commands dt2dv and dv2dt" ON ALL) -LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ON ALL) -LYX_OPTION(EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ON ALL) +LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ${DefaultExternalLibs} ALL) +LYX_OPTION(EXTERNAL_DTL "OFF := Build 3rdparty commands dt2dv and dv2dt" ${DefaultExternalLibs} ALL) +LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ${DefaultExternalLibs} ALL) +LYX_OPTION(EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ${DefaultExternalLibs} ALL) LYX_COMBO(EXTERNAL_MYTHES "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON) # GCC specific -LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC) -LYX_OPTION(EXTERNAL_BOOST "Use external boost" OFF GCC) +LYX_OPTION(PROFILE "Build with options for gprof" ${DefaultLyxProfile} GCC) +LYX_OPTION(EXTERNAL_BOOST "Use external boost" ${DefaultExternalLibs} 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 +676,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 # 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 @@ -681,6 +720,16 @@ else() endif() endif() +if(LYX_ASAN) + set(CMAKE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g ${CMAKE_CXX_FLAGS}") + message(STATUS) + message(STATUS "Address sanitizer enabled. Usage:") + message(STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py") + message(STATUS " chmod +x ./asan_symbolize.py") + message(STATUS " ./bin/${_lyx} 2>&1 | ./asan_symbolize.py | c++filt ") + message(STATUS) +endif() + set(LYX_CXX_FLAGS_EXTRA "" CACHE STRING "Desired semicolon separated list of extra cxx compile flags, like '-Werror'") mark_as_advanced(LYX_CXX_FLAGS_EXTRA) if(LYX_CXX_FLAGS_EXTRA) @@ -783,7 +832,7 @@ set(Include_used_spellchecker) # String will be inserted into config.h if (LYX_EXTERNAL_MYTHES MATCHES "AUTO") # try system library first - find_package(MyThesLIB) + find_package(MYTHESLIB) if (MYTHESLIB_FOUND) set(LYX_EXTERNAL_MYTHES ON CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE) else() @@ -791,7 +840,7 @@ if (LYX_EXTERNAL_MYTHES MATCHES "AUTO") endif() endif() if (LYX_EXTERNAL_MYTHES MATCHES "ON") - find_package(MyThesLIB REQUIRED) + find_package(MYTHESLIB REQUIRED) else() add_subdirectory(3rdparty/mythes) endif() @@ -1028,9 +1077,9 @@ if(MSVC) # add here warnings which should be disabled /wdXXXX set(MSVC_W_DISABLE "/wd4288 /wd4355 /wd4800 /wd4996 /wd4311 /wd4312 /wd4505 /wd4267 /wd4512 /wd4245 /wd4127 /wd4180 /wd4231") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") else() set(CMAKE_CXX_WARNING_LEVEL 3 CACHE STRING "Warning level" FORCE) @@ -1138,16 +1187,6 @@ endif () add_custom_target (lyx_run_tests COMMAND ${cmd}) set_target_properties(lyx_run_tests PROPERTIES FOLDER "tests") -if(LYX_ASAN) - set(LYX_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g") - message(STATUS) - message(STATUS "Address sanitizer enabled. Usage:") - message(STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py") - message(STATUS " chmod +x ./asan_symbolize.py") - message(STATUS " ./bin/lyx2.2 2>&1 | ./asan_symbolize.py | c++filt ") - message(STATUS) -endif() - if(LYX_INSTALL) if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND") message(STATUS "Python required to create doc!")