X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=3c737c7ba27e9f1fca91fd0c9282c8de6490fa29;hb=268ae66e3c7df04effc329373dc887715d9c6f06;hp=1bc690a12fc41da2fbd90597db14db6bf5892d82;hpb=24a7dd45dcc6c7b4d22bf1dc3762ff27efeedcaa;p=lyx.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bc690a12f..3c737c7ba2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -139,9 +131,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_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5) +#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) @@ -156,7 +153,6 @@ LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC) LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC) LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC) LYX_OPTION(WALL "Enable all warnings" OFF MSVC) -LYX_OPTION(CONFIGURE_CHECKS "Also run configure checks for MSVC" OFF MSVC) LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC) # APPLE specific @@ -208,20 +204,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) @@ -262,9 +259,8 @@ set(LYX_GCC11_MODE) if(UNIX OR MINGW) if (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$") # ignore the GCC_VERSION for clang - # We pretend the compiler version >= 4.9 + # and use the resulting CXX11_STD_REGEX found in FindCXX11Compiler.cmake message(STATUS "Using clang") - # CXX11_STD_REGEX found in FindCXX11Compiler.cmake if(CXX11_STD_REGEX) set(LYX_USE_STD_REGEX 1) else() @@ -274,8 +270,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() # in gcc is unusable in versions less than 4.9.0 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631 @@ -312,6 +308,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 +455,22 @@ else() set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}") endif() -if(LYX_PACKAGE_SUFFIX) +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(suffixing) 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 + # 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() @@ -586,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) @@ -597,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 + # 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 +680,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 +698,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) @@ -674,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") @@ -706,15 +778,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) @@ -740,7 +814,7 @@ else() if(NOT LYX_USE_STD_REGEX) set(Lyx_Boost_Libraries boost_regex) endif() - add_definitions(-DBOOST_USER_CONFIG="") + add_definitions(-DBOOST_USER_CONFIG=) include_directories(${TOP_SRC_DIR}/3rdparty/boost) add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost") endif() @@ -755,15 +829,19 @@ 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() -# Compute qt4-version from ${QTVERSION} +# Compute qt-version from ${QTVERSION} message(STATUS "") foreach(_v PACKAGE PACKAGE_VERSION @@ -905,19 +983,10 @@ if (WIN32 AND Qt5Core_FOUND) set(Z_PREFIX 1) endif() -# compiler tests, config.h generation -if(MSVC AND NOT LYX_CONFIGURE_CHECKS) - configure_file(${LYX_CMAKE_DIR}/configCompiler.h.msvc ${TOP_BINARY_DIR}/configCompiler.h) -else() - include(${LYX_CMAKE_DIR}/ConfigureChecks.cmake) - configure_file(${LYX_CMAKE_DIR}/configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h) -endif() +# compiler tests, config.h generation LYX_CONFIGURE_CHECKS +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]+).*")