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>
# Copyright (c) 2008-2011 Kornel Benko, <Kornel.Benko@berlin.de>
cmake_minimum_required ( VERSION 2.6.4 )
2012-09-21 13:09:46 +00:00
set ( LYX_PROJECT LyX )
2011-05-10 17:21:45 +00:00
2012-10-21 10:05:50 +00:00
enable_testing ( )
2011-05-10 17:21:45 +00:00
get_filename_component ( lyx_dir_readme ${ CMAKE_SOURCE_DIR } /README ABSOLUTE )
get_filename_component ( TOP_SRC_DIR ${ lyx_dir_readme } PATH )
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 )
cmake_policy ( SET CMP0003 OLD )
cmake_policy ( SET CMP0005 OLD )
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 CMP0028 )
cmake_policy ( SET CMP0028 OLD )
endif ( )
if ( POLICY CMP0043 )
# COMPILE_DEFINITIONS are not used yet. Enable new behavior.
cmake_policy ( SET CMP0043 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 )
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0" )
message ( STATUS "Gnu CXX compiler version = ${CMAKE_CXX_COMPILER_VERSION}" )
message ( STATUS "is too old, should be >= 4.0" )
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 )
# 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, ...
2014-06-07 08:45:13 +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
2011-05-10 17:21:15 +00:00
LYX_OPTION_INIT ( )
# 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 )
LYX_OPTION ( DEVEL_VERSION "Build developer version" OFF ALL )
LYX_OPTION ( RELEASE "Build release version, build debug when disabled" OFF ALL )
2011-05-15 13:21:18 +00:00
LYX_OPTION ( DEBUG "Enforce debug build" OFF ALL )
LYX_OPTION ( NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( PACKAGE_SUFFIX "Use version suffix for packaging" ON ALL )
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 )
2014-08-10 08:35:56 +00:00
LYX_OPTION ( ASAN "Use address sanitizer" OFF ALL )
2011-05-10 17:21:15 +00:00
# GCC specific
2011-05-10 18:34:39 +00:00
LYX_OPTION ( PROFILE "Build profile version" OFF GCC )
LYX_OPTION ( EXTERNAL_BOOST "Use external boost" OFF GCC )
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 )
2011-05-10 18:34:39 +00:00
LYX_OPTION ( STDLIB_DEBUG "Use debug stdlib" OFF GCC )
2011-08-19 18:04:41 +00:00
LYX_OPTION ( PROFILE "Build with options for gprof" OFF GCC )
2012-10-24 09:36:54 +00:00
LYX_OPTION ( ENABLE_CXX11 "Build with options for c++11-mode" OFF GCC )
2011-05-10 17:21:15 +00:00
# MSVC specific
2011-12-05 20:09:50 +00:00
LYX_OPTION ( CONSOLE "Show console on Windows, enforce with =FORCE" 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 )
LYX_OPTION ( CONFIGURE_CHECKS "Also run configure checks for MSVC" 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 )
2014-06-09 08:08:32 +00:00
if ( LYX_XMINGW )
LYX_COMBO ( USE_QT "Use Qt version as frontend for MINGW" QT4 )
else ( )
LYX_COMBO ( USE_QT "Use Qt version as frontend" QT4 QT5 )
endif ( )
2011-05-10 20:25:31 +00:00
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 )
2011-05-28 08:30:44 +00:00
RETURN ( )
endif ( )
2011-05-10 20:25:31 +00:00
2011-05-10 17:21:15 +00:00
# Check option dependencies
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 ( )
2011-12-05 20:09:50 +00:00
if ( LYX_CONSOLE MATCHES "FORCE" )
set ( LYX_CONSOLE ON )
else ( )
set ( LYX_CONSOLE OFF )
endif ( )
2011-05-10 17:21:15 +00:00
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 ( )
2014-06-07 05:59:52 +00:00
2011-05-10 17:21:15 +00:00
if ( LYX_DEPENDENCIES_DOWNLOAD )
message ( STATUS )
set ( LYX_DEPENDENCIES_DIR ${ TOP_BINARY_DIR } /msvc2010-deps )
message ( STATUS "Using downloaded dependencies in ${LYX_DEPENDENCIES_DIR}" )
2011-12-05 19:37:44 +00:00
set ( deps_files lyx20-deps-msvc2010-x86.zip )
2011-11-10 19:00:41 +00:00
set ( deps_server http://downloads.sourceforge.net/project/lyx/Win_installers/Dependencies )
2011-05-10 17:21:15 +00:00
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} ..." )
2011-11-10 19:00:41 +00:00
file ( DOWNLOAD ${ deps_server } / ${ it } ${ LYX_DEPENDENCIES_DIR } /download/ ${ it } SHOW_PROGRESS STATUS status LOG log )
2011-08-09 22:09:35 +00:00
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 ( )
2011-05-10 17:21:15 +00:00
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 ( )
set ( GNUWIN32_DIR ${ LYX_DEPENDENCIES_DIR } /deps20 )
2014-06-07 06:17:20 +00:00
if ( MSVC12 )
# handle error in msvc12 when linking against msvc10 libs
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vd2" )
endif ( )
2011-05-10 17:21:15 +00:00
endif ( )
2011-05-15 13:21:18 +00:00
2011-05-10 17:21:15 +00:00
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
2014-04-22 07:36:17 +00:00
set ( LYX_GCC11_MODE )
2011-05-10 17:21:15 +00:00
if ( UNIX OR MINGW )
execute_process ( COMMAND ${ CMAKE_CXX_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
message ( STATUS "Using GCC version ${GCC_VERSION}" )
2014-12-28 17:08:18 +00:00
if ( GCC_VERSION VERSION_LESS 4.9 )
2014-12-23 21:18:08 +00:00
# <regex> in gcc is unusable in versions less than 4.9.0
2014-12-21 19:19:12 +00:00
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
2014-12-23 21:18:08 +00:00
set ( LYX_USE_STD_REGEX 0 )
2014-12-28 17:08:18 +00:00
endif ( )
2012-10-24 09:36:54 +00:00
if ( LYX_ENABLE_CXX11 )
2013-12-15 10:41:28 +00:00
find_package ( CXX11Compiler )
if ( NOT CXX11COMPILER_FOUND )
message ( FATAL_ERROR "A C++11 compatible compiler is required." )
2012-10-24 09:36:54 +00:00
endif ( )
2014-04-22 07:36:17 +00:00
set ( LYX_GCC11_MODE "${CXX11_FLAG}" )
2012-10-24 09:36:54 +00:00
endif ( )
2011-05-10 17:21:15 +00:00
else ( )
2014-12-23 21:18:08 +00:00
set ( LYX_USE_STD_REGEX 0 )
# if(MSVC10)
# set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode?
# endif()
2011-05-10 17:21:15 +00:00
endif ( )
set ( VERSION_INFO "CMake Build" )
# Try to get some informations from configure.ac
2011-05-10 20:25:31 +00:00
include ( LyXPaths )
2011-05-10 17:21:15 +00:00
file ( STRINGS "${TOP_SRC_DIR}/configure.ac" _config_lines )
if ( WIN32 )
2011-05-28 08:30:44 +00:00
set ( USE_WINDOWS_PACKAGING ON )
2011-05-10 17:21:15 +00:00
elseif ( APPLE )
2011-05-28 08:30:44 +00:00
set ( USE_MACOSX_PACKAGING ON )
2011-05-10 17:21:15 +00:00
else ( )
2011-05-28 08:30:44 +00:00
set ( USE_POSIX_PACKAGING ON )
2011-05-10 17:21:15 +00:00
endif ( )
2013-01-26 10:29:48 +00:00
macro ( setstripped _varname )
if ( ${ ARGC } GREATER 1 )
string ( STRIP "${ARGV1}" _v )
if ( USE_POSIX_PACKAGING )
string ( TOLOWER ${ _v } ${ _varname } )
else ( )
set ( ${ _varname } ${ _v } )
endif ( )
2011-05-10 17:21:15 +00:00
else ( )
2013-01-26 10:29:48 +00:00
set ( ${ _varname } )
2011-05-10 17:21:15 +00:00
endif ( )
endmacro ( setstripped )
foreach ( _c_l ${ _config_lines } )
if ( _c_l MATCHES "^AC_INIT\\(\([^,]+\),\([^,]+\), *\\[\([^,]+\)\\] *,\(.*\)" )
setstripped ( PACKAGE_BASE ${ CMAKE_MATCH_1 } )
setstripped ( PACKAGE_VERSION ${ CMAKE_MATCH_2 } )
setstripped ( PACKAGE_BUGREPORT ${ CMAKE_MATCH_3 } )
2011-05-21 13:48:45 +00:00
if ( PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\)\(\\.\([0-9]+\)\)?.*$" )
2011-05-10 17:21:15 +00:00
set ( LYX_MAJOR_VERSION ${ CMAKE_MATCH_1 } )
set ( LYX_MINOR_VERSION ${ CMAKE_MATCH_2 } )
2011-05-22 08:38:31 +00:00
set ( LYX_PATCH_VERSION ${ CMAKE_MATCH_4 } )
2011-05-10 17:21:15 +00:00
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}" )
endif ( )
endif ( )
if ( _c_l MATCHES "^AC_SUBST\\( *LYX_DATE *, *\\[\\\" ( .* ) \\\"\\].*")
set ( LYX_DATE "${CMAKE_MATCH_1}" )
endif ( )
endforeach ( _c_l )
2014-10-11 09:18:48 +00:00
FIND_PROGRAM ( LYX_GITVERSION git )
#message(STATUS "gitversion = ${LYX_GITVERSION}")
set ( LYX_REVISION_VERSION ${ LYX_PATCH_VERSION } )
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
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 L Y X _ P A C K A G E _ R E L E A S E 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 ( LYX_PACKAGE_RELEASE MATCHES "^2\\.0\\.0\\-\([0-9]+\)\\-.*$" )
# 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_PATCH_VERSION}-${tmp_REVISION_VERSION}git" )
set ( ENABLE_DIST ON )
endif ( )
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 } )
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
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/development/MacOSX/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/development/MacOSX/lyxrc.dist.in" "${CMAKE_CURRENT_BINARY_DIR}/lyxrc.dist" )
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 )
endif ( )
set ( LYX_INSTALL_PREFIX ${ LYX_INSTALL_PREFIX } CACHE PATH "LyX user's choice install prefix" FORCE )
2014-05-09 08:04:42 +00:00
string ( REGEX REPLACE "/lyx${LYX_INSTALL_SUFFIX}$" "/share" SYSTEM_DATADIR ${ CMAKE_INSTALL_PREFIX } )
2011-05-10 17:21:15 +00:00
if ( LYX_PACKAGE_SUFFIX )
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 ( )
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"
# 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 )
endif ( )
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
2011-05-15 13:21:18 +00:00
if ( NOT LYX_DATA_SUBDIR )
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 )
endif ( )
2011-05-10 17:21:15 +00:00
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}" )
set ( LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}" )
2014-03-09 09:21:51 +00:00
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." )
endif ( )
2013-09-06 12:56:31 +00:00
mark_as_advanced ( LYX_MAN_DIR )
2011-05-10 17:21:15 +00:00
2011-05-22 08:18:54 +00:00
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 )
2011-05-10 17:21:15 +00:00
set ( CMAKE_BUILD_TYPE Profile CACHE TYPE STRING 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 ( )
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 ( )
if ( NOT MSVC )
if ( NOT LYX_QUIET )
set ( CMAKE_VERBOSE_MAKEFILE ON )
endif ( )
2014-08-10 08:35:56 +00:00
set ( LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}" )
2011-05-10 17:21:15 +00:00
if ( LYX_STDLIB_DEBUG )
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 )
2013-01-26 10:29:48 +00:00
set ( CMAKE_CXX_FLAGS_DEBUG "${LYX_CXX_FLAGS} -fno-strict-aliasing -O0 -g3 -D_DEBUG" CACHE TYPE STRING FORCE )
2011-05-10 17:21:15 +00:00
if ( MINGW )
set ( CMAKE_CXX_FLAGS_RELEASE "${LYX_CXX_FLAGS} -O2 -DNDEBUG" CACHE TYPE STRING FORCE )
else ( )
set ( CMAKE_CXX_FLAGS_RELEASE "${LYX_CXX_FLAGS} -O3 -DNDEBUG" CACHE TYPE STRING FORCE )
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 )
set ( QT_MINGW_DIR ${ LYX_QT4 } CACHE PATH "Qt for Mingw" FORCE )
list ( APPEND CMAKE_FIND_ROOT_PATH ${ QT_MINGW_DIR } ${ GNUWIN32_DIR } )
endif ( )
2014-06-09 08:08:32 +00:00
if ( LYX_USE_QT MATCHES "QT5" )
2014-08-21 16:22:43 +00:00
find_package ( Qt5Core REQUIRED )
if ( Qt5Core_FOUND )
find_package ( Qt5Widgets REQUIRED )
if ( APPLE )
2014-08-24 19:59:12 +00:00
find_package ( Qt5MacExtras REQUIRED )
2014-08-21 16:22:43 +00:00
endif ( )
2014-08-23 09:36:24 +00:00
find_package ( Qt5X11Extras QUIET )
2014-12-26 15:53:31 +00:00
find_package ( Qt5WinExtras QUIET )
2014-08-21 16:22:43 +00:00
set ( QTVERSION ${ Qt5Core_VERSION } )
macro ( qt_use_modules )
qt5_use_modules ( ${ ARGN } )
endmacro ( )
macro ( qt_add_resources )
qt5_add_resources ( ${ ARGN } )
endmacro ( )
macro ( qt_wrap_uifiles )
qt5_wrap_ui ( ${ ARGN } )
endmacro ( )
2014-08-24 19:59:12 +00:00
message ( STATUS "Found Qt-Version ${QTVERSION}" )
2014-08-21 16:22:43 +00:00
endif ( )
2014-06-09 08:08:32 +00:00
elseif ( LYX_USE_QT MATCHES "QT4" )
2013-04-21 19:42:53 +00:00
find_package ( Qt4 "4.5.0" REQUIRED )
macro ( qt_use_modules )
endmacro ( )
macro ( qt_add_resources )
qt4_add_resources ( ${ ARGN } )
endmacro ( )
macro ( qt_wrap_uifiles )
qt4_wrap_ui ( ${ ARGN } )
endmacro ( )
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 )
set ( HAVE_MAGIC_H 1 )
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
2014-05-13 10:31:37 +00:00
foreach ( _spell "ASPELL" "Enchant" "Hunspell" )
string ( TOUPPER ${ _spell } _upspell )
find_package ( ${ _spell } )
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 ( )
if ( LYX_ ${ _upspell } )
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
2015-03-10 16:29:58 +00:00
find_package ( PythonInterp 2.7 QUIET )
if ( PYTHONINTERP_FOUND )
if ( PYTHON_VERSION_STRING VERSION_GREATER 2.8 )
unset ( PYTHONINTERP_FOUND )
endif ( )
endif ( )
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 )
endif ( )
set ( LYX_PYTHON_EXECUTABLE ${ PYTHON_EXECUTABLE } CACHE FILEPATH "Python to be used by LyX" )
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 } )
install ( FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION ${ LYX_DATA_SUBDIR } ${ LYX_LOCALEDIR } / ${ _lang } /LC_MESSAGES RENAME ${ PACKAGE } .mo )
endforeach ( )
2011-05-10 17:21:15 +00:00
endif ( )
endif ( )
2014-06-07 05:59:52 +00:00
2011-05-12 21:48:11 +00:00
find_package ( ICONV REQUIRED )
2011-05-14 09:22:35 +00:00
find_package ( ZLIB REQUIRED )
2011-05-12 21:48:11 +00:00
2011-05-10 17:21:15 +00:00
if ( LYX_EXTERNAL_BOOST )
message ( STATUS "Searching for boost" )
2015-01-07 08:01:25 +00:00
if ( LYX_USE_STD_REGEX )
find_package ( Boost COMPONENTS signals )
else ( )
find_package ( Boost COMPONENTS signals regex )
endif ( )
2011-05-10 17:21:15 +00:00
if ( Boost_FOUND )
message ( STATUS "Boost found" )
message ( STATUS "Boost-libs = ${Boost_LIBRARIES}" )
set ( Lyx_Boost_Libraries ${ Boost_LIBRARIES } )
2015-09-22 13:27:35 +00:00
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 ( )
2011-05-10 17:21:15 +00:00
else ( )
message ( FATAL_ERROR "Boost not found" ${ Boost_ERROR_REASON } )
endif ( )
else ( )
2014-12-23 21:18:08 +00:00
if ( LYX_USE_STD_REGEX )
2011-05-10 17:21:15 +00:00
set ( Lyx_Boost_Libraries boost_signals )
else ( )
set ( Lyx_Boost_Libraries boost_signals boost_regex )
endif ( )
add_definitions ( -DBOOST_USER_CONFIG= "<config.h>" )
2014-04-29 16:01:50 +00:00
add_definitions ( -DBOOST_SIGNALS_NO_DEPRECATION_WARNING=1 )
2011-05-10 17:21:15 +00:00
include_directories ( ${ TOP_SRC_DIR } /boost )
2011-05-10 18:04:49 +00:00
add_subdirectory ( boost "${TOP_BINARY_DIR}/boost" )
2011-05-10 17:21:15 +00:00
endif ( )
if ( WIN32 )
if ( NOT LYX_CONSOLE )
set ( WIN32_CONSOLE WIN32 )
set ( LYX_QTMAIN_LIBRARY ${ QT_QTMAIN_LIBRARY } )
endif ( )
if ( MSVC )
add_definitions ( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX )
# 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 ( )
add_definitions ( -DWINVER=0x0500 )
endif ( )
endif ( )
2012-11-01 12:00:19 +00:00
# Compute qt4-version from ${QTVERSION}
2011-05-10 17:21:15 +00:00
message ( STATUS "" )
2014-10-24 14:58:54 +00:00
foreach ( _v PACKAGE PACKAGE_VERSION
2011-05-10 17:21:15 +00:00
P R O G R A M _ S U F F I X L Y X _ D A T E L Y X _ D I R _ V E R L Y X _ U S E R D I R _ V E R
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 )
2014-07-21 06:49:05 +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" )
2011-05-22 09:33:53 +00:00
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_ )
2014-07-21 06:49:05 +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
set ( CMAKE_CXX_WARNING_LEVEL 4 CACHE TYPE STRING FORCE )
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" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
set ( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Wp64 ${MSVC_W_ERROR} ${MSVC_W_DISABLE}" )
else ( )
set ( CMAKE_CXX_WARNING_LEVEL 3 CACHE TYPE STRING FORCE )
# 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
if ( NOT Qt5Core_FOUND )
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
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 ( )
if ( LYX_DEBUG_GLIBC )
2011-05-28 08:30:44 +00:00
set ( _GLIBCXX_DEBUG ON )
2011-05-10 17:21:15 +00:00
endif ( )
if ( LYX_DEBUG_GLIBC_PEDANTIC )
2011-05-28 08:30:44 +00:00
set ( _GLIBCXX_DEBUG_PEDANTIC ON )
2011-05-10 17:21:15 +00:00
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
2011-05-10 17:21:15 +00:00
# compiler tests, config.h generation
if ( MSVC AND NOT LYX_CONFIGURE_CHECKS )
2011-05-10 17:21:45 +00:00
configure_file ( ${ LYX_CMAKE_DIR } /configCompiler.h.msvc ${ TOP_BINARY_DIR } /configCompiler.h )
2011-05-10 17:21:15 +00:00
else ( )
2011-05-10 17:21:45 +00:00
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
endif ( )
2011-05-10 17:21:45 +00:00
configure_file ( ${ LYX_CMAKE_DIR } /config.h.cmake ${ TOP_BINARY_DIR } /config.h )
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]+).*" )
2011-06-08 23:00:28 +00:00
MATH ( EXPR QT4_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" )
2014-08-10 08:35:56 +00:00
if ( LYX_ASAN )
set ( LYX_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g" )
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/lyx2.2 2>&1 | ./asan_symbolize.py | c++filt " )
message ( STATUS )
endif ( )
2012-12-14 18:48:16 +00:00
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
include ( ../Install )
endif ( )
2011-05-10 17:21:15 +00:00
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" )
2013-09-06 13:03:47 +00:00
if ( LYX_ENABLE_URLTESTS )
add_subdirectory ( development/checkurls "${TOP_BINARY_DIR}/checkurls" )
endif ( )
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" )
message ( STATUS " - header : ${ICONV_HEADER}" )
message ( STATUS " - library: ${ICONV_LIBRARY}" )
message ( STATUS " * zlib" )
message ( STATUS " - header : ${ZLIB_HEADER}" )
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 )
2011-05-10 17:21:15 +00:00
message ( STATUS )