endif()
include(LyXMacros)
+include(LyXDestinations)
# Usage LYX_OPTION
# 1. parameter: option name without prefix 'LYX_'
LYX_OPTION(DEBUG "Enforce debug build" OFF ALL)
LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL)
LYX_OPTION(PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL)
+LYX_STRING(SUFFIX_VALUE "Use this string as suffix" "")
LYX_OPTION(PCH "Use precompiled headers" OFF ALL)
LYX_OPTION(MERGE_FILES "Merge source files into one compilation unit" OFF ALL)
LYX_OPTION(MERGE_REBUILD "Rebuild generated files from merged files build" 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)
LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC)
-LYX_OPTION(ENABLE_CXX11 "Build with options for c++11-mode" OFF GCC)
# MSVC specific
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
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)
endif()
+# Set to some meaningful default
+find_package(CXX11Compiler)
+if(NOT CXX11COMPILER_FOUND)
+ message(FATAL_ERROR "A C++11 compatible compiler is required.")
+endif()
set(LYX_GCC11_MODE)
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)
- # <regex> in gcc is unusable in versions less than 4.9.0
- # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
- set(LYX_USE_STD_REGEX 0)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
+ # ignore the GCC_VERSION for clang
+ # and use the resulting CXX11_STD_REGEX found in FindCXX11Compiler.cmake
+ message(STATUS "Using clang")
+ if(CXX11_STD_REGEX)
+ set(LYX_USE_STD_REGEX 1)
+ else()
+ set(LYX_USE_STD_REGEX 0)
+ endif()
else()
- if (LYX_ENABLE_CXX11)
- set(LYX_USE_STD_REGEX 1)
- endif()
- endif()
- if (LYX_ENABLE_CXX11)
- find_package(CXX11Compiler)
- if(NOT CXX11COMPILER_FOUND)
- message(FATAL_ERROR "A C++11 compatible compiler is required.")
- endif()
- set(LYX_GCC11_MODE "${CXX11_FLAG}")
+ 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.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
+ set(LYX_USE_STD_REGEX 0)
+ else()
+ set(LYX_USE_STD_REGEX 1)
+ endif()
endif()
+ set(LYX_GCC11_MODE "${CXX11_FLAG}")
else()
set(LYX_USE_STD_REGEX 0)
# if(MSVC10)
file(STRINGS "${TOP_SRC_DIR}/configure.ac" _config_lines)
if(WIN32)
+ set(CMAKE_PREFIX_PATH Specify-path-to-Qt CACHE PATH "Used Qt version")
+ if(MSVC)
+ set(LYX_3RDPARTY_BUILD ON CACHE BOOL "Build 3rdparty libraries" FORCE)
+ endif()
set(USE_WINDOWS_PACKAGING ON)
elseif(APPLE)
set(USE_MACOSX_PACKAGING ON)
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)
set(LYX_PATCH_VERSION ${CMAKE_MATCH_4})
set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
- set(LYX_INSTALL_SUFFIX "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
+ if ("${LYX_SUFFIX_VALUE}" MATCHES "")
+ set(LYX_INSTALL_SUFFIX "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
+ else()
+ set(LYX_INSTALL_SUFFIX "${LYX_SUFFIX_VALUE}")
+ endif()
endif()
endif()
if(_c_l MATCHES "^AC_SUBST\\( *LYX_DATE *, *\\[\\\"(.*)\\\"\\].*")
endif()
set(LYX_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
-string(REGEX REPLACE "/lyx${LYX_INSTALL_SUFFIX}$" "/share" SYSTEM_DATADIR ${CMAKE_INSTALL_PREFIX})
+if(UNIX)
+ set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}/share")
+elseif(CMAKE_INSTALL_PREFIX MATCHES "/lyx${LYX_INSTALL_SUFFIX}$")
+ string(REGEX REPLACE "/lyx${LYX_INSTALL_SUFFIX}$" "/share" SYSTEM_DATADIR ${CMAKE_INSTALL_PREFIX})
+else()
+ set(SYSTEM_DATADIR "${CMAKE_INSTALL_PREFIX}")
+endif()
-if(LYX_PACKAGE_SUFFIX)
+# The define 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)
set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
else()
set(PACKAGE ${PACKAGE_BASE})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# see http://www.cmake.org/pipermail/cmake/2006-October/011559.html
if (UNIX)
- # don't use the default "/usr/local"
+ # use the default "/usr/local"
# but respect the user-choice on the command-line
- if(LYX_INSTALL_SUFFIX)
- set(CMAKE_INSTALL_PREFIX "/usr/local/lyx${LYX_INSTALL_SUFFIX}" CACHE PATH "LyX default install prefix" FORCE)
- else()
- set(CMAKE_INSTALL_PREFIX "/usr/local/${LYX_PROJECT}" CACHE PATH "LyX default install prefix" FORCE)
- endif()
- endif()
- if(WIN32)
- set(CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE)
+ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "LyX default install prefix" FORCE)
endif()
endif()
+if(WIN32)
+ set(CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE)
+endif()
if(IS_ABSOLUTE)
set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
else()
if (WIN32)
set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
else()
- set(LYX_DATA_SUBDIR "" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+ set(LYX_DATA_SUBDIR "share/${_lyx}/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
endif()
endif()
set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}")
-set(LYX_LOCALEDIR "locale")
-set(LYX_ABS_INSTALLED_LOCALEDIR "${LYX_ABS_INSTALLED_DATADIR}/${LYX_DATA_SUBDIR}${LYX_LOCALEDIR}")
+get_locale_destination(LYX_LOCALEDIR)
+set(LYX_ABS_INSTALLED_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LYX_LOCALEDIR}")
set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
if(LYX_BUNDLE AND APPLE)
set(LYX_MAN_DIR "${LYX_DATA_SUBDIR}" CACHE STRING "Install location for man pages.")
else()
- set(LYX_MAN_DIR "/usr/local/man/man1" CACHE STRING "Install location for man pages.")
+ if(WIN32)
+ set(LYX_MAN_DIR "${CMAKE_BINARY_DIR}/usr/local/man" CACHE STRING "Install location for man pages.")
+ elseif(UNIX)
+ set(LYX_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE STRING "Install location for man pages.")
+ else()
+ set(LYX_MAN_DIR "${CMAKE_INSTALL_PREFIX}/man" CACHE STRING "Install location for man pages.")
+ endif()
endif()
mark_as_advanced(LYX_MAN_DIR)
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()
endif()
if(LYX_USE_QT MATCHES "QT5")
+ # set QPA_XCB if QT uses X11
find_package(Qt5Core REQUIRED)
if (Qt5Core_FOUND)
find_package(Qt5Widgets REQUIRED)
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})")
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)
endif()
endforeach()
+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()
+ if(PYTHON_VERSION_STRING VERSION_GREATER 2.8)
+ unset(PYTHONINTERP_FOUND)
+ endif()
endif()
-if(NOT PYTHONINTERP_FOUND AND NOT GNUWIN32_DIR)
+if(NOT PYTHONINTERP_FOUND)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR)
message(STATUS "Installing provided .gmo-files only")
foreach( _gmo ${_gmofiles})
string(REGEX REPLACE "\\.gmo$" "" _lang ${_gmo})
- install(FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION ${LYX_DATA_SUBDIR}${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
+ install(FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION ${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
endforeach()
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)
message(STATUS "Searching for boost")
- if(LYX_USE_STD_REGEX)
- find_package(Boost COMPONENTS signals)
- else()
- find_package(Boost COMPONENTS signals regex)
+ if(NOT LYX_USE_STD_REGEX)
+ find_package(Boost COMPONENTS regex)
endif()
if(Boost_FOUND)
message(STATUS "Boost found")
message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON})
endif()
else()
- if(LYX_USE_STD_REGEX)
- set(Lyx_Boost_Libraries boost_signals)
- else()
- set(Lyx_Boost_Libraries boost_signals boost_regex)
+ if(NOT LYX_USE_STD_REGEX)
+ set(Lyx_Boost_Libraries boost_regex)
endif()
add_definitions(-DBOOST_USER_CONFIG="<config.h>")
- add_definitions(-DBOOST_SIGNALS_NO_DEPRECATION_WARNING=1)
include_directories(${TOP_SRC_DIR}/3rdparty/boost)
add_subdirectory(3rdparty/boost "${TOP_BINARY_DIR}/3rdparty/boost")
endif()
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()
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)
configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)