X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=48cc85a13c87b0a3e19e69f38ff59e1014155cdd;hb=2fe59adbc89f56e7e192b57c90eb5e2a8338721c;hp=0a59f2dedc6ecd991decb849005e97ff80e0213e;hpb=0935f94f0d448c1a9b521e4825b30b94fe0521ff;p=features.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a59f2dedc..48cc85a13c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,10 @@ cmake_minimum_required(VERSION 2.6.4) set(LYX_PROJECT LyX) +# Instruct cmake to not use gnu extensions, +# this prevents the mix of '-std=c++*' and '-std=gnu++*' flags +set(CMAKE_CXX_EXTENSIONS OFF) + enable_testing() get_filename_component(lyx_dir_readme ${CMAKE_SOURCE_DIR}/README REALPATH) # Resolve symlinks @@ -117,7 +121,6 @@ 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(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) @@ -133,7 +136,7 @@ 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 "OFF := Build 3rdparty lib zlib" ON ALL) LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ON ALL) @@ -594,11 +597,11 @@ if(NOT MSVC) set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC") endif() set(CMAKE_CXX_FLAGS "${LYX_CXX_FLAGS} -fno-strict-aliasing " CACHE TYPE STRING FORCE) - set(CMAKE_CXX_FLAGS_DEBUG "${LYX_CXX_FLAGS} -fno-strict-aliasing -O0 -g3 -D_DEBUG" CACHE TYPE STRING FORCE) + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -D_DEBUG" CACHE TYPE STRING FORCE) if(MINGW) - set(CMAKE_CXX_FLAGS_RELEASE "${LYX_CXX_FLAGS} -O2 -DNDEBUG" CACHE TYPE STRING FORCE) + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE TYPE STRING FORCE) else() - set(CMAKE_CXX_FLAGS_RELEASE "${LYX_CXX_FLAGS} -O3 -DNDEBUG" CACHE TYPE STRING FORCE) + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE TYPE STRING FORCE) endif() endif() @@ -614,6 +617,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) @@ -625,10 +645,10 @@ if(LYX_USE_QT MATCHES "QT5") find_package(Qt5X11Extras QUIET) find_package(Qt5WinExtras QUIET) set(QTVERSION ${Qt5Core_VERSION}) - if (QTVERSION VERSION_LESS "5.4") + 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 >= \"5.4\"") + message(STATUS "install QT-Version >= \"${min_qt5_version}\"") # see thread in lyx-devel list # From: Jean-Pierre Chrétien # Date 11.03.2017 @@ -774,37 +794,36 @@ else() add_subdirectory(3rdparty/zlib) endif() -if(LYX_EXTERNAL_BOOST) - message(STATUS "Searching for boost") - if(NOT LYX_USE_STD_REGEX) - find_package(Boost COMPONENTS regex) - endif() - if(Boost_FOUND) - message(STATUS "Boost found") - message(STATUS "Boost-libs = ${Boost_LIBRARIES}") - set(Lyx_Boost_Libraries ${Boost_LIBRARIES}) - if (LYX_STDLIB_DEBUG) - # Comment from Jean-Marc Lasgouttes: - # In general, system boost libraries are incompatible with - # the use of stdlib-debug in libstdc++. See ticket #9736 for - # details. - message(WARNING "Compiling LyX with stdlib-debug and system boost libraries may lead to crashes. Consider using '-DLYX_STDLIB_DEBUG=OFF' or using '-DLYX_EXTERNAL_BOOST=OFF'") - endif() - else() - message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON}) - endif() +if(LYX_USE_STD_REGEX) + # Nothing to do else() - if(NOT LYX_USE_STD_REGEX) - set(Lyx_Boost_Libraries boost_regex) - endif() - add_definitions(-DBOOST_USER_CONFIG=) - include_directories(${TOP_SRC_DIR}/3rdparty/boost) - add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost") + # Using boost-regex + if(LYX_EXTERNAL_BOOST) + message(STATUS "Searching for external boost") + find_package(Boost COMPONENTS regex) + if(Boost_FOUND) + message(STATUS "Boost found") + message(STATUS "Boost-libs = ${Boost_LIBRARIES}") + set(Lyx_Boost_Libraries ${Boost_LIBRARIES}) + if (LYX_STDLIB_DEBUG) + # Comment from Jean-Marc Lasgouttes: + # In general, system boost libraries are incompatible with + # the use of stdlib-debug in libstdc++. See ticket #9736 for + # details. + message(WARNING "Compiling LyX with stdlib-debug and system boost libraries may lead to crashes. Consider using '-DLYX_STDLIB_DEBUG=OFF' or using '-DLYX_EXTERNAL_BOOST=OFF'") + endif() + else() + message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON}) + endif() + else() + # Using included boost + set(Lyx_Boost_Libraries boost_regex) + add_definitions(-DBOOST_USER_CONFIG=) + include_directories(${TOP_SRC_DIR}/3rdparty/boost) + add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost") + endif() endif() - - - if(WIN32) if(LYX_CONSOLE) set(LYX_QTMAIN_LIBRARY) @@ -819,7 +838,7 @@ if(WIN32) 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. + # If this ever changes then -DPSAPI_VERSION might be needed here as well. add_definitions(-DWINVER=0x0500) endif() endif()