]> git.lyx.org Git - lyx.git/blobdiff - CMakeLists.txt
Check path of Qt tools if qtchooser is detected
[lyx.git] / CMakeLists.txt
index 68845e3f346685eaf14700f90028f3d8738fcacc..7fd8b26f764b94a56aa9b8e7a1966548be3137a2 100644 (file)
@@ -139,9 +139,13 @@ 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       "Build 3rdparty lib zlib" ON ALL)
+LYX_OPTION(EXTERNAL_ICONV   "Build 3rdparty lib iconvlib" ON ALL)
+LYX_OPTION(EXTERNAL_HUNSPELL "Build 3rdparty lib hunspelllib" ON ALL)
 
 # GCC specific
 LYX_OPTION(PROFILE              "Build profile version" OFF GCC)
@@ -207,20 +211,21 @@ else()
        set(LYX_MERGE_REBUILD OFF)
 endif()
 
-
 if(LYX_DEPENDENCIES_DOWNLOAD)
        message(STATUS)
-    if(MSVC12)
-        set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2013-deps)
-        set(deps_files lyx-windows-deps-msvc2013.zip)
-        set(deps_server http://ftp.lyx.de/LyX-Windows-Deps)
-        set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2013)
-    else()
-        set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2010-deps)
-           set(deps_files lyx20-deps-msvc2010-x86.zip)
-           set(deps_server http://downloads.sourceforge.net/project/lyx/Win_installers/Dependencies)
-        set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/deps20)
-    endif()
+       if(MSVC14)
+               set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2015-deps)
+               set(deps_files lyx-windows-deps-msvc2015.zip)
+               set(deps_server http://ftp.lyx.de/LyX-Windows-Deps)
+               set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2015)
+       elseif(MSVC10)
+               set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2010-deps)
+               set(deps_files lyx-windows-deps-msvc2010.zip)
+               set(deps_server http://ftp.lyx.de/LyX-Windows-Deps)
+               set(GNUWIN32_DIR ${LYX_DEPENDENCIES_DIR}/lyx-windows-deps-msvc2010)
+       else()
+               message(FATAL_ERROR "error: no dependency package known for the selected MSVC version.")
+       endif()
     message(STATUS "Using downloaded dependencies in ${LYX_DEPENDENCIES_DIR}")
        foreach(it ${deps_files})
                set(already_downloaded already_downloaded-NOTFOUND CACHE PATH "downloaded" FORCE)
@@ -272,8 +277,8 @@ if(UNIX OR MINGW)
          execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
          message(STATUS "Using GCC version ${GCC_VERSION}")
          if(GCC_VERSION VERSION_LESS 4.9)
-                 if(GCC_VERSION VERSION_LESS 4.3)
-                         message(FATAL_ERROR "gcc >= 4.3 is required.")
+                 if(GCC_VERSION VERSION_LESS 4.6)
+                         message(FATAL_ERROR "gcc >= 4.6 is required.")
                  endif()
                  # <regex> in gcc is unusable in versions less than 4.9.0
                  # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
@@ -310,6 +315,14 @@ 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)
+endif()
+
 macro(setstripped _varname)
        if(${ARGC} GREATER 1)
                string(STRIP "${ARGV1}" _v)
@@ -559,7 +572,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()
@@ -640,7 +661,7 @@ 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(NOT LYX_EXTERNAL_HUNSPELL)
     add_subdirectory(3rdparty/hunspell)
     add_definitions(-DHUNSPELL_STATIC)
     set(HUNSPELL_FOUND ON)
@@ -704,15 +725,17 @@ if(LYX_NLS)
        endif()
 endif()
 
-if(UNIX)
-    find_package(ICONV REQUIRED)
-    find_package(ZLIB REQUIRED)
+if(LYX_EXTERNAL_ICONV)
+  find_package(ICONV REQUIRED)
 else()
-    if(LYX_3RDPARTY_BUILD)
-       add_subdirectory(3rdparty/libiconv)
-       set(HAVE_ICONV_CONST 1)
-       add_subdirectory(3rdparty/zlib)
-    endif()
+  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)
@@ -753,10 +776,14 @@ if(WIN32)
                set(WIN32_CONSOLE WIN32)
        endif()
        if(MSVC)
-               add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX)
+               # -DPSAPI_VERSION=1 is needed to run on vista (bug 10186)
+               add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX -DPSAPI_VERSION=1)
                # disable checked iterators for msvc release builds to get maximum speed
                set(CMAKE_CXX_FLAGS_RELEASE  "${CMAKE_CXX_FLAGS_RELEASE} /D_SECURE_SCL=0")
        else()
+               # -DPSAPI_VERSION=1 is not needed for mingw, since the mingw psapi.h
+               # does not use it and always declares the vista compatible API.
+               # If this ever changes then -DPSAPI_VERSION might be needed here as well. 
                add_definitions(-DWINVER=0x0500)
        endif()
 endif()
@@ -907,11 +934,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]+).*")