]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Fix for crash/segfault introduced with [244de5d2/lyxgit], thanks Guillame.
[lyx.git] / CMakeLists.txt
index 3c9ab63bc997570a9586d0e79582b8420650870e..f9fe75902052f1716d554f6781186c0ae85edef5 100644 (file)
@@ -125,7 +125,7 @@ LYX_OPTION(REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL)
 LYX_OPTION(ASPELL           "Require aspell" OFF ALL)
 LYX_OPTION(ENCHANT          "Require Enchant" OFF ALL)
 LYX_OPTION(HUNSPELL         "Require Hunspell" OFF ALL)
-LYX_OPTION(DEVEL_VERSION    "Build developer version" OFF ALL) 
+LYX_OPTION(DEVEL_VERSION    "Build developer version" OFF ALL)
 LYX_OPTION(RELEASE          "Build release version, build debug when disabled" OFF ALL)
 LYX_OPTION(DEBUG            "Enforce debug build"  OFF ALL)
 LYX_OPTION(NO_OPTIMIZE      "Don't use any optimization/debug flags"  OFF ALL)
@@ -139,9 +139,14 @@ LYX_OPTION(INSTALL_PREFIX   "Install path for LyX" OFF ALL)
 LYX_OPTION(BUNDLE           "Build bundle  (experimental) " OFF ALL)
 LYX_OPTION(ENABLE_URLTESTS  "Enable for URL tests" OFF ALL)
 LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL)
+LYX_OPTION(ENABLE_KEYTESTS  "Enable for keytests" OFF ALL)
 LYX_OPTION(ASAN             "Use address sanitizer" OFF ALL)
 LYX_COMBO(USE_QT            "Use Qt version as frontend" QT4 QT5)
-LYX_OPTION(3RDPARTY_BUILD   "Build 3rdparty libs" OFF ALL)
+#LYX_OPTION(3RDPARTY_BUILD   "Build 3rdparty libs" OFF ALL)
+LYX_OPTION(EXTERNAL_Z       "OFF := Build 3rdparty lib zlib" 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_COMBO(EXTERNAL_MYTHES   "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON)
 
 # GCC specific
 LYX_OPTION(PROFILE              "Build profile version" OFF GCC)
@@ -207,7 +212,6 @@ else()
        set(LYX_MERGE_REBUILD OFF)
 endif()
 
-
 if(LYX_DEPENDENCIES_DOWNLOAD)
        message(STATUS)
        if(MSVC14)
@@ -281,7 +285,7 @@ if(UNIX OR MINGW)
                  # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
                  set(LYX_USE_STD_REGEX 0)
          else()
-                 set(LYX_USE_STD_REGEX 1)
+                 set(LYX_USE_STD_REGEX 0)
          endif()
        endif()
        set(LYX_GCC11_MODE "${CXX11_FLAG}")
@@ -312,6 +316,15 @@ else()
        set(USE_POSIX_PACKAGING ON)
 endif()
 
+if(LYX_3RDPARTY_BUILD)
+  # LYX_3RDPARTY_BUILD is not cached anymore, but for compatibility reasons
+  # this enables the build of all 3rd_party libs
+  set(LYX_EXTERNAL_Z        OFF CACHE BOOL "Build 3rdparty lib zlib"    FORCE)
+  set(LYX_EXTERNAL_ICONV    OFF CACHE BOOL "Build 3rdparty iconvlib"    FORCE)
+  set(LYX_EXTERNAL_HUNSPELL OFF CACHE BOOL "Build 3rdparty hunspelllib" FORCE)
+  set(LYX_EXTERNAL_MYTHES   OFF CACHE STRING "Build 3rdparty mytheslib" FORCE)
+endif()
+
 macro(setstripped _varname)
        if(${ARGC} GREATER 1)
                string(STRIP "${ARGV1}" _v)
@@ -450,7 +463,14 @@ else()
   set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}")
 endif()
 
-if(LYX_PACKAGE_SUFFIX)
+# The define below allows lyx-executable to find its default configuration files
+# see routines
+#    Package::messages_file()
+#    get_default_user_support_dir()
+#    relative_system_support_dir()
+# in src/support/Package.cpp
+#
+if(LYX_PROGRAM_SUFFIX)
        set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
 else()
        set(PACKAGE ${PACKAGE_BASE})
@@ -561,7 +581,15 @@ if(NOT MSVC)
        if(NOT LYX_QUIET)
                set(CMAKE_VERBOSE_MAKEFILE ON)
        endif()
-    set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
+       set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
+       if(LYX_CXX_FLAGS 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
+         # and still use our own c++ extension tests
+         set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
+         message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
+       endif()
        if(LYX_STDLIB_DEBUG)
                set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
        endif()
@@ -597,6 +625,16 @@ if(LYX_USE_QT MATCHES "QT5")
                find_package(Qt5X11Extras QUIET)
                find_package(Qt5WinExtras QUIET)
                set(QTVERSION ${Qt5Core_VERSION})
+               if (QTVERSION VERSION_LESS "5.4")
+                       message(STATUS "QTVERSION = \"${QTVERSION}\"")
+                       message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or")
+                       message(STATUS "install QT-Version >= \"5.4\"")
+                       # see thread in lyx-devel list
+                       # From: Jean-Pierre Chrétien <jeanpierre.chretien@free.fr>
+                       # Date 11.03.2017
+                       # Subject: cmake compilation error
+                       #message(FATAL_ERROR "Wrong Qt-Version")
+               endif()
                macro (qt_use_modules)
                        qt5_use_modules(${ARGN})
                endmacro()
@@ -625,8 +663,9 @@ elseif(LYX_USE_QT MATCHES "QT4")
        macro (qt_wrap_uifiles)
                qt4_wrap_ui(${ARGN})
        endmacro()
+        set(LYX_QTMAIN_LIBRARY ${QT_QTSVG_LIBRARY})
        if(WIN32)
-               set(LYX_QTMAIN_LIBRARY ${QT_QTMAIN_LIBRARIES})
+               list(APPEND LYX_QTMAIN_LIBRARY ${QT_QTMAIN_LIBRARIES})
        endif()
 else()
   message(FATAL_ERROR "Unhandled value for LYX_USE_QT (${LYX_USE_QT})")
@@ -642,7 +681,23 @@ include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
 set(Spelling_FOUND OFF)
 set(Include_used_spellchecker)   # String will be inserted into config.h
 
-if(LYX_3RDPARTY_BUILD)
+if (LYX_EXTERNAL_MYTHES MATCHES "AUTO")
+  # try system library first
+  find_package(MyThesLIB)
+  if (MYTHESLIB_FOUND)
+    set(LYX_EXTERNAL_MYTHES ON CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE)
+  else()
+    set(LYX_EXTERNAL_MYTHES OFF CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE)
+  endif()
+endif()
+if (LYX_EXTERNAL_MYTHES MATCHES "ON")
+  find_package(MyThesLIB REQUIRED)
+else()
+  add_subdirectory(3rdparty/mythes)
+endif()
+set(MYTHES_DIR ${MYTHESLIB_INCLUDE_DIR})
+
+if(NOT LYX_EXTERNAL_HUNSPELL)
     add_subdirectory(3rdparty/hunspell)
     add_definitions(-DHUNSPELL_STATIC)
     set(HUNSPELL_FOUND ON)
@@ -706,13 +761,17 @@ if(LYX_NLS)
        endif()
 endif()
 
-if(LYX_3RDPARTY_BUILD)
-       add_subdirectory(3rdparty/libiconv)
-       set(HAVE_ICONV_CONST 1)
-       add_subdirectory(3rdparty/zlib)
+if(LYX_EXTERNAL_ICONV)
+  find_package(ICONV REQUIRED)
 else()
-       find_package(ICONV REQUIRED)
-       find_package(ZLIB REQUIRED)
+  add_subdirectory(3rdparty/libiconv)
+  set(HAVE_ICONV_CONST 1)
+endif()
+
+if(LYX_EXTERNAL_Z)
+  find_package(ZLIB REQUIRED)
+else()
+  add_subdirectory(3rdparty/zlib)
 endif()
 
 if(LYX_EXTERNAL_BOOST)
@@ -765,7 +824,7 @@ if(WIN32)
        endif()
 endif()
 
-# Compute qt4-version from ${QTVERSION}
+# Compute qt-version from ${QTVERSION}
 
 message(STATUS "")
 foreach(_v PACKAGE PACKAGE_VERSION
@@ -911,11 +970,6 @@ endif()
 include(${LYX_CMAKE_DIR}/ConfigureChecks.cmake)
 configure_file(${LYX_CMAKE_DIR}/configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h)
 
-set(QPA_XCB)
-if(Qt5X11Extras_FOUND AND QT_USES_X11)
-  # QPA_XCB is only valid if QT5+X11
-  set(QPA_XCB 1)
-endif()
 configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
 
 if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")