2011-05-10 17:21:15 +00:00
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
2023-12-31 14:18:11 +00:00
# Copyright (c) 2008-2024 Kornel Benko, <Kornel.Benko@berlin.de>
2011-05-10 17:21:15 +00:00
2023-12-31 14:18:11 +00:00
cmake_minimum_required ( VERSION 3.5.0 )
2011-05-10 17:21:15 +00:00
2012-09-21 13:09:46 +00:00
set ( LYX_PROJECT LyX )
2017-07-27 11:33:17 +00:00
# Instruct cmake to not use gnu extensions,
# this prevents the mix of '-std=c++*' and '-std=gnu++*' flags
set ( CMAKE_CXX_EXTENSIONS OFF )
2012-10-21 10:05:50 +00:00
enable_testing ( )
2015-12-11 22:23:46 +00:00
get_filename_component ( lyx_dir_readme ${ CMAKE_SOURCE_DIR } /README REALPATH ) # Resolve symlinks
2011-05-10 17:21:45 +00:00
get_filename_component ( TOP_SRC_DIR ${ lyx_dir_readme } PATH )
2015-12-11 22:23:46 +00:00
message ( STATUS "TOP_SRC_DIR = ${TOP_SRC_DIR}" )
2011-05-10 17:21:45 +00:00
2012-11-02 12:33:22 +00:00
set ( LYX_CMAKE_DIR "development/cmake" )
set ( TOP_CMAKE_PATH "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}" )
set ( TOP_MODULE_PATH "${TOP_CMAKE_PATH}/modules" )
set ( TOP_SCRIPT_PATH "${TOP_CMAKE_PATH}/scripts" )
set ( CMAKE_MODULE_PATH "${TOP_MODULE_PATH}" )
2011-05-10 17:21:45 +00:00
set ( CMAKE_PROJECT_NAME ${ LYX_PROJECT } )
2011-05-10 20:25:31 +00:00
message ( STATUS )
2013-08-25 09:41:10 +00:00
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
2011-05-10 17:21:45 +00:00
message ( STATUS "Building in-source" )
set ( TOP_BINARY_DIR "${CMAKE_BINARY_DIR}/build" )
else ( )
message ( STATUS "Building out-of-source" )
set ( TOP_BINARY_DIR "${CMAKE_BINARY_DIR}" )
endif ( )
2013-08-25 09:41:10 +00:00
# This directory should be used if some test uses lyx-executable
set ( LYX_TESTS_USERDIR "${TOP_BINARY_DIR}/Testing/.lyx" )
file ( MAKE_DIRECTORY "${LYX_TESTS_USERDIR}" )
2011-05-10 17:21:45 +00:00
2011-05-10 17:21:15 +00:00
if ( COMMAND cmake_policy )
2014-03-09 09:21:51 +00:00
# Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION
cmake_policy ( SET CMP0006 NEW )
2014-08-21 16:03:37 +00:00
if ( POLICY CMP0043 )
# COMPILE_DEFINITIONS are not used yet. Enable new behavior.
cmake_policy ( SET CMP0043 NEW )
endif ( )
2018-05-14 15:29:45 +00:00
cmake_policy ( SET CMP0020 NEW )
2018-06-10 09:40:12 +00:00
if ( POLICY CMP0075 )
2020-03-01 14:36:41 +00:00
cmake_policy ( SET CMP0075 NEW )
2018-06-10 09:40:12 +00:00
endif ( )
2020-10-28 22:12:03 +00:00
if ( POLICY CMP0077 )
cmake_policy ( SET CMP0077 NEW )
endif ( )
2011-05-10 17:21:15 +00:00
endif ( )
set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
# Supress regeneration
set ( CMAKE_SUPPRESS_REGENERATION FALSE )
2014-06-07 05:59:52 +00:00
if ( LYX_XMINGW )
set ( CMAKE_SYSTEM_NAME Windows )
set ( TOOLNAME ${ LYX_XMINGW } )
set ( TOOLCHAIN "${TOOLNAME}-" )
set ( CMAKE_C_COMPILER "${TOOLCHAIN}gcc" CACHE PATH "Mingw C compiler" FORCE )
set ( CMAKE_CXX_COMPILER "${TOOLCHAIN}g++" CACHE PATH "Mingw C++ compiler" FORCE )
set ( CMAKE_RC_COMPILER "${TOOLCHAIN}windres" CACHE PATH "Mingw rc compiler" FORCE )
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH )
set ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endif ( )
2011-05-15 13:37:18 +00:00
if ( NOT help AND NOT HELP )
2015-05-14 19:21:07 +00:00
# 'project' triggers the searching for a compiler
project ( ${ LYX_PROJECT } )
if ( CMAKE_COMPILER_IS_GNUCXX )
2020-11-24 22:00:28 +00:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9" )
2015-05-14 19:21:07 +00:00
message ( STATUS "Gnu CXX compiler version = ${CMAKE_CXX_COMPILER_VERSION}" )
2020-11-24 22:00:28 +00:00
message ( STATUS "is too old, should be >= 4.9" )
2015-05-14 19:21:07 +00:00
message ( FATAL_ERROR "Exiting" )
endif ( )
endif ( )
2011-05-15 13:37:18 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
2011-05-24 06:58:40 +00:00
if ( UNIX )
2011-05-28 08:30:44 +00:00
set ( ARCH_TRIPLET )
2011-05-24 06:58:40 +00:00
FIND_PROGRAM ( DPKG_ARCHITECTURE_EXECUTABLE dpkg-architecture )
if ( DPKG_ARCHITECTURE_EXECUTABLE )
2011-05-28 08:30:44 +00:00
EXECUTE_PROCESS ( COMMAND ${ DPKG_ARCHITECTURE_EXECUTABLE } -qDEB_HOST_MULTIARCH
O U T P U T _ V A R I A B L E A R C H _ T R I P L E T
E R R O R _ V A R I A B L E E R R O R _ A R C H _ T R I P L E T
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2011-05-24 06:58:40 +00:00
endif ( )
endif ( )
if ( ARCH_TRIPLET )
set ( SYSTEM_LIB_DIRS /usr/lib /usr/lib/ ${ ARCH_TRIPLET } /usr/local/lib )
else ( )
set ( SYSTEM_LIB_DIRS /usr/lib /usr/local/lib )
endif ( )
2011-05-10 17:21:15 +00:00
include ( LyXMacros )
2016-06-06 06:29:07 +00:00
include ( LyXDestinations )
2011-05-10 17:21:15 +00:00
2020-07-13 08:17:54 +00:00
# Value of USE_POSIX_PACKAGING is needed in determineversionandbuildtype()
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 )
else ( )
set ( USE_POSIX_PACKAGING ON )
endif ( )
2020-07-12 14:27:45 +00:00
determineversionandbuildtype ( "${TOP_SRC_DIR}/configure.ac" _package_list _version_list _envlist LYX_DATE LYX_BUILD_TYPE )
list ( GET _package_list 0 PACKAGE_BASE )
list ( GET _package_list 1 PACKAGE_VERSION )
list ( GET _package_list 2 PACKAGE_BUGREPORT )
list ( GET _envlist 0 LYX_DIR_VER )
list ( GET _envlist 1 LYX_USERDIR_VER )
list ( GET _version_list 0 LYX_VERSION )
list ( GET _version_list 1 LYX_MAJOR_VERSION )
list ( GET _version_list 2 LYX_MINOR_VERSION )
list ( GET _version_list 3 LYX_RELEASE_LEVEL )
list ( GET _version_list 4 LYX_RELEASE_PATCH )
2011-05-10 17:21:15 +00:00
# Usage LYX_OPTION
# 1. parameter: option name without prefix 'LYX_'
# 2. parameter: description
# 3. parameter: default value, ON or OFF
# 4. parameter: system on which option is used: ALL, GCC, MSVC, ...
2020-07-14 18:06:43 +00:00
# Usage LYX_COMBO
# 1. parameter: name without prefix 'LYX_'
# 2. parameter: description
# 3. parameter: default value
# 4-n parameter: possible other string values
LYX_OPTION_INIT ( )
LYX_COMBO ( ENABLE_BUILD_TYPE "Allows to tweak the compiled code" AUTO release prerelease development gprof )
if ( LYX_ENABLE_BUILD_TYPE MATCHES "AUTO" )
message ( STATUS "Selecting build type defaults from configure.ac" )
else ( )
set ( LYX_BUILD_TYPE "${LYX_ENABLE_BUILD_TYPE}" )
message ( STATUS "Selecting build type defaults from LYX_ENABLE_BUILD_TYPE" )
endif ( )
2020-07-13 08:53:52 +00:00
# Select some defaults depending on LYX_BUILD_TYPE
2020-07-14 18:06:43 +00:00
# they can always be overwritten by the respective command line settings
# These settings are only effective on fresh(==empty) CMakeCache.txt
2020-07-13 08:53:52 +00:00
if ( LYX_BUILD_TYPE STREQUAL "development" )
set ( DefaultLyxDebug ON )
set ( DefaultLyxRelease OFF )
2020-07-13 11:51:44 +00:00
set ( DefaultLyxStdlibDebug ON )
set ( DefaultLyxEnableAssertions ON )
2020-07-14 18:06:43 +00:00
set ( DefaultLyxProfile OFF )
2020-08-09 08:42:02 +00:00
set ( DefaultExternalLibs OFF )
2020-07-13 08:53:52 +00:00
elseif ( LYX_BUILD_TYPE STREQUAL "prerelease" )
set ( DefaultLyxDebug OFF )
set ( DefaultLyxRelease OFF )
2020-07-13 11:51:44 +00:00
set ( DefaultLyxStdlibDebug OFF )
set ( DefaultLyxEnableAssertions OFF )
2020-07-14 18:06:43 +00:00
set ( DefaultLyxProfile OFF )
2020-08-09 08:42:02 +00:00
set ( DefaultExternalLibs ON )
2020-07-13 08:53:52 +00:00
elseif ( LYX_BUILD_TYPE STREQUAL "release" )
set ( DefaultLyxDebug OFF )
set ( DefaultLyxRelease ON )
2020-07-13 11:51:44 +00:00
set ( DefaultLyxStdlibDebug OFF )
set ( DefaultLyxEnableAssertions OFF )
2020-07-14 18:06:43 +00:00
set ( DefaultLyxProfile OFF )
2020-08-09 08:42:02 +00:00
set ( DefaultExternalLibs ON )
2020-07-14 18:06:43 +00:00
elseif ( LYX_BUILD_TYPE STREQUAL "gprof" )
set ( DefaultLyxDebug ON )
set ( DefaultLyxRelease OFF )
set ( DefaultLyxStdlibDebug OFF )
set ( DefaultLyxEnableAssertions OFF )
set ( DefaultLyxProfile ON )
2020-08-09 08:42:02 +00:00
set ( DefaultExternalLibs OFF )
2020-07-13 08:53:52 +00:00
else ( )
2020-07-14 18:06:43 +00:00
message ( FATAL_ERROR "Invalid build type (${LYX_BUILD_TYPE}) encountered" )
2020-07-13 08:53:52 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
# Options for all compilers/systems
2011-05-10 18:34:39 +00:00
LYX_OPTION ( CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL )
2012-03-15 12:01:09 +00:00
LYX_OPTION ( LOCALVERSIONING "Add version info to created package name (only used if LYX_CPACK option set)" OFF ALL )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( INSTALL "Build install projects/rules (implies a bunch of other options)" OFF ALL )
2011-05-14 09:22:35 +00:00
LYX_OPTION ( NLS "Enable Native Language Support (NLS)" ON ALL )
2014-05-13 10:31:37 +00:00
LYX_OPTION ( REQUIRE_SPELLCHECK "Abort if no spellchecker available" OFF ALL )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( ASPELL "Require aspell" OFF ALL )
LYX_OPTION ( ENCHANT "Require Enchant" OFF ALL )
LYX_OPTION ( HUNSPELL "Require Hunspell" OFF ALL )
2020-07-13 08:53:52 +00:00
LYX_OPTION ( RELEASE "Build release version, build debug when disabled" ${ DefaultLyxRelease } ALL )
LYX_OPTION ( DEBUG "Enforce debug build" ${ DefaultLyxDebug } ALL )
2011-05-15 13:21:18 +00:00
LYX_OPTION ( NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL )
2020-07-13 11:51:44 +00:00
LYX_OPTION ( ENABLE_ASSERTIONS "Run sanity checks in the program" ${ DefaultLyxEnableAssertions } ALL )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL )
2016-06-05 14:26:59 +00:00
LYX_STRING ( SUFFIX_VALUE "Use this string as suffix" "" )
2011-05-10 18:34:39 +00:00
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 ( QUIET "Don't generate verbose makefiles" OFF ALL )
LYX_OPTION ( INSTALL_PREFIX "Install path for LyX" OFF ALL )
2011-05-20 22:26:46 +00:00
LYX_OPTION ( BUNDLE "Build bundle (experimental) " OFF ALL )
2013-09-06 13:03:47 +00:00
LYX_OPTION ( ENABLE_URLTESTS "Enable for URL tests" OFF ALL )
2014-06-21 19:15:54 +00:00
LYX_OPTION ( ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL )
2016-07-13 08:51:58 +00:00
LYX_OPTION ( ENABLE_KEYTESTS "Enable for keytests" OFF ALL )
2020-04-07 10:12:29 +00:00
if ( NOT CMAKE_VERSION VERSION_LESS "3.17" )
2020-06-16 22:26:51 +00:00
LYX_OPTION ( ENABLE_VALGRIND_TESTS "Enable for tests involving valgrind" OFF ALL )
2020-04-07 12:16:07 +00:00
else ( )
2020-06-16 22:26:51 +00:00
if ( LYX_ENABLE_VALGRIND_TESTS )
unset ( LYX_ENABLE_VALGRIND_TESTS CACHE )
endif ( )
2020-04-07 10:12:29 +00:00
endif ( )
2021-09-21 09:27:13 +00:00
LYX_COMBO ( DEBUG_SANITIZE "Use sanitize check" NONE ADDRESS UNSPECIFIED )
2020-02-22 20:13:43 +00:00
#LYX_COMBO(USE_FILEDIALOG "Use native or QT file dialog" QT NATIVE)
2022-11-19 13:45:03 +00:00
LYX_COMBO ( USE_QT "Use Qt version as frontend" AUTO QT5 QT6 )
2019-12-17 12:59:52 +00:00
LYX_COMBO ( USE_IPO "Interprocedural optimization" OFF AUTO ON )
2016-07-05 13:57:04 +00:00
#LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL)
2019-02-26 08:50:58 +00:00
LYX_OPTION ( DISABLE_CALLSTACK_PRINTING "do not print a callstack when crashing" OFF ALL )
2020-08-09 08:42:02 +00:00
LYX_OPTION ( EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ${ DefaultExternalLibs } ALL )
LYX_OPTION ( EXTERNAL_DTL "OFF := Build 3rdparty commands dt2dv and dv2dt" ${ DefaultExternalLibs } ALL )
LYX_OPTION ( EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ${ DefaultExternalLibs } ALL )
LYX_OPTION ( EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ${ DefaultExternalLibs } ALL )
2017-03-07 13:27:08 +00:00
LYX_COMBO ( EXTERNAL_MYTHES "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON )
2011-05-10 17:21:15 +00:00
# GCC specific
2020-07-14 18:06:43 +00:00
LYX_OPTION ( PROFILE "Build with options for gprof" ${ DefaultLyxProfile } GCC )
2020-11-30 09:17:40 +00:00
LYX_OPTION ( EXTERNAL_BOOST "Use external boost" ${ DefaultExternalLibs } GCC )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( PROGRAM_SUFFIX "Append version suffix to binaries" ON GCC )
LYX_OPTION ( DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC )
2013-01-30 02:35:06 +00:00
LYX_OPTION ( DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC )
2022-12-07 10:04:55 +00:00
LYX_OPTION ( DEBUG_GLIBC_ASSERTIONS "Enable stdlib-assertions debug mode" OFF GCC )
2020-07-13 11:51:44 +00:00
LYX_OPTION ( STDLIB_DEBUG "Use debug stdlib" ${ DefaultLyxStdlibDebug } GCC )
2011-05-10 17:21:15 +00:00
# MSVC specific
2017-08-18 10:07:03 +00:00
LYX_OPTION ( CONSOLE "Show console on Windows" ON MSVC )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( VLD "Use VLD with MSVC" OFF MSVC )
LYX_OPTION ( WALL "Enable all warnings" OFF MSVC )
2011-05-10 17:21:15 +00:00
LYX_OPTION ( DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC )
2011-05-15 13:21:18 +00:00
# APPLE specific
2011-05-15 13:37:18 +00:00
LYX_OPTION ( DMG "Build as Mac bundle, needed for .dmg (experimental) " OFF MAC )
LYX_OPTION ( COCOA "Use Cocoa on Mac" OFF MAC )
2011-05-10 20:25:31 +00:00
2021-01-27 19:13:42 +00:00
# On Windows, download the dependencies if need be.
if ( LYX_DEPENDENCIES_DOWNLOAD )
message ( STATUS )
# Do not check for bitness against CMAKE_SIZEOF_VOID_P, as it relates to the bitness of the CMake executable,
# not that of the compiler.
if ( MSVC_VERSION GREATER_EQUAL 1920 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" MATCHES "x64" )
set ( LYX_DEPENDENCIES_DIR ${ TOP_BINARY_DIR } /msvc2019-deps-64 )
set ( deps_files lyx-windows-deps-msvc2019_64.zip )
set ( deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps )
set ( GNUWIN32_DIR ${ LYX_DEPENDENCIES_DIR } /lyx-windows-deps-msvc2019-64 )
elseif ( MSVC_VERSION GREATER_EQUAL 1920 )
set ( LYX_DEPENDENCIES_DIR ${ TOP_BINARY_DIR } /msvc2019-deps )
set ( deps_files lyx-windows-deps-msvc2019_32.zip )
set ( deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps )
set ( GNUWIN32_DIR ${ LYX_DEPENDENCIES_DIR } /lyx-windows-deps-msvc2019 )
elseif ( MSVC_VERSION GREATER_EQUAL 1900 AND NOT "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" MATCHES "x64" )
set ( LYX_DEPENDENCIES_DIR ${ TOP_BINARY_DIR } /msvc2015-deps )
set ( deps_files lyx-windows-deps-msvc2015.zip )
set ( deps_server http://ftp.lyx.org/pub/lyx/devel/win_deps )
set ( GNUWIN32_DIR ${ LYX_DEPENDENCIES_DIR } /lyx-windows-deps-msvc2015 )
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 )
find_file ( already_downloaded ${ it } "${LYX_DEPENDENCIES_DIR}/download" )
if ( NOT already_downloaded )
message ( STATUS "Downloading ${it} ..." )
file ( DOWNLOAD ${ deps_server } / ${ it } ${ LYX_DEPENDENCIES_DIR } /download/ ${ it } SHOW_PROGRESS STATUS status LOG log )
list ( GET status 0 status_code )
list ( GET status 1 status_string )
if ( NOT status_code EQUAL 0 )
file ( REMOVE ${ LYX_DEPENDENCIES_DIR } / ${ it } )
message ( FATAL_ERROR "error: downloading '${it}' failed. status_code: ${status_code}, status_string: ${status_string}. \nLog: ${log} " )
endif ( )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar xzf ${ LYX_DEPENDENCIES_DIR } /download/ ${ it }
W O R K I N G _ D I R E C T O R Y $ { L Y X _ D E P E N D E N C I E S _ D I R } )
endif ( )
endforeach ( )
endif ( )
# Try to get some information from configure.ac
2020-11-18 18:17:44 +00:00
include ( LyXPaths )
2011-05-20 22:26:46 +00:00
2011-05-10 20:25:31 +00:00
if ( help OR HELP )
message ( STATUS )
2011-05-28 08:30:44 +00:00
message ( STATUS "Available options: (dis/enable with -DLYX_*=OFF/ON)" )
2011-05-10 20:25:31 +00:00
message ( STATUS )
2011-05-22 09:33:53 +00:00
LYX_OPTION_LIST_ALL ( help )
2011-05-10 20:25:31 +00:00
message ( STATUS )
2020-10-28 22:12:03 +00:00
unset ( help CACHE )
unset ( HELP CACHE )
2011-05-28 08:30:44 +00:00
RETURN ( )
endif ( )
2011-05-10 20:25:31 +00:00
2020-07-12 14:27:45 +00:00
if ( "${LYX_SUFFIX_VALUE}" MATCHES "" )
set ( LYX_INSTALL_SUFFIX "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}" )
else ( )
set ( LYX_INSTALL_SUFFIX "${LYX_SUFFIX_VALUE}" )
endif ( )
2011-05-10 17:21:15 +00:00
# Check option dependencies
2020-04-07 10:12:29 +00:00
if ( LYX_ENABLE_VALGRIND_TESTS )
find_program ( VALGRIND_EXECUTABLE "valgrind" )
if ( NOT VALGRIND_EXECUTABLE )
message ( FATAL_ERROR "Cannot use valgrind tests, executable valgrind is missing. Please disable LYX_ENABLE_VALGRIND_TESTS" )
endif ( )
endif ( )
2020-11-30 09:17:40 +00:00
if ( LYX_DEBUG_GLIBC OR LYX_DEBUG_GLIBC_PEDANTIC OR LYX_STDLIB_DEBUG )
if ( LYX_EXTERNAL_BOOST )
message ( FATAL_ERROR "Using external boost not compatible with debug mode for stdlib" )
endif ( )
endif ( )
2011-05-10 20:25:31 +00:00
2011-05-20 22:26:46 +00:00
if ( LYX_DMG )
2011-05-22 09:33:53 +00:00
set ( LYX_BUNDLE ON )
set ( LYX_CPACK ON )
2011-05-20 22:26:46 +00:00
endif ( )
2013-01-26 10:29:48 +00:00
if ( LYX_CPACK )
set ( LYX_INSTALL ON )
endif ( )
2011-05-10 17:21:15 +00:00
if ( LYX_INSTALL )
set ( LYX_NLS ON )
2014-06-07 05:59:52 +00:00
if ( WIN32 AND NOT MINGW )
2011-05-10 17:21:15 +00:00
set ( LYX_HUNSPELL ON )
endif ( )
set ( LYX_PACKAGE_SUFFIX ON )
2013-01-26 10:29:48 +00:00
if ( NOT LYX_DEBUG )
set ( LYX_RELEASE ON )
endif ( )
2011-05-10 17:21:15 +00:00
set ( LYX_PROFILE OFF )
endif ( )
2011-05-15 13:21:18 +00:00
2011-05-10 17:21:15 +00:00
if ( LYX_MERGE_FILES )
set ( LYX_PCH OFF )
else ( )
set ( LYX_MERGE_REBUILD OFF )
endif ( )
message ( STATUS )
set ( EXECUTABLE_OUTPUT_PATH ${ TOP_BINARY_DIR } /bin )
2011-05-22 11:38:10 +00:00
if ( WIN32 )
set ( LIBRARY_OUTPUT_PATH ${ EXECUTABLE_OUTPUT_PATH } )
else ( )
set ( LIBRARY_OUTPUT_PATH ${ TOP_BINARY_DIR } /lib )
endif ( )
2011-05-10 17:21:15 +00:00
2019-12-17 12:59:52 +00:00
set ( LYX_IPO_SUPPORTED OFF )
if ( POLICY CMP0069 )
cmake_policy ( SET CMP0069 NEW )
if ( LYX_USE_IPO MATCHES "AUTO" )
# Enable LTO if supported and not debugging
if ( NOT LYX_DEBUG )
include ( CheckIPOSupported )
check_ipo_supported ( RESULT LYX_IPO_SUPPORTED )
endif ( )
else ( )
set ( LYX_IPO_SUPPORTED ${ LYX_USE_IPO } )
endif ( )
endif ( )
if ( LYX_IPO_SUPPORTED )
set ( LYX_USE_IPO "ON" CACHE STRING "Use interprocedural optimization" FORCE )
else ( )
set ( LYX_USE_IPO "OFF" CACHE STRING "Use interprocedural optimization" FORCE )
endif ( )
2011-05-10 17:21:15 +00:00
2016-06-07 18:33:06 +00:00
# Set to some meaningful default
find_package ( CXX11Compiler )
if ( NOT CXX11COMPILER_FOUND )
message ( FATAL_ERROR "A C++11 compatible compiler is required." )
2016-02-11 08:03:07 +00:00
endif ( )
2020-04-07 09:48:45 +00:00
unset ( LYX_GCC11_MODE )
2011-05-10 17:21:15 +00:00
if ( UNIX OR MINGW )
2018-06-12 20:42:48 +00:00
if ( CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$" )
2016-06-11 10:23:33 +00:00
# ignore the GCC_VERSION for clang
message ( STATUS "Using clang" )
2015-12-06 19:04:21 +00:00
else ( )
2019-06-13 07:18:40 +00:00
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpfullversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE )
#message(STATUS "dumpfullversion: error = ${_error}, result = ${_err}")
if ( _err )
# previous check failed, try again with _old_ parameter
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION ERROR_VARIABLE _error RESULT_VARIABLE _err OUTPUT_STRIP_TRAILING_WHITESPACE )
#message(STATUS "dumpversion: error = ${_error}, result = ${_err}")
endif ( )
2016-06-11 10:23:33 +00:00
message ( STATUS "Using GCC version ${GCC_VERSION}" )
2020-11-24 22:00:28 +00:00
if ( GCC_VERSION VERSION_LESS 4.9 )
message ( FATAL_ERROR "gcc >= 4.9 is required." )
2016-06-11 10:23:33 +00:00
endif ( )
2012-10-24 09:36:54 +00:00
endif ( )
2016-06-07 18:33:06 +00:00
set ( LYX_GCC11_MODE "${CXX11_FLAG}" )
2011-05-10 17:21:15 +00:00
else ( )
2019-06-29 14:45:38 +00:00
if ( MSVC_VERSION LESS 1900 )
# Drop support for msvc versions prior to 1900 (Visual Studio 2015)
message ( FATAL_ERROR "Visual Studio >= 2015 is required." )
2018-10-25 08:14:49 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
endif ( )
2016-07-05 13:57:04 +00:00
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 )
2017-03-07 13:27:08 +00:00
set ( LYX_EXTERNAL_MYTHES OFF CACHE STRING "Build 3rdparty mytheslib" FORCE )
2016-07-05 13:57:04 +00:00
endif ( )
2014-10-11 09:18:48 +00:00
FIND_PROGRAM ( LYX_GITVERSION git )
#message(STATUS "gitversion = ${LYX_GITVERSION}")
2020-01-17 13:25:57 +00:00
set ( LYX_REVISION_VERSION ${ LYX_RELEASE_LEVEL } )
2020-02-12 11:02:36 +00:00
set ( LYX_PACKAGE_RELEASE "UNDEFINED" )
2014-10-11 09:18:48 +00:00
if ( LYX_GITVERSION )
if ( LYX_LOCALVERSIONING )
2020-01-17 14:27:17 +00:00
# Find the revision number for later use
2014-10-11 09:18:48 +00:00
EXECUTE_PROCESS ( COMMAND ${ LYX_GITVERSION } describe --match 2.0.0 HEAD
2020-02-12 11:02:36 +00:00
W O R K I N G _ D I R E C T O R Y " $ { T O P _ S R C _ D I R } "
R E S U L T _ V A R I A B L E t m p _ G I T _ R E S U L T
O U T P U T _ V A R I A B L E t m p _ L Y X _ P A C K A G E _ R E L E A S E
E R R O R _ V A R I A B L E t m p _ G I T _ E R R O R
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( tmp_GIT_RESULT EQUAL 0 )
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
MATH ( EXPR tmp_REVISION_VERSION "(${CMAKE_MATCH_1}+40000)" )
set ( LYX_REVISION_VERSION "${LYX_RELEASE_LEVEL}-${tmp_REVISION_VERSION}git" )
set ( ENABLE_DIST ON )
endif ( )
2014-10-11 09:18:48 +00:00
endif ( )
endif ( )
2020-02-12 11:02:36 +00:00
endif ( )
if ( LYX_PACKAGE_RELEASE MATCHES "UNDEFINED" )
set ( LYX_PACKAGE_RELEASE "1" )
2020-01-17 14:27:17 +00:00
if ( LYX_RELEASE_PATCH GREATER 0 )
set ( LYX_REVISION_VERSION "${LYX_RELEASE_LEVEL}.${LYX_RELEASE_PATCH}" )
endif ( )
2011-05-22 08:18:54 +00:00
endif ( )
2014-10-11 09:18:48 +00:00
# Set the programs (lyx, tex2lyx, etc.) suffix
2014-03-09 09:21:51 +00:00
# When building an OS X bundle, we will append
# the suffix only to the bundle, not to the programs
2014-03-09 09:24:07 +00:00
set ( PROGRAM_SUFFIX "" )
2014-03-09 09:21:51 +00:00
if ( LYX_PROGRAM_SUFFIX AND NOT ( APPLE AND LYX_BUNDLE ) )
set ( PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}" )
2011-05-20 22:26:46 +00:00
endif ( )
2014-03-09 09:21:51 +00:00
set ( _lyx "${PACKAGE_BASE}${PROGRAM_SUFFIX}" )
set ( _tex2lyx tex2lyx ${ PROGRAM_SUFFIX } )
2017-10-02 00:00:47 +00:00
set ( _convert lyxconvert ${ PROGRAM_SUFFIX } )
2011-05-20 22:26:46 +00:00
2012-11-01 12:00:19 +00:00
add_custom_target ( lyx_version ALL
2012-11-02 12:33:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - D T O P _ S R C _ D I R = $ { T O P _ S R C _ D I R } - D T O P _ C M A K E _ P A T H = $ { T O P _ C M A K E _ P A T H } - D T O P _ B I N A R Y _ D I R = $ { T O P _ B I N A R Y _ D I R } - D L Y X _ D A T E = $ { L Y X _ D A T E } - P $ { T O P _ S C R I P T _ P A T H } / L y X G e t V e r s i o n . c m a k e
2012-11-01 12:00:19 +00:00
)
2012-10-22 16:12:29 +00:00
set_target_properties ( lyx_version PROPERTIES FOLDER "applications" )
2011-05-20 22:26:46 +00:00
2014-03-09 09:21:51 +00:00
# Default paths for installed utilities (tex2lyx, lyxclient, etc.)
set ( LYX_UTILITIES_INSTALL_PATH bin )
2012-10-13 07:53:20 +00:00
2011-05-20 22:26:46 +00:00
if ( LYX_BUNDLE )
2011-05-22 09:33:53 +00:00
set ( LYX_CPACK ON )
2014-03-09 09:21:51 +00:00
2011-05-21 12:17:05 +00:00
message ( STATUS )
message ( STATUS "Bundle creation is enabled (experimental):" )
message ( STATUS " make" )
message ( STATUS " make install/strip" )
message ( STATUS " make package" )
2011-05-20 22:26:46 +00:00
if ( APPLE )
2014-03-09 09:21:51 +00:00
set ( MACOSX_BUNDLE TRUE )
# This sets the bundle + executable names
set ( _lyx "${PACKAGE_BASE}${LYX_INSTALL_SUFFIX}" )
# This sets the Info.plist executable name
set ( osx_bundle_program_name ${ _lyx } )
# Bundle name
set ( LYX_BUNDLE_NAME ${ _lyx } )
# This will contain the list of files that need to be included
# in the bundle and their location within the bundle
set ( OSX_BUNDLE_FILES "${TOP_SRC_DIR}/development/MacOSX/LyX.sdef;${TOP_SRC_DIR}/development/MacOSX/LyXapp.icns;${CMAKE_BINARY_DIR}/lyxrc.dist" )
set ( OSX_BUNDLE_DIRS "Resources;Resources;Resources" )
# Process Info.plist and lyxrc.dist
2018-01-03 13:58:58 +00:00
# See development/cmake/Install.cmake
2014-03-09 09:21:51 +00:00
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/development/MacOSX/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" )
2011-05-20 22:26:46 +00:00
set ( LYX_BUILD_BUNDLE MACOSX_BUNDLE )
2014-03-09 09:21:51 +00:00
set ( LYX_DATA_SUBDIR ${ LYX_BUNDLE_NAME } .app/Contents/Resources/ CACHE STRING "Bundle Contents dir" FORCE )
# Variables used by CPack
set ( CPACK_BUNDLE_NAME ${ LYX_BUNDLE_NAME } )
2012-10-13 07:53:20 +00:00
set ( CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" )
2014-03-09 09:21:51 +00:00
set ( MACOSX_BUNDLE_STARTUP_COMMAND ${ LYX_BUNDLE_NAME } .app )
# Set the install paths
set ( LYX_UTILITIES_INSTALL_PATH ${ LYX_BUNDLE_NAME } .app/Contents/MacOS )
2011-05-20 22:26:46 +00:00
if ( NOT LYX_INSTALL_PREFIX )
set ( CMAKE_INSTALL_PREFIX ${ CMAKE_BINARY_DIR } /LyX CACHE PATH "Mac bundle dir" FORCE )
set ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
endif ( )
2012-10-13 07:53:20 +00:00
# Change the owner so that the install can work
2014-03-09 09:21:51 +00:00
install ( CODE "set(BU_CHMOD_BUNDLE_ITEMS 1)" COMPONENT Runtime )
2011-05-21 12:17:05 +00:00
elseif ( UNIX )
message ( STATUS "To embed Qt in this bundle don't build with your system Qt:" )
message ( STATUS " - fix PATH so a other qmake is found by cmake" )
message ( STATUS " - fix LD_LIBRARY_PATH so lyx doesn't use system's Qt" )
elseif ( WIN32 )
message ( STATUS "A zipped-only release could be created by building the 'PACKAGE' project" )
2011-05-20 22:26:46 +00:00
endif ( )
2011-05-15 13:21:18 +00:00
endif ( )
if ( LYX_INSTALL_PREFIX )
2011-05-10 17:21:15 +00:00
set ( CMAKE_INSTALL_PREFIX ${ LYX_INSTALL_PREFIX } CACHE PATH "LyX user's choice install prefix" FORCE )
set ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
2024-05-24 18:26:04 +00:00
set ( LYX_INSTALL_PREFIX ${ LYX_INSTALL_PREFIX } CACHE PATH "LyX user's choice install prefix" FORCE )
2011-05-10 17:21:15 +00:00
endif ( )
2024-05-24 18:26:04 +00:00
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
# see http://www.cmake.org/pipermail/cmake/2006-October/011559.html
if ( UNIX )
# use the default "/usr/local"
# but respect the user-choice on the command-line
set ( CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "LyX default install prefix" FORCE )
endif ( )
if ( WIN32 )
set ( CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE )
endif ( )
endif ( )
2011-05-10 17:21:15 +00:00
2016-06-10 11:38:29 +00:00
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 ( )
2014-05-09 08:04:42 +00:00
2018-09-29 21:26:14 +00:00
if ( NOT CMAKE_COMPILER_IS_GNUCXX )
2017-05-02 06:16:00 +00:00
# Not a GCC compiler, programs do not have a suffix
set ( suffixing ${ LYX_PACKAGE_SUFFIX } )
2018-09-29 21:26:14 +00:00
elseif ( WIN32 AND MINGW )
# We want to use a suffix for the package in this case,
# even if not for the program
set ( suffixing ${ LYX_PACKAGE_SUFFIX } )
else ( )
message ( STATUS "CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}" )
set ( suffixing ${ LYX_PROGRAM_SUFFIX } )
2017-05-02 06:16:00 +00:00
endif ( )
# The define PACKAGE below allows lyx-executable to find its default configuration files
2016-08-03 10:09:04 +00:00
# see routines
# Package::messages_file()
# get_default_user_support_dir()
# relative_system_support_dir()
# in src/support/Package.cpp
2017-05-02 06:16:00 +00:00
if ( suffixing )
2011-05-10 17:21:15 +00:00
set ( PACKAGE ${ PACKAGE_BASE } ${ LYX_INSTALL_SUFFIX } )
2011-05-22 09:33:53 +00:00
else ( )
2011-05-10 17:21:15 +00:00
set ( PACKAGE ${ PACKAGE_BASE } )
endif ( )
2011-05-21 09:50:41 +00:00
if ( IS_ABSOLUTE )
set ( CMAKE_INSTALL_PREFIX_ABSOLUTE ${ CMAKE_INSTALL_PREFIX } )
else ( )
set ( CMAKE_INSTALL_PREFIX_ABSOLUTE ${ CMAKE_BINARY_DIR } / ${ CMAKE_INSTALL_PREFIX } )
endif ( )
2011-05-10 17:21:15 +00:00
2024-05-18 08:27:54 +00:00
if ( WIN32 )
set ( LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE )
else ( )
set ( LYX_DATA_SUBDIR "share/${_lyx}/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE )
2011-05-10 17:21:15 +00:00
endif ( )
2020-04-14 17:59:41 +00:00
set ( LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}/${LYX_DATA_SUBDIR}" )
2016-06-06 06:29:07 +00:00
get_locale_destination ( LYX_LOCALEDIR )
2016-06-05 20:59:13 +00:00
set ( LYX_ABS_INSTALLED_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LYX_LOCALEDIR}" )
2011-05-10 17:21:15 +00:00
set ( LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}" )
2014-03-09 09:21:51 +00:00
if ( LYX_BUNDLE AND APPLE )
2020-04-17 10:13:08 +00:00
set ( LYX_MAN_DIR_tmp "${LYX_DATA_SUBDIR}" )
2014-03-09 09:21:51 +00:00
else ( )
2016-01-20 18:37:53 +00:00
if ( WIN32 )
2020-04-17 10:13:08 +00:00
set ( LYX_MAN_DIR_tmp "${CMAKE_BINARY_DIR}/usr/local/man/" )
2016-06-07 12:38:20 +00:00
elseif ( UNIX )
2020-04-17 10:13:08 +00:00
set ( LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/share/man/" )
2016-01-20 18:37:53 +00:00
else ( )
2020-04-17 10:13:08 +00:00
set ( LYX_MAN_DIR_tmp "${CMAKE_INSTALL_PREFIX}/man/" )
2016-01-20 18:37:53 +00:00
endif ( )
2014-03-09 09:21:51 +00:00
endif ( )
2020-04-17 10:13:08 +00:00
if ( NOT LYX_MAN_DIR_tmp EQUAL "${LYX_MAN_DIR}" )
unset ( LYX_MAN_DIR CACHE )
set ( LYX_MAN_DIR "${LYX_MAN_DIR_tmp}" CACHE STRING "Install location for man pages." )
endif ( )
unset ( LYX_MAN_DIR_tmp )
2013-09-06 12:56:31 +00:00
mark_as_advanced ( LYX_MAN_DIR )
2011-05-10 17:21:15 +00:00
2017-11-20 20:05:16 +00:00
# The Win installer cannot be built by CMake because one needs to install plugins for NSIS
# see the Readme.txt of the installer
#if(LYX_INSTALL AND WIN32)
# message(STATUS "Configuring NSIS files")
# configure_file(development/Win32/packaging/installer/lyx.nsi.cmake ${CMAKE_BINARY_DIR}/installer/lyx.nsi @ONLY)
# configure_file(development/Win32/packaging/installer/settings.nsh.cmake ${CMAKE_BINARY_DIR}/installer/settings-cmake.nsh @ONLY)
# configure_file(development/Win32/packaging/installer/include/declarations.nsh.cmake ${CMAKE_BINARY_DIR}/installer/declarations-cmake.nsh @ONLY)
# message(STATUS "NSIS files are created in ${CMAKE_BINARY_DIR}/installer")
#endif()
2011-05-15 13:21:18 +00:00
2011-05-10 17:21:15 +00:00
if ( NOT GROUP_CODE )
#set(GROUP_CODE "The Golden Code")
set ( GROUP_CODE flat )
endif ( )
# lyx's source files
2014-10-21 12:50:44 +00:00
set ( LYX_CPP_FILES [a-zA-Z]*.cpp )
2014-10-21 13:04:48 +00:00
set ( LYX_HPP_FILES [a-zA-Z]*.h )
2011-05-10 17:21:15 +00:00
set ( LYX_MOC_FILES moc_*.cpp )
include ( ProjectSourceGroup )
2011-08-19 18:04:41 +00:00
if ( LYX_PROFILE AND NOT MSVC )
2019-02-05 11:27:15 +00:00
set ( CMAKE_BUILD_TYPE Profile CACHE STRING "Profile build type" FORCE )
2011-08-19 18:04:41 +00:00
set ( CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" )
2011-06-11 08:54:27 +00:00
else ( )
set ( LYX_PROFILE OFF )
2011-05-10 17:21:15 +00:00
endif ( )
2011-05-15 13:21:18 +00:00
if ( LYX_NO_OPTIMIZE )
set ( CMAKE_BUILD_TYPE None )
set ( LYX_DEBUG OFF )
set ( LYX_RELEASE OFF )
2011-06-11 08:54:27 +00:00
set ( LYX_PROFILE OFF )
2011-05-15 13:21:18 +00:00
elseif ( LYX_RELEASE )
set ( CMAKE_BUILD_TYPE Release )
set ( LYX_DEBUG OFF )
2011-06-11 08:54:27 +00:00
set ( LYX_PROFILE OFF )
elseif ( LYX_PROFILE )
set ( CMAKE_BUILD_TYPE Profile )
set ( LYX_DEBUG OFF )
2011-05-10 17:21:15 +00:00
else ( )
2011-05-15 13:21:18 +00:00
set ( CMAKE_BUILD_TYPE Debug )
2011-06-05 10:37:12 +00:00
set ( LYX_DEBUG ON )
2011-05-10 17:21:15 +00:00
endif ( )
2022-12-07 10:04:55 +00:00
set ( min_qt5_version "5.6" )
if ( LYX_USE_QT MATCHES "AUTO" )
# try qt6 first
2024-04-06 08:34:00 +00:00
foreach ( _mod Core Gui Widgets Concurrent Svg )
find_package ( Qt6 ${ _mod } CONFIG QUIET )
if ( NOT Qt6 ${ _mod } _FOUND )
message ( STATUS "Not found Qt6${_mod}, aborting use of QT6" )
set ( Qt6Core_FOUND OFF )
break ( )
else ( )
message ( STATUS "Found Qt6${_mod}" )
endif ( )
endforeach ( )
2024-04-02 08:46:20 +00:00
if ( Qt6Core_FOUND )
2022-12-07 10:04:55 +00:00
set ( LYX_USE_QT "QT6" CACHE STRING "Valid qt version" FORCE )
2024-04-02 08:46:20 +00:00
message ( STATUS "Qt6Core_VERSION = ${Qt6Core_VERSION}" )
2022-12-07 10:04:55 +00:00
else ( )
find_package ( Qt5Core CONFIG 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 } )
message ( FATAL_ERROR "No appropriate QT-version found" )
endif ( )
else ( )
message ( FATAL_ERROR "No appropriate QT-version found" )
endif ( )
endif ( )
endif ( )
2011-05-15 13:21:18 +00:00
2011-05-10 17:21:15 +00:00
# When shared libs are supported enable this option
#LYX_OPTION(SHARED_LIBRARIES "Build shared libraries" OFF ALL)
if ( LYX_SHARED_LIBRARIES )
set ( library_type SHARED )
else ( )
2013-11-30 02:08:34 +00:00
set ( library_type STATIC )
2011-05-10 17:21:15 +00:00
endif ( )
2020-07-13 11:51:44 +00:00
if ( LYX_ENABLE_ASSERTIONS )
set ( LYX_CXX_FLAGS " -DENABLE_ASSERTIONS=1" )
else ( )
set ( LYX_CXX_FLAGS "" )
endif ( )
2021-09-21 09:27:13 +00:00
if ( LYX_DEBUG_SANITIZE MATCHES "ADDRESS" )
set ( LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
message ( STATUS )
message ( STATUS "Address sanitizer enabled. Usage:" )
message ( STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py" )
message ( STATUS " chmod +x ./asan_symbolize.py" )
message ( STATUS " ./bin/${_lyx} 2>&1 | ./asan_symbolize.py | c++filt " )
message ( STATUS )
elseif ( LYX_DEBUG_SANITIZE MATCHES "UNSPECIFIED" )
set ( LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer" )
endif ( )
2020-05-05 11:49:50 +00:00
if ( MSVC )
if ( CXX11_FLAG MATCHES "\\+\\+([0-9]+)" )
set ( CMAKE_CXX_STANDARD ${ CMAKE_MATCH_1 } )
message ( STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}" )
endif ( )
2020-07-13 11:51:44 +00:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${LYX_CXX_FLAGS}" )
2020-05-05 11:49:50 +00:00
else ( )
2011-05-10 17:21:15 +00:00
if ( NOT LYX_QUIET )
set ( CMAKE_VERBOSE_MAKEFILE ON )
endif ( )
2020-10-22 11:46:29 +00:00
if ( LYX_GCC11_MODE MATCHES "\\+\\+([0-9][0-9])" )
2016-07-15 08:37:18 +00:00
# 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
2020-10-22 16:53:53 +00:00
set ( std_num ${ CMAKE_MATCH_1 } )
2020-10-28 22:12:03 +00:00
set ( CMAKE_CXX_STANDARD ${ std_num } )
2020-10-22 11:46:29 +00:00
else ( )
2020-10-28 22:12:03 +00:00
message ( STATUS "Setting CMAKE_CXX_STANDARD 11 as fallback" )
set ( CMAKE_CXX_STANDARD 11 )
set ( LYX_GCC11_MODE "--std=c++11" )
2016-07-15 08:37:18 +00:00
endif ( )
2020-10-28 22:12:03 +00:00
# The following setting with LYX_GCC11_MODE is needed because cmake does not honor
# CMAKE_CXX_STANDARD while performing tests like
# check_cxx_source_compiles("..." HAVE_DEF_MAKE_UNIQUE)
2021-04-05 09:14:13 +00:00
include ( CheckCXXCompilerFlag )
unset ( CHECK_WNODEPRECATEDCOPY_FLAG CACHE )
2021-09-29 15:53:50 +00:00
CHECK_CXX_COMPILER_FLAG ( "-Wdeprecated-copy" CHECK_WNODEPRECATEDCOPY_FLAG )
2021-04-05 09:14:13 +00:00
if ( ${ CHECK_WNODEPRECATEDCOPY_FLAG } )
set ( LYX_CXX_FLAGS "-Wall -Wextra -Wno-deprecated-copy ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}" )
else ( )
set ( LYX_CXX_FLAGS "-Wall -Wextra ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}" )
endif ( )
2022-12-07 10:04:55 +00:00
message ( STATUS "LYX_USE_QT = ${LYX_USE_QT}" )
if ( LYX_USE_QT MATCHES "QT6" )
if ( LYX_DEBUG_GLIBC OR LYX_DEBUG_GLIBC_PEDANTIC )
message ( WARNING "Compiling LyX with stdlib-debug and Qt6 library may lead to crashes. Consider dropping -DLYX_DEBUG_GLIBC=ON and -DLYX_DEBUG_GLIBC_PEDANTIC=ON" )
endif ( )
endif ( )
if ( LYX_STDLIB_DEBUG OR LYX_DEBUG_GLIBC_ASSERTIONS )
set ( LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_ASSERTIONS" )
endif ( )
if ( LYX_DEBUG_GLIBC )
set ( LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG" )
endif ( )
if ( LYX_DEBUG_GLIBC_PEDANTIC )
set ( LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG_PEDANTIC" )
2011-05-10 17:21:15 +00:00
endif ( )
2019-02-05 11:27:15 +00:00
set ( CMAKE_CXX_FLAGS "${LYX_CXX_FLAGS} -fno-strict-aliasing " CACHE STRING "Set CXX flags" FORCE )
set ( CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -D_DEBUG" CACHE STRING "Set debug flags" FORCE )
2011-05-10 17:21:15 +00:00
if ( MINGW )
2020-10-16 05:17:04 +00:00
set ( CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Set release flags for Mingw" FORCE )
2011-05-10 17:21:15 +00:00
else ( )
2020-10-16 05:17:04 +00:00
set ( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Set release flags" FORCE )
2011-05-10 17:21:15 +00:00
endif ( )
endif ( )
2013-12-05 11:00:02 +00:00
set ( LYX_CXX_FLAGS_EXTRA "" CACHE STRING "Desired semicolon separated list of extra cxx compile flags, like '-Werror'" )
mark_as_advanced ( LYX_CXX_FLAGS_EXTRA )
2013-11-30 02:08:48 +00:00
if ( LYX_CXX_FLAGS_EXTRA )
2013-12-05 11:00:02 +00:00
foreach ( _flag ${ LYX_CXX_FLAGS_EXTRA } )
add_definitions ( ${ _flag } )
endforeach ( )
2013-11-30 02:08:48 +00:00
endif ( )
2014-06-07 05:59:52 +00:00
if ( LYX_XMINGW )
2015-10-23 13:36:39 +00:00
list ( APPEND CMAKE_FIND_ROOT_PATH ${ GNUWIN32_DIR } )
2014-06-07 05:59:52 +00:00
endif ( )
2015-10-23 13:36:39 +00:00
2021-03-22 15:19:10 +00:00
set ( QtCore5CompatLibrary )
set ( QtCore5CompatModule )
if ( LYX_USE_QT MATCHES "QT6|QT5" )
if ( LYX_USE_QT MATCHES "QT6" )
set ( QtVal "Qt6" )
macro ( qt_add_resources )
Qt6_add_resources ( ${ ARGN } )
endmacro ( )
macro ( qt_wrap_uifiles )
Qt6_wrap_ui ( ${ ARGN } )
endmacro ( )
else ( )
set ( QtVal "Qt5" )
macro ( qt_add_resources )
Qt5_add_resources ( ${ ARGN } )
endmacro ( )
macro ( qt_wrap_uifiles )
Qt5_wrap_ui ( ${ ARGN } )
endmacro ( )
endif ( )
2016-04-09 09:53:55 +00:00
# set QPA_XCB if QT uses X11
2021-03-22 15:19:10 +00:00
find_package ( ${ QtVal } Core CONFIG REQUIRED )
if ( ${ QtVal } Core_FOUND )
find_package ( ${ QtVal } Widgets CONFIG REQUIRED )
2014-08-21 16:22:43 +00:00
if ( APPLE )
2021-03-25 16:29:24 +00:00
if ( LYX_USE_QT MATCHES "QT6" )
find_package ( ${ QtVal } MacExtras CONFIG QUIET )
else ( )
find_package ( ${ QtVal } MacExtras CONFIG REQUIRED )
endif ( )
2014-08-21 16:22:43 +00:00
endif ( )
2021-03-22 15:19:10 +00:00
find_package ( ${ QtVal } X11Extras CONFIG QUIET )
find_package ( ${ QtVal } WinExtras CONFIG QUIET )
set ( QTVERSION ${ ${QtVal } Core_VERSION} )
2017-05-02 12:12:41 +00:00
if ( QTVERSION VERSION_LESS ${ min_qt5_version } )
2017-03-25 11:43:53 +00:00
message ( STATUS "QTVERSION = \" ${ QTVERSION } \"")
2022-11-19 13:45:03 +00:00
message ( STATUS "This version is not recommended," )
message ( STATUS "please install QT-Version >= \" ${ min_qt5_version } \"")
2017-03-25 11:43:53 +00:00
# see thread in lyx-devel list
# From: Jean-Pierre Chrétien <jeanpierre.chretien@free.fr>
# Date 11.03.2017
# Subject: cmake compilation error
#message(FATAL_ERROR "Wrong Qt-Version")
endif ( )
2018-06-09 14:52:15 +00:00
macro ( qt_use_modules lyxtarget )
foreach ( _tg ${ ARGN } )
2021-03-22 15:19:10 +00:00
find_package ( ${ QtVal } ${ _tg } CONFIG REQUIRED )
target_link_libraries ( ${ lyxtarget } ${ QtVal } :: ${ _tg } )
2018-06-09 14:52:15 +00:00
endforeach ( )
2014-08-21 16:22:43 +00:00
endmacro ( )
2014-08-24 19:59:12 +00:00
message ( STATUS "Found Qt-Version ${QTVERSION}" )
2015-12-10 00:24:04 +00:00
if ( WIN32 )
2021-03-22 15:19:10 +00:00
set ( LYX_QTMAIN_LIBRARY ${ ${QtVal } Core_QTMAIN_LIBRARIES} )
endif ( )
if ( LYX_USE_QT MATCHES "QT6" )
get_target_property ( QT_MOC_EXECUTABLE Qt6::moc LOCATION )
2023-03-03 09:57:12 +00:00
#find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
2022-12-18 21:12:08 +00:00
# We don't know why QtZlib is included, and ideally we
# would have a different fix than relying on this
# variable (which as "Private" in the name indicates,
# it might be a fragile workaround).
# See ML discussion here:
# https://www.mail-archive.com/search?l=mid&q=CAGU9VOqpkngYBumnNh%3DcuzQ585GsS7TJbhHa903nJSfy-davRg%40mail.gmail.com
2022-12-16 20:40:59 +00:00
list ( REMOVE_ITEM Qt6Core5Compat_INCLUDE_DIRS ${ _Qt6ZlibPrivate_OWN_INCLUDE_DIRS } )
2021-03-22 15:19:10 +00:00
include_directories ( ${ Qt6Core5Compat_INCLUDE_DIRS } )
2023-03-03 09:57:12 +00:00
#set(QtCore5CompatLibrary Qt6::Core5Compat)
#set(QtCore5CompatModule Core5Compat)
2015-12-10 00:24:04 +00:00
endif ( )
2014-08-21 16:22:43 +00:00
endif ( )
2014-06-09 08:08:32 +00:00
else ( )
message ( FATAL_ERROR "Unhandled value for LYX_USE_QT (${LYX_USE_QT})" )
2013-04-21 19:42:53 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
2012-02-22 10:07:04 +00:00
find_package ( Magic )
if ( Magic_FOUND )
2018-01-03 13:58:58 +00:00
set ( HAVE_MAGIC_H 1 )
include_directories ( ${ Magic_INCLUDE_DIR } )
2012-02-22 10:07:04 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
include_directories ( ${ TOP_BINARY_DIR } ${ TOP_SRC_DIR } /src )
2011-05-22 09:33:53 +00:00
2014-05-13 10:31:37 +00:00
set ( Spelling_FOUND OFF )
2014-05-13 12:52:11 +00:00
set ( Include_used_spellchecker ) # String will be inserted into config.h
2017-03-07 13:27:08 +00:00
if ( LYX_EXTERNAL_MYTHES MATCHES "AUTO" )
# try system library first
2020-08-04 10:00:14 +00:00
find_package ( MYTHESLIB )
2017-03-07 13:27:08 +00:00
if ( MYTHESLIB_FOUND )
2017-03-25 11:43:53 +00:00
set ( LYX_EXTERNAL_MYTHES ON CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE )
2017-03-07 13:27:08 +00:00
else ( )
2017-03-25 11:43:53 +00:00
set ( LYX_EXTERNAL_MYTHES OFF CACHE STRING "OFF:= Build 3rdparty mytheslib" FORCE )
2017-03-07 13:27:08 +00:00
endif ( )
endif ( )
if ( LYX_EXTERNAL_MYTHES MATCHES "ON" )
2020-08-04 10:12:07 +00:00
find_package ( MYTHESLIB REQUIRED )
2017-03-07 13:27:08 +00:00
else ( )
add_subdirectory ( 3rdparty/mythes )
endif ( )
set ( MYTHES_DIR ${ MYTHESLIB_INCLUDE_DIR } )
2016-07-05 13:57:04 +00:00
if ( NOT LYX_EXTERNAL_HUNSPELL )
2015-12-15 12:18:47 +00:00
add_subdirectory ( 3rdparty/hunspell )
2015-12-09 16:59:47 +00:00
add_definitions ( -DHUNSPELL_STATIC )
set ( HUNSPELL_FOUND ON )
message ( STATUS " * Hunspell:" )
message ( STATUS " - include: ${HUNSPELL_INCLUDE_DIR}" )
message ( STATUS " - library: ${HUNSPELL_LIBRARY}" )
endif ( )
2020-01-27 09:44:14 +00:00
foreach ( _spell "ASPELL" "ENCHANT" "HUNSPELL" )
2014-05-13 10:31:37 +00:00
string ( TOUPPER ${ _spell } _upspell )
2015-12-09 16:59:47 +00:00
if ( NOT ${ _upspell } _FOUND )
find_package ( ${ _spell } )
endif ( )
2014-05-13 10:31:37 +00:00
if ( ${ _upspell } _FOUND )
include_directories ( ${ ${_upspell } _INCLUDE_DIR} )
set ( Spelling_FOUND ON )
message ( STATUS "Building with USE_${_upspell}" )
2014-05-13 12:52:11 +00:00
set ( Include_used_spellchecker "${Include_used_spellchecker}#define USE_${_upspell} 1\n" )
2014-05-13 10:31:37 +00:00
else ( )
2015-12-09 16:59:47 +00:00
if ( LYX_ ${ _upspell } )
2014-05-13 10:31:37 +00:00
message ( FATAL_ERROR "Required ${_spell} devel package not found" )
else ( )
message ( STATUS "${_upspell} not found, building without ${_spell} support" )
endif ( )
endif ( )
endforeach ( )
2011-05-10 17:21:15 +00:00
2016-01-22 11:12:53 +00:00
if ( GNUWIN32_DIR )
list ( APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Python" )
2020-11-18 18:17:44 +00:00
list ( APPEND CMAKE_PROGRAM_PATH "${GNUWIN32_DIR}/Perl/bin" )
2016-01-22 11:12:53 +00:00
endif ( )
2015-12-09 12:54:08 +00:00
2017-04-24 15:48:59 +00:00
# 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 )
2019-11-28 20:51:47 +00:00
if ( CMAKE_VERSION VERSION_LESS "3.13" )
find_package ( PythonInterp 3.5 QUIET )
if ( NOT PYTHONINTERP_FOUND )
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 ( )
2017-04-24 15:48:59 +00:00
endif ( )
2019-11-28 20:51:47 +00:00
set ( LYX_PYTHON_EXECUTABLE ${ PYTHON_EXECUTABLE } CACHE FILEPATH "Python to be used by LyX" )
2019-11-28 14:09:11 +00:00
else ( )
2019-11-28 20:51:47 +00:00
find_package ( Python3 3.5 QUIET )
if ( NOT Python3_Interpreter_FOUND )
unset ( PYTHON_EXECUTABLE CACHE )
find_package ( Python2 2.0 REQUIRED )
2019-11-29 13:47:27 +00:00
if ( NOT Python2_VERSION VERSION_LESS 2.8 )
2019-11-28 20:51:47 +00:00
message ( FATAL_ERROR "Python interpreter found, but is not suitable" )
endif ( )
set ( LYX_PYTHON_EXECUTABLE ${ Python2_EXECUTABLE } CACHE FILEPATH "Python to be used by LyX" )
else ( )
set ( LYX_PYTHON_EXECUTABLE ${ Python3_EXECUTABLE } CACHE FILEPATH "Python to be used by LyX" )
endif ( )
2015-03-10 16:29:58 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
if ( LYX_NLS )
2013-06-02 09:38:27 +00:00
find_package ( LyXGettext )
if ( LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND )
add_subdirectory ( po "${TOP_BINARY_DIR}/po" )
else ( )
# Install only supplied .gmo-files
file ( GLOB _gmofiles RELATIVE "${TOP_SRC_DIR}/po" "${TOP_SRC_DIR}/po/*.gmo" )
message ( STATUS "Installing provided .gmo-files only" )
foreach ( _gmo ${ _gmofiles } )
string ( REGEX REPLACE "\\.gmo$" "" _lang ${ _gmo } )
2016-06-05 20:59:13 +00:00
install ( FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION ${ LYX_LOCALEDIR } / ${ _lang } /LC_MESSAGES RENAME ${ PACKAGE } .mo )
2013-06-02 09:38:27 +00:00
endforeach ( )
2011-05-10 17:21:15 +00:00
endif ( )
endif ( )
2016-07-05 13:57:04 +00:00
if ( LYX_EXTERNAL_ICONV )
2020-10-28 22:12:03 +00:00
# Possible remnants of previous run without external iconv
file ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/libiconv" "${CMAKE_BINARY_DIR}/3rdparty/libiconv" )
2016-07-05 13:57:04 +00:00
find_package ( ICONV REQUIRED )
else ( )
add_subdirectory ( 3rdparty/libiconv )
set ( HAVE_ICONV_CONST 1 )
endif ( )
if ( LYX_EXTERNAL_Z )
find_package ( ZLIB REQUIRED )
2016-07-02 09:09:26 +00:00
else ( )
2016-07-05 13:57:04 +00:00
add_subdirectory ( 3rdparty/zlib )
2015-12-09 12:54:08 +00:00
endif ( )
2020-04-09 09:46:47 +00:00
if ( NOT LYX_EXTERNAL_DTL )
add_subdirectory ( 3rdparty/dtl )
endif ( )
2020-11-30 09:17:40 +00:00
# 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 )
2020-12-13 21:06:05 +00:00
include_directories ( ${ TOP_SRC_DIR } /3rdparty/nod )
2011-05-10 17:21:15 +00:00
if ( WIN32 )
2015-12-09 15:20:54 +00:00
if ( LYX_CONSOLE )
2015-12-10 00:24:04 +00:00
set ( LYX_QTMAIN_LIBRARY )
else ( )
2011-05-10 17:21:15 +00:00
set ( WIN32_CONSOLE WIN32 )
endif ( )
if ( MSVC )
2016-07-01 20:05:55 +00:00
# -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 )
2011-05-10 17:21:15 +00:00
# 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 ( )
2016-07-01 20:05:55 +00:00
# -DPSAPI_VERSION=1 is not needed for mingw, since the mingw psapi.h
# does not use it and always declares the vista compatible API.
2017-07-27 21:29:29 +00:00
# If this ever changes then -DPSAPI_VERSION might be needed here as well.
2020-10-16 05:17:12 +00:00
add_definitions ( -DWINVER=0x0500 )
2011-05-10 17:21:15 +00:00
endif ( )
endif ( )
2017-03-25 11:43:53 +00:00
# Compute qt-version from ${QTVERSION}
2012-11-01 12:00:19 +00:00
2011-05-10 17:21:15 +00:00
message ( STATUS "" )
2014-10-24 14:58:54 +00:00
foreach ( _v PACKAGE PACKAGE_VERSION
2020-04-19 07:45:32 +00:00
P R O G R A M _ S U F F I X L Y X _ V E R S I O N L Y X _ D I R _ V E R L Y X _ U S E R D I R _ V E R
2011-05-10 17:21:15 +00:00
L Y X _ A B S _ T O P _ S R C D I R
L Y X _ A B S _ I N S T A L L E D _ D A T A D I R L Y X _ A B S _ I N S T A L L E D _ L O C A L E D I R L Y X _ I N S T A L L _ S U F F I X )
if ( NOT DEFINED ${ _v } )
message ( FATAL_ERROR "${_v} not defined" )
endif ( )
string ( SUBSTRING "${_v} " 0 28 _v1 )
message ( STATUS "----- ${_v1}: ${${_v}}" )
endforeach ( _v )
message ( STATUS "" )
if ( LYX_PCH )
# PCHs not supported by cmake: http://www.cmake.org/Bug/view.php?id=1260
# Not sure if it works for all non-msvc compilers
include ( PCHSupport_26 )
2012-11-02 12:33:22 +00:00
configure_file ( ${ TOP_CMAKE_PATH } /pcheaders.h ${ TOP_BINARY_DIR } /pcheaders.h )
configure_file ( ${ TOP_CMAKE_PATH } /config.cpp.cmake ${ TOP_BINARY_DIR } /config_pch.cpp )
2011-05-10 17:21:15 +00:00
add_definitions ( -DLYX_ENABLE_PCH )
if ( MSVC )
macro ( lyx_add_msvc_pch name_ )
set_source_files_properties ( ${ ${name_ } _sources} PROPERTIES
C O M P I L E _ F L A G S " / Y u c o n f i g . h / F p \ $ ( I n t D i r ) / c o n f i g . p c h " )
set_source_files_properties ( ${ TOP_BINARY_DIR } /config_pch.cpp PROPERTIES
C O M P I L E _ F L A G S " / Y c c o n f i g . h / F p \ $ ( I n t D i r ) / c o n f i g . p c h " )
set ( ${ name_ } _sources ${ ${name_ } _sources} ${ TOP_BINARY_DIR } /config_pch.cpp
$ { T O P _ B I N A R Y _ D I R } / p c h e a d e r s . h )
2020-11-30 09:17:40 +00:00
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /DLYX_PCH_STL /DLYX_PCH_BOOST" )
2011-05-10 17:21:15 +00:00
endmacro ( lyx_add_msvc_pch )
macro ( lyx_add_gcc_pch name_ )
endmacro ( )
else ( )
macro ( lyx_add_msvc_pch name_ )
endmacro ( )
macro ( lyx_add_gcc_pch name_ )
2020-11-30 09:17:40 +00:00
add_definitions ( -DLYX_PCH_STL -DLYX_PCH_BOOST -DLYX_PCH_QT )
2011-05-10 17:21:15 +00:00
ADD_PRECOMPILED_HEADER ( ${ name_ } ${ TOP_BINARY_DIR } /config_pch.cpp ${ TOP_BINARY_DIR } /config.h.gch )
endmacro ( )
endif ( )
else ( )
macro ( lyx_add_msvc_pch )
endmacro ( lyx_add_msvc_pch )
macro ( lyx_add_gcc_pch name_ )
endmacro ( )
endif ( )
2011-05-22 11:38:10 +00:00
2011-05-10 17:21:15 +00:00
if ( MSVC )
2011-05-22 11:38:10 +00:00
2011-05-10 17:21:15 +00:00
if ( LYX_VLD )
2011-05-22 11:38:10 +00:00
set ( vld_path ${ CMAKE_CURRENT_SOURCE_DIR } /development/Win32/vld )
add_subdirectory ( ${ vld_path } /cmake )
include ( ${ vld_path } /cmake/vld.cmake ) # forced include
set ( vld_dll vld )
2011-05-10 17:21:15 +00:00
endif ( )
if ( LYX_WALL )
# Use the highest warning level
2019-02-05 11:27:15 +00:00
set ( CMAKE_CXX_WARNING_LEVEL 4 CACHE STRING "Warning level" FORCE )
2011-05-10 17:21:15 +00:00
if ( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
string ( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
endif ( )
if ( CMAKE_C_FLAGS MATCHES "/W[0-4]" )
string ( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" )
else ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4" )
endif ( )
# add here warnings which should produce an error /weXXXX
set ( MSVC_W_ERROR "/we4101 /we4189" )
# add here warnings which should be disabled /wdXXXX
set ( MSVC_W_DISABLE "/wd4288 /wd4355 /wd4800 /wd4996 /wd4311 /wd4312 /wd4505 /wd4267 /wd4512 /wd4245 /wd4127 /wd4180 /wd4231" )
2020-09-02 13:05:20 +00:00
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /W4 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
2011-05-10 17:21:15 +00:00
else ( )
2019-02-05 11:27:15 +00:00
set ( CMAKE_CXX_WARNING_LEVEL 3 CACHE STRING "Warning level" FORCE )
2011-05-10 17:21:15 +00:00
# add here warnings which should produce an error /weXXXX
set ( MSVC_W_ERROR "/we4101 /we4189" )
# add here warnings which should be disabled /wdXXXX
set ( MSVC_W_DISABLE "/wd4288 /wd4355 /wd4800 /wd4996 /wd4267 /wd4180 /wd4231" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
endif ( )
2013-05-12 10:26:44 +00:00
2021-05-24 18:32:26 +00:00
if ( NOT ( Qt5Core_FOUND OR Qt6Core_FOUND ) )
2013-05-12 10:26:44 +00:00
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zc:wchar_t-" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zc:wchar_t-" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Zc:wchar_t-" )
endif ( )
2011-05-10 17:21:15 +00:00
2020-12-31 02:46:53 +00:00
if ( MSVC_VERSION GREATER_EQUAL 1914 )
# Ensure the __cplusplus macro is set to a sensible value.
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zc:__cplusplus" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zc:__cplusplus" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Zc:__cplusplus" )
endif ( )
2011-05-10 17:21:15 +00:00
message ( STATUS "----- Warning level : ${CMAKE_CXX_WARNING_LEVEL} ${WARNING_LEVEL_MESSAGE}" )
message ( STATUS "----- Warnings as errors : ${MSVC_W_ERROR}" )
message ( STATUS "----- Warnings disabled : ${MSVC_W_DISABLE}" )
message ( STATUS "" )
endif ( )
2011-12-06 11:36:50 +00:00
# Xcode compiler
if ( CMAKE_GENERATOR MATCHES Xcode )
2013-12-31 14:49:19 +00:00
if ( XCODE_VERSION VERSION_LESS "5.0" )
2013-12-31 09:24:27 +00:00
# Automatically select the Xcode compiler if not set
if ( NOT DEFINED CMAKE_XCODE_ATTRIBUTE_GCC_VERSION )
# XCode >= 3.1 has gcc 4.2 (up to actual Xcode)
if ( XCODE_VERSION VERSION_GREATER "3.1" )
SET ( CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42" )
ENDIF ( XCODE_VERSION VERSION_GREATER "3.1" )
ENDIF ( NOT DEFINED CMAKE_XCODE_ATTRIBUTE_GCC_VERSION )
# Print the selected compiler version
MESSAGE ( STATUS "---- Using XCode compiler CMAKE_XCODE_ATTRIBUTE_GCC_VERSION=${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION}" )
2013-12-31 14:49:19 +00:00
ENDIF ( XCODE_VERSION VERSION_LESS "5.0" )
2011-12-06 11:36:50 +00:00
ENDIF ( CMAKE_GENERATOR MATCHES Xcode )
2013-05-14 15:13:59 +00:00
if ( WIN32 AND Qt5Core_FOUND )
set ( Z_PREFIX 1 )
endif ( )
2011-12-06 11:36:50 +00:00
2016-06-15 09:29:09 +00:00
# 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 )
2011-05-10 17:21:15 +00:00
2020-04-07 09:48:45 +00:00
unset ( opts )
2020-03-25 12:48:16 +00:00
foreach ( _option ${ LYX_OPTIONS } )
if ( ${ _option } _show_message )
string ( SUBSTRING "${_option} " 0 31 _var )
get_property ( _prop CACHE ${ _option } PROPERTY STRINGS )
list ( FIND LYX_OPTION_STRINGS ${ _option } _index )
if ( ${ _index } GREATER -1 )
set ( _isset ${ ${_option } } )
elseif ( ${ _option } )
set ( _isset ON )
else ( )
set ( _isset OFF )
endif ( )
string ( SUBSTRING "${_isset} " 0 10 _val )
set ( opts "${opts} ${_option}(${${_option}})" )
endif ( )
endforeach ( )
2020-03-26 14:48:01 +00:00
set ( tmp_vi "CMake Build" )
list ( APPEND tmp_vi " Host name: ${CMAKE_HOST_SYSTEM_NAME}" )
list ( APPEND tmp_vi " Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}" )
list ( APPEND tmp_vi " Build flags: ${opts}" )
list ( APPEND tmp_vi " C++ Compiler: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION})" )
list ( APPEND tmp_vi " C++ Compiler flags: ${CMAKE_CXX_FLAGS}" )
2020-03-25 12:48:16 +00:00
if ( LYX_DEBUG )
2020-03-26 14:48:01 +00:00
list ( APPEND tmp_vi " C++ Compiler user flags: ${CMAKE_CXX_FLAGS_DEBUG}" )
2020-03-25 12:48:16 +00:00
else ( )
2020-03-26 14:48:01 +00:00
list ( APPEND tmp_vi " C++ Compiler user flags: ${CMAKE_CXX_FLAGS_RELEASE}" )
2020-03-25 12:48:16 +00:00
endif ( )
2020-03-26 14:48:01 +00:00
list ( APPEND tmp_vi " Qt version: ${QTVERSION}" )
list ( APPEND tmp_vi " LyX binary dir: ${CMAKE_INSTALL_PREFIX}/${LYX_UTILITIES_INSTALL_PATH}" )
2020-03-25 16:50:58 +00:00
get_data_destination ( dest_data )
2020-03-26 14:48:01 +00:00
list ( APPEND tmp_vi " LyX files dir: ${CMAKE_INSTALL_PREFIX}/${dest_data}" )
string ( REPLACE ";" "\\n" VERSION_INFO "${tmp_vi}" )
2020-03-25 12:48:16 +00:00
2011-05-10 17:21:45 +00:00
configure_file ( ${ LYX_CMAKE_DIR } /config.h.cmake ${ TOP_BINARY_DIR } /config.h )
2020-04-07 09:48:45 +00:00
unset ( opts )
unset ( tmp_vi )
2011-05-10 17:21:15 +00:00
2011-06-08 20:22:27 +00:00
if ( QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" )
2022-11-19 13:45:03 +00:00
MATH ( EXPR QTx_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}" )
2011-06-08 20:22:27 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
2012-12-14 18:48:16 +00:00
set ( cmd ${ CMAKE_CTEST_COMMAND } )
if ( MSVC )
set ( cmd ${ cmd } -C ${ CMAKE_CFG_INTDIR } )
else ( )
set ( cmd ${ cmd } -C ${ CMAKE_BUILD_TYPE } )
endif ( )
add_custom_target ( lyx_run_tests COMMAND ${ cmd } )
set_target_properties ( lyx_run_tests PROPERTIES FOLDER "tests" )
2011-05-10 17:21:15 +00:00
if ( LYX_INSTALL )
2011-05-20 06:40:04 +00:00
if ( ${ LYX_PYTHON_EXECUTABLE } MATCHES "-NOTFOUND" )
message ( STATUS "Python required to create doc!" )
2011-05-19 07:44:04 +00:00
else ( )
2014-06-07 05:59:52 +00:00
if ( UNIX )
add_subdirectory ( ${ LYX_CMAKE_DIR } /man "${TOP_BINARY_DIR}/man" )
endif ( )
2011-05-19 07:44:04 +00:00
add_subdirectory ( ${ LYX_CMAKE_DIR } /doc "${TOP_BINARY_DIR}/doc" )
2011-05-10 17:21:15 +00:00
endif ( )
2014-03-09 09:24:07 +00:00
endif ( )
2017-09-25 08:29:40 +00:00
include ( ../Install )
2011-05-10 17:21:15 +00:00
2017-12-24 01:41:16 +00:00
# By running the URL tests first, time can be saved when running the ctests in
# parallel since the URL tests take a long time to run (e.g. 10 minutes).
2020-11-13 23:34:20 +00:00
# Needed, because of perl scripts in checkurls autotests and batchtests
find_package ( Perl REQUIRED )
2017-12-24 01:41:16 +00:00
if ( LYX_ENABLE_URLTESTS )
add_subdirectory ( development/checkurls "${TOP_BINARY_DIR}/checkurls" )
endif ( )
2014-03-09 09:21:51 +00:00
add_subdirectory ( src "${TOP_BINARY_DIR}/src" )
add_subdirectory ( lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx" )
add_subdirectory ( lib/scripts "${TOP_BINARY_DIR}/scripts" )
add_subdirectory ( lib/examples "${TOP_BINARY_DIR}/lib/examples" )
2011-05-16 10:51:33 +00:00
add_subdirectory ( sourcedoc "${TOP_BINARY_DIR}/sourcedoc" )
2012-12-14 15:25:57 +00:00
add_subdirectory ( development/autotests "${TOP_BINARY_DIR}/autotests" )
2018-01-14 12:47:27 +00:00
add_subdirectory ( development/batchtests "${TOP_BINARY_DIR}/batchtests" )
2011-05-10 17:21:15 +00:00
message ( STATUS )
2014-06-07 19:00:46 +00:00
message ( STATUS "Build params, switch LYX_* options by -DLYX_*=ON or OFF, LYX_* combos by -DLYX_*=value:" )
2011-05-10 17:21:15 +00:00
message ( STATUS )
2014-06-07 08:45:13 +00:00
2011-05-10 20:25:31 +00:00
LYX_OPTION_LIST_ALL ( used )
2011-05-10 17:21:15 +00:00
2011-05-14 09:22:35 +00:00
if ( LYX_NLS )
message ( STATUS )
message ( STATUS "Building Native Language Support (LYX_NLS is set), used libraries:" )
message ( STATUS )
message ( STATUS " * iconv" )
2015-12-09 12:54:08 +00:00
message ( STATUS " - include: ${ICONV_INCLUDE_DIR}" )
2011-05-14 09:22:35 +00:00
message ( STATUS " - library: ${ICONV_LIBRARY}" )
message ( STATUS " * zlib" )
2015-12-09 12:54:08 +00:00
message ( STATUS " - include: ${ZLIB_INCLUDE_DIR}" )
2011-05-14 09:22:35 +00:00
message ( STATUS " - library: ${ZLIB_LIBRARY}" )
message ( STATUS )
endif ( )
2014-06-12 21:34:04 +00:00
# Apple has builtin native spell checker,
# no need to warn for missing Aspell, Hunspell or Enchant
2014-06-12 12:55:56 +00:00
if ( NOT Spelling_FOUND AND NOT APPLE )
2014-05-13 10:31:37 +00:00
if ( LYX_REQUIRE_SPELLCHECK )
set ( _mode "FATAL_ERROR" )
else ( )
set ( _mode "STATUS" )
endif ( )
2014-06-12 21:34:04 +00:00
message ( ${ _mode } "No spellcheck libraries found. LyX will be unable use spellchecking" )
2014-05-13 10:31:37 +00:00
endif ( )
2012-11-02 12:33:22 +00:00
include ( "${TOP_CMAKE_PATH}/LyxPackaging.cmake" )
2011-05-15 13:21:18 +00:00
2012-12-18 09:49:21 +00:00
if ( ENABLE_DIST )
# Use git to create the source package
# git archive --format=tgz --output=/home/kornel/x.tar.gz master
if ( UNIX )
set ( DIST_FORMAT tgz )
else ( )
set ( DIST_FORMAT zip )
endif ( )
set ( DIST_NAME ${ CMAKE_PROJECT_NAME } - ${ CPACK_PACKAGE_VERSION_MAJOR } . ${ CPACK_PACKAGE_VERSION_MINOR } . ${ CPACK_PACKAGE_VERSION_PATCH } - ${ CMAKE_SYSTEM_NAME } . ${ DIST_FORMAT } )
add_custom_command (
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { D I S T _ N A M E }
C O M M A N D $ { L Y X _ G I T V E R S I O N } a r c h i v e - - f o r m a t = $ { D I S T _ F O R M A T } - - o u t p u t = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { D I S T _ N A M E } m a s t e r
W O R K I N G _ D I R E C T O R Y $ { T O P _ S R C _ D I R } )
add_custom_target ( git-archive DEPENDS ${ CMAKE_CURRENT_BINARY_DIR } / ${ DIST_NAME } )
endif ( )
2014-03-09 09:21:51 +00:00
# Last directory to be included so that the fixup code (OS X)
# can be run last
add_subdirectory ( development/cmake/post_install )
2020-11-26 23:49:03 +00:00
string ( TIMESTAMP current_date "%Y-%m-%d %H:%M" )
execute_process ( COMMAND ${ LYX_GITVERSION } describe --tags
W O R K I N G _ D I R E C T O R Y " $ { T O P _ S R C _ D I R } "
O U T P U T _ V A R I A B L E c u r r e n t _ v e r s i o n
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
file ( APPEND "${TOP_BINARY_DIR}/Testing/IgnoredCount" "${current_date} ${current_version} Ignored tests = ${LYX_ignored_count}\n" )
2011-05-10 17:21:15 +00:00
message ( STATUS )