]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Remerge strings again after last change
[lyx.git] / CMakeLists.txt
index 7bd6c3d794de60fcb41a5d86ece925c22970ccd1..3c737c7ba27e9f1fca91fd0c9282c8de6490fa29 100644 (file)
@@ -37,16 +37,8 @@ set(LYX_TESTS_USERDIR "${TOP_BINARY_DIR}/Testing/.lyx")
 file(MAKE_DIRECTORY "${LYX_TESTS_USERDIR}")
 
 if(COMMAND cmake_policy)
-       cmake_policy(SET CMP0003 OLD)
-       cmake_policy(SET CMP0005 OLD)
        # Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION
        cmake_policy(SET CMP0006 NEW)
-       if(POLICY CMP0020)
-               cmake_policy(SET CMP0020 OLD)
-       endif()
-       if(POLICY CMP0028)
-               cmake_policy(SET CMP0028 OLD)
-       endif()
        if(POLICY CMP0043)
                # COMPILE_DEFINITIONS are not used yet. Enable new behavior.
                cmake_policy(SET CMP0043 NEW)
@@ -125,7 +117,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)
@@ -141,12 +133,12 @@ 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_COMBO(USE_QT            "Use Qt version as frontend" AUTO QT4 QT5)
 #LYX_OPTION(3RDPARTY_BUILD   "Build 3rdparty libs" OFF ALL)
-LYX_OPTION(EXTERNAL_Z       "Do not build 3rdparty lib zlib" ON ALL)
-LYX_OPTION(EXTERNAL_ICONV   "Do not build 3rdparty lib iconvlib" ON ALL)
-LYX_OPTION(EXTERNAL_HUNSPELL "Do not build 3rdparty lib hunspelllib" ON ALL)
-LYX_OPTION(EXTERNAL_MYTHES  "Do not build 3rdparty lib mytheslib" 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)
@@ -184,12 +176,6 @@ if(LYX_DMG)
        set(LYX_CPACK ON)
 endif()
 
-if (LYX_EXTERNAL_MYTHES)
-  message(FATAL_ERROR "Compilation with system mythes not supported yet")
-else()
-  set(MYTHES_DIR "${TOP_SRC_DIR}/3rdparty/mythes/1.2.5")
-endif()
-
 if(LYX_CPACK)
        set(LYX_INSTALL ON)
 endif()
@@ -291,7 +277,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 0)
+                 set(LYX_USE_STD_REGEX 1)
          endif()
        endif()
        set(LYX_GCC11_MODE "${CXX11_FLAG}")
@@ -328,6 +314,7 @@ if(LYX_3RDPARTY_BUILD)
   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)
@@ -468,14 +455,22 @@ else()
   set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}")
 endif()
 
-# The define below allows lyx-executable to find its default configuration files
+if(CMAKE_COMPILER_IS_GNUCXX)
+  message(STATUS "CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}")
+  set(suffixing ${LYX_PROGRAM_SUFFIX})
+else()
+  # Not a GCC compiler, programs do not have a suffix
+  set(suffixing ${LYX_PACKAGE_SUFFIX})
+endif()
+
+# The define PACKAGE 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)
+if(suffixing)
        set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
 else()
        set(PACKAGE ${PACKAGE_BASE})
@@ -619,6 +614,23 @@ if(LYX_XMINGW)
        list(APPEND CMAKE_FIND_ROOT_PATH ${GNUWIN32_DIR})
 endif()
 
+set(min_qt5_version "5.6")
+if(LYX_USE_QT MATCHES "AUTO")
+       # try qt5 first
+       find_package(Qt5Core QUIET)
+       if(Qt5Core_FOUND)
+               set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE)
+               message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}")
+               if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version})
+                       find_package(Qt4 "4.5.0" QUIET)
+                       if(QT4_FOUND)
+                               set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
+                       endif()
+               endif()
+       else()
+               set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
+       endif()
+endif()
 if(LYX_USE_QT MATCHES "QT5")
        # set QPA_XCB if QT uses X11
        find_package(Qt5Core REQUIRED)
@@ -630,6 +642,16 @@ if(LYX_USE_QT MATCHES "QT5")
                find_package(Qt5X11Extras QUIET)
                find_package(Qt5WinExtras QUIET)
                set(QTVERSION ${Qt5Core_VERSION})
+               if (QTVERSION VERSION_LESS ${min_qt5_version})
+                       message(STATUS "QTVERSION = \"${QTVERSION}\"")
+                       message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or")
+                       message(STATUS "install QT-Version >= \"${min_qt5_version}\"")
+                       # 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()
@@ -676,6 +698,22 @@ 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_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)
@@ -708,19 +746,19 @@ if(GNUWIN32_DIR)
        list(APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Python" )
 endif()
 
-find_package(PythonInterp 2.7 QUIET)
-if(PYTHONINTERP_FOUND)
-       if(PYTHON_VERSION_STRING VERSION_GREATER 2.8)
-       unset(PYTHONINTERP_FOUND)
-       endif()
-endif()
-
+# Search for python default version first
+unset(PYTHON_EXECUTABLE CACHE)
+unset(LYX_PYTHON_EXECUTABLE CACHE)
+unset(PYTHON_VERSION_MAJOR)
+unset(PYTHON_VERSION_MINOR)
+unset(PYTHON_VERSION_STRING)
+find_package(PythonInterp 3.3 QUIET)
 if(NOT PYTHONINTERP_FOUND)
   unset(PYTHON_EXECUTABLE CACHE)
-  unset(PYTHON_VERSION_MAJOR)
-  unset(PYTHON_VERSION_MINOR)
-  unset(PYTHON_VERSION_STRING)
-  find_package(PythonInterp 3.3 REQUIRED)
+  find_package(PythonInterp 2.0 REQUIRED)
+  if(NOT PYTHON_VERSION_STRING VERSION_LESS 2.8)
+    message(FATAL_ERROR "Python interpreter found, but is not suitable")
+  endif()
 endif()
 
 set(LYX_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Python to be used by LyX")
@@ -776,7 +814,7 @@ else()
        if(NOT LYX_USE_STD_REGEX)
                set(Lyx_Boost_Libraries boost_regex)
        endif()
-       add_definitions(-DBOOST_USER_CONFIG="<config.h>")
+       add_definitions(-DBOOST_USER_CONFIG=<config.h>)
        include_directories(${TOP_SRC_DIR}/3rdparty/boost)
        add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost")
 endif()
@@ -803,7 +841,7 @@ if(WIN32)
        endif()
 endif()
 
-# Compute qt4-version from ${QTVERSION}
+# Compute qt-version from ${QTVERSION}
 
 message(STATUS "")
 foreach(_v PACKAGE PACKAGE_VERSION