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
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)
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)
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)
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)
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)
FIND_PROGRAM(LYX_GITVERSION git)
#message(STATUS "gitversion = ${LYX_GITVERSION}")
set(LYX_REVISION_VERSION ${LYX_PATCH_VERSION})
+set(LYX_PACKAGE_RELEASE "1")
if(LYX_GITVERSION)
if (LYX_LOCALVERSIONING)
# Find the revision number and for later use
EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} describe --match 2.0.0 HEAD
- WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE LYX_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-.*$")
+ WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE tmp_LYX_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (tmp_LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-\(.*\)$")
+ set(LYX_PACKAGE_RELEASE ${CMAKE_MATCH_2})
# We will add offset of 40000 to get appropriate value to
# previous svn.
# We use this value than also to set the package-patch-value
endif()
set(_lyx "${PACKAGE_BASE}${PROGRAM_SUFFIX}")
set(_tex2lyx tex2lyx${PROGRAM_SUFFIX})
+set(_convert lyxconvert${PROGRAM_SUFFIX})
add_custom_target(lyx_version ALL
COMMAND ${CMAKE_COMMAND} -DTOP_SRC_DIR=${TOP_SRC_DIR} -DTOP_CMAKE_PATH=${TOP_CMAKE_PATH} -DTOP_BINARY_DIR=${TOP_BINARY_DIR} -DLYX_DATE=${LYX_DATE} -P ${TOP_SCRIPT_PATH}/LyXGetVersion.cmake
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})
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()
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)
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 <jeanpierre.chretien@free.fr>
# Date 11.03.2017
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")
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=<config.h>)
+ 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="<config.h>")
- 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=<config.h>)
+ 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)
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()
endif()
add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
endif()
- include(../Install)
endif()
+include(../Install)
add_subdirectory(src "${TOP_BINARY_DIR}/src")
add_subdirectory(lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx")