X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=302ac19366e3fcd1fcae06d7f3afc8d5272f4c46;hb=2cbca8be1e85c2126014960d179b4d0d25c2fbd4;hp=da0776eb2f25f767b59669f56b968fafaf982e11;hpb=0f3b1539e88878290a63b6ac3046f077700a8195;p=lyx.git diff --git a/CMakeLists.txt b/CMakeLists.txt index da0776eb2f..302ac19366 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 @@ -37,16 +41,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 +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) @@ -141,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) @@ -158,7 +153,7 @@ LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC) LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC) # MSVC specific -LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC) +LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC) LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC) LYX_OPTION(WALL "Enable all warnings" OFF MSVC) LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC) @@ -193,11 +188,6 @@ if(LYX_INSTALL) if(WIN32 AND NOT MINGW) set(LYX_HUNSPELL ON) endif() - if(LYX_CONSOLE MATCHES "FORCE") - set(LYX_CONSOLE ON) - else() - set(LYX_CONSOLE OFF) - endif() set(LYX_PACKAGE_SUFFIX ON) if(NOT LYX_DEBUG) set(LYX_RELEASE ON) @@ -463,14 +453,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}) @@ -594,11 +592,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 +612,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 +640,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 +789,41 @@ 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) + # Set only include path. + # Use internal boost, which is known to exist + # we don't need any libraries + set(Lyx_Boost_Libraries) + add_definitions(-DBOOST_USER_CONFIG=) + include_directories(${TOP_SRC_DIR}/3rdparty/boost) 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()