cmake_minimum_required(VERSION 2.6.4)
-set(LYX_PROJECT lyx)
+set(LYX_PROJECT LyX)
-set(LYX_CMAKE_DIR "development/cmake")
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/${LYX_CMAKE_DIR}/modules")
+enable_testing()
get_filename_component(lyx_dir_readme ${CMAKE_SOURCE_DIR}/README ABSOLUTE)
get_filename_component(TOP_SRC_DIR ${lyx_dir_readme} PATH)
+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}")
+
set(CMAKE_PROJECT_NAME ${LYX_PROJECT})
message(STATUS)
# Supress regeneration
set(CMAKE_SUPPRESS_REGENERATION FALSE)
+if(NOT help AND NOT HELP)
+ # 'project' triggers the searching for a compiler
+ project(${LYX_PROJECT})
+endif()
+
+if(UNIX)
+ set(ARCH_TRIPLET )
+ FIND_PROGRAM(DPKG_ARCHITECTURE_EXECUTABLE dpkg-architecture)
+ if(DPKG_ARCHITECTURE_EXECUTABLE)
+ EXECUTE_PROCESS(COMMAND ${DPKG_ARCHITECTURE_EXECUTABLE} -qDEB_HOST_MULTIARCH
+ OUTPUT_VARIABLE ARCH_TRIPLET
+ ERROR_VARIABLE ERROR_ARCH_TRIPLET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 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()
include(LyXMacros)
# Options for all compilers/systems
LYX_OPTION(CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL)
+LYX_OPTION(LOCALVERSIONING "Add version info to created package name (only used if LYX_CPACK option set)" OFF ALL)
LYX_OPTION(INSTALL "Build install projects/rules (implies a bunch of other options)" OFF ALL)
-LYX_OPTION(NLS "Use nls" ON ALL)
+LYX_OPTION(NLS "Enable Native Language Support (NLS)" ON ALL)
LYX_OPTION(ASPELL "Require aspell" OFF ALL)
LYX_OPTION(ENCHANT "Require Enchant" OFF ALL)
LYX_OPTION(HUNSPELL "Require Hunspell" OFF ALL)
LYX_OPTION(DEVEL_VERSION "Build developer version" OFF ALL)
LYX_OPTION(RELEASE "Build release version, build debug when disabled" OFF ALL)
+LYX_OPTION(DEBUG "Enforce debug build" OFF ALL)
+LYX_OPTION(NO_OPTIMIZE "Don't use any optimization/debug flags" OFF ALL)
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)
-LYX_OPTION(EXTERNAL_LIBINTL "Use external libintl" ON ALL)
+LYX_OPTION(BUNDLE "Build bundle (experimental) " OFF ALL)
# GCC specific
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)
-LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++pedantic debug mode" OFF GCC)
+LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC)
+LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC)
+LYX_OPTION(ENABLE_CXX11 "Build with options for c++11-mode" OFF GCC)
# MSVC specific
-LYX_OPTION(CONSOLE "Show console on Windows" ON MSVC)
+LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC)
LYX_OPTION(VLD "Use VLD with MSVC" OFF MSVC)
LYX_OPTION(WALL "Enable all warnings" OFF MSVC)
LYX_OPTION(CONFIGURE_CHECKS "Also run configure checks for MSVC" OFF MSVC)
LYX_OPTION(DEPENDENCIES_DOWNLOAD "Download dependencies for MSVC 10" OFF MSVC)
+# APPLE specific
+LYX_OPTION(DMG "Build as Mac bundle, needed for .dmg (experimental) " OFF MAC)
+LYX_OPTION(COCOA "Use Cocoa on Mac" OFF MAC)
+
if(help OR HELP)
message(STATUS)
- message(STATUS "Available options: (dis/enable with -D=0/1)")
+ message(STATUS "Available options: (dis/enable with -DLYX_*=OFF/ON)")
message(STATUS)
- LYX_OPTION_LIST_ALL(help)
+ LYX_OPTION_LIST_ALL(help)
message(STATUS)
-else()
-
-# 'project' triggers the searching for a compiler
-project(${LYX_PROJECT})
-
+ RETURN()
+endif()
# Check option dependencies
+if(LYX_DMG)
+ set(LYX_BUNDLE ON)
+ set(LYX_CPACK ON)
+endif()
+
if(LYX_CPACK)
set(LYX_INSTALL ON)
endif()
if (WIN32)
set(LYX_HUNSPELL ON)
endif()
- set(LYX_CONSOLE OFF)
+ if(LYX_CONSOLE MATCHES "FORCE")
+ set(LYX_CONSOLE ON)
+ else()
+ set(LYX_CONSOLE OFF)
+ endif()
set(LYX_PACKAGE_SUFFIX ON)
- set(LYX_RELEASE ON)
+ if(NOT LYX_DEBUG)
+ set(LYX_RELEASE ON)
+ endif()
set(LYX_PROFILE OFF)
endif()
+
if(LYX_MERGE_FILES)
set(LYX_PCH OFF)
else()
set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2010-deps)
message(STATUS "Using downloaded dependencies in ${LYX_DEPENDENCIES_DIR}")
set(deps_files lyx20-deps-msvc2010-x86.zip)
+ set(deps_server http://downloads.sourceforge.net/project/lyx/Win_installers/Dependencies)
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 ftp://ftp.devel.lyx.org/pub/contrib/windows/${it} ${LYX_DEPENDENCIES_DIR}/download/${it} SHOW_PROGRESS)
+ 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}
WORKING_DIRECTORY ${LYX_DEPENDENCIES_DIR})
endif()
endif()
+
message(STATUS)
set(EXECUTABLE_OUTPUT_PATH ${TOP_BINARY_DIR}/bin)
-set(LIBRARY_OUTPUT_PATH ${TOP_BINARY_DIR}/lib)
-
+if(WIN32)
+ set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
+else()
+ set(LIBRARY_OUTPUT_PATH ${TOP_BINARY_DIR}/lib)
+endif()
+set(LYX_GCC11_MODE)
if(UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
message(STATUS "Using GCC version ${GCC_VERSION}")
# http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.tr1
set(LYX_USE_TR1_REGEX 0)
endif()
+ if (LYX_ENABLE_CXX11)
+ if(GCC_VERSION VERSION_GREATER 4.7)
+ set(LYX_GCC11_MODE "-std=gnu++11")
+ elseif(GCC_VERSION VERSION_GREATER 4.2)
+ set(LYX_GCC11_MODE "-std=gnu++0x")
+ endif()
+ endif()
else()
if(MSVC10)
set(LYX_USE_TR1 1)
file(STRINGS "${TOP_SRC_DIR}/configure.ac" _config_lines)
if(WIN32)
- set(USE_WINDOWS_PACKAGING 1)
+ set(USE_WINDOWS_PACKAGING ON)
elseif(APPLE)
- set(USE_MACOSX_PACKAGING 1)
+ set(USE_MACOSX_PACKAGING ON)
else()
- set(USE_POSIX_PACKAGING 1)
+ set(USE_POSIX_PACKAGING ON)
endif()
-macro(setstripped _varname _value)
- string(STRIP ${_value} _v)
- if(USE_POSIX_PACKAGING)
- string(TOLOWER ${_v} ${_varname})
+macro(setstripped _varname)
+ if(${ARGC} GREATER 1)
+ string(STRIP "${ARGV1}" _v)
+ if(USE_POSIX_PACKAGING)
+ string(TOLOWER ${_v} ${_varname})
+ else()
+ set(${_varname} ${_v})
+ endif()
else()
- set(${_varname} ${_v})
+ set(${_varname})
endif()
endmacro(setstripped)
setstripped(PACKAGE_BASE ${CMAKE_MATCH_1})
setstripped(PACKAGE_VERSION ${CMAKE_MATCH_2})
setstripped(PACKAGE_BUGREPORT ${CMAKE_MATCH_3})
- if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\).*$")
+ if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\)\(\\.\([0-9]+\)\)?.*$")
set(LYX_MAJOR_VERSION ${CMAKE_MATCH_1})
set(LYX_MINOR_VERSION ${CMAKE_MATCH_2})
+ set(LYX_PATCH_VERSION ${CMAKE_MATCH_4})
set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
set(LYX_INSTALL_SUFFIX "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
endif()
endforeach(_c_l)
+if (LYX_LOCALVERSIONING)
+ # Find the revision number and for later use
+ FIND_PROGRAM(LYX_GITVERSION git)
+ #message(STATUS "gitversion = ${LYX_GITVERSION}")
+ if(LYX_GITVERSION)
+ EXECUTE_PROCESS(COMMAND ${LYX_GITVERSION} "describe" WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE LYX_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 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()
+ else()
+ set(LYX_REVISION_VERSION git) #TODO use date
+ endif()
+else()
+ set(LYX_REVISION_VERSION ${LYX_PATCH_VERSION})
+endif()
+
+if(LYX_PROGRAM_SUFFIX)
+ set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}")
+else()
+ set(PROGRAM_SUFFIX "")
+endif()
+
+add_custom_target(lyx_version ALL
+ COMMAND ${CMAKE_COMMAND} -DTOP_SRC_DIR=${TOP_SRC_DIR} -DTOP_CMAKE_PATH=${TOP_CMAKE_PATH} -DTOP_BINARY_DIR=${TOP_BINARY_DIR} -DLYX_DATE=${LYX_DATE} -P ${TOP_SCRIPT_PATH}/LyXGetVersion.cmake
+ )
+set_target_properties(lyx_version PROPERTIES FOLDER "applications")
-if (LYX_INSTALL_PREFIX)
+if(APPLE)
+ set(osx_bundle_program_name ${PACKAGE_BASE}${PROGRAM_SUFFIX})
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/development/MacOSX/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
+endif()
+
+if(LYX_BUNDLE)
+ set(LYX_CPACK ON)
+ message(STATUS)
+ message(STATUS "Bundle creation is enabled (experimental):")
+ message(STATUS " make")
+ message(STATUS " make install/strip")
+ message(STATUS " make package")
+ if(APPLE)
+ set(LYX_BUILD_BUNDLE MACOSX_BUNDLE)
+ set(CPACK_BUNDLE_NAME ${PACKAGE_BASE}${PROGRAM_SUFFIX})
+ set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
+ set(LYX_DATA_SUBDIR ${PACKAGE_BASE}${PROGRAM_SUFFIX}.app/Contents/Resources/ CACHE STRING "Bundle Contents dir" FORCE)
+ set(MACOSX_BUNDLE_STARTUP_COMMAND ${PACKAGE_BASE}${PROGRAM_SUFFIX}.app)
+ 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()
+ # Change the owner so that the install can work
+ install(CODE "set(BU_CHMOD_BUNDLE_ITEMS 1)")
+ 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")
+ endif()
+endif()
+
+if(LYX_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${LYX_INSTALL_PREFIX} CACHE PATH "LyX user's choice install prefix" FORCE)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
if(LYX_PACKAGE_SUFFIX)
set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
-else()
- set(PACKAGE ${PACKAGE_BASE})
-endif()
-
-if(LYX_PROGRAM_SUFFIX)
- set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}")
else()
- set(PROGRAM_SUFFIX "")
+ set(PACKAGE ${PACKAGE_BASE})
endif()
set(CMAKE_INSTALL_PREFIX LYX_INSTALLED CACHE PATH "LyX default install prefix" FORCE)
endif()
endif()
-
-if (WIN32)
- set(LYX_DATA_SUBDIR "Resources/" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+if(IS_ABSOLUTE)
+ set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
else()
- set(LYX_DATA_SUBDIR "" CACHE STRING "Subdirectory for all lyx-system-data" FORCE)
+ set(CMAKE_INSTALL_PREFIX_ABSOLUTE ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX})
+endif()
+
+
+
+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()
endif()
set(LYX_ABS_INSTALLED_DATADIR "${CMAKE_INSTALL_PREFIX}")
set(LYX_ABS_TOP_SRCDIR "${TOP_SRC_DIR}")
+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()
+
if(NOT GROUP_CODE)
#set(GROUP_CODE "The Golden Code")
set(GROUP_CODE flat)
set(LYX_HPP_FILES *.h)
set(LYX_MOC_FILES moc_*.cpp)
-
include(ProjectSourceGroup)
-if(LYX_PROFILE)
+if(LYX_PROFILE AND NOT MSVC)
set(CMAKE_BUILD_TYPE Profile CACHE TYPE STRING FORCE)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" CACHE TYPE STRING FORCE)
+ set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
+else()
+ set(LYX_PROFILE OFF)
endif()
-if(LYX_RELEASE)
- set(CMAKE_BUILD_TYPE Release CACHE STRING "Build release version" FORCE)
+
+if(LYX_NO_OPTIMIZE)
+ set(CMAKE_BUILD_TYPE None)
+ set(LYX_DEBUG OFF)
+ set(LYX_RELEASE OFF)
+ set(LYX_PROFILE OFF)
+elseif(LYX_RELEASE)
+ set(CMAKE_BUILD_TYPE Release)
+ set(LYX_DEBUG OFF)
+ set(LYX_PROFILE OFF)
+elseif(LYX_PROFILE)
+ set(CMAKE_BUILD_TYPE Profile)
+ set(LYX_DEBUG OFF)
else()
- set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build debug version" FORCE)
+ set(CMAKE_BUILD_TYPE Debug)
+ set(LYX_DEBUG ON)
endif()
+
# When shared libs are supported enable this option
#LYX_OPTION(SHARED_LIBRARIES "Build shared libraries" OFF ALL)
if(LYX_SHARED_LIBRARIES)
if(NOT LYX_QUIET)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
- set(LYX_CXX_FLAGS "-Wall -Wunused-parameter")
+ set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
if(LYX_STDLIB_DEBUG)
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
endif()
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCPP_CONCEPT_CHECKS")
endif()
set(CMAKE_CXX_FLAGS "${LYX_CXX_FLAGS} -fno-strict-aliasing " CACHE TYPE STRING FORCE)
- set(CMAKE_CXX_FLAGS_DEBUG "${LYX_CXX_FLAGS} -fno-strict-aliasing -O0 -g -D_DEBUG" CACHE TYPE STRING FORCE)
+ set(CMAKE_CXX_FLAGS_DEBUG "${LYX_CXX_FLAGS} -fno-strict-aliasing -O0 -g3 -D_DEBUG" CACHE TYPE STRING FORCE)
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()
- set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg" CACHE TYPE STRING FORCE)
endif()
+find_package(Qt5Core QUIET)
+if (Qt5Core_FOUND)
+ find_package(Qt5Widgets REQUIRED)
+ 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()
+else()
+ 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()
+endif()
-find_package(Qt4 REQUIRED)
-find_package(ICONV REQUIRED)
-find_package(ZLIB REQUIRED)
+find_package(Magic)
+if(Magic_FOUND)
+ set(HAVE_MAGIC_H 1)
+endif()
include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
-
+
if(LYX_ASPELL)
find_package(ASPELL)
include_directories(${ASPELL_INCLUDE_DIR})
endif()
if(LYX_NLS)
- FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python HINTS ${GNUWIN32_DIR}/python)
- if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
- message(FATAL_ERROR "Python 2.6 needed!")
- endif()
- find_package(LyXGettext REQUIRED)
- include_directories(${TOP_SRC_DIR}/po)
- add_subdirectory(po "${TOP_BINARY_DIR}/po")
-endif()
-
-if(LYX_EXTERNAL_LIBINTL)
- find_package(Libintl REQUIRED)
- add_definitions(-DHAVE_GETTEXT) #TODO move to config.h
-else()
- if(LYX_NLS)
- add_subdirectory(intl "${TOP_BINARY_DIR}/intl")
+ FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python)
+ find_package(LyXGettext)
+ if(LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND)
+ add_subdirectory(po "${TOP_BINARY_DIR}/po")
else()
- # do not compile if nls disabled
+ # 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()
endif()
endif()
+find_package(ICONV REQUIRED)
+find_package(ZLIB REQUIRED)
+
if(LYX_EXTERNAL_BOOST)
message(STATUS "Searching for boost")
find_package(Boost COMPONENTS signals regex) #TODO could REQUIRED be used
endif()
endif()
+# Compute qt4-version from ${QTVERSION}
+
message(STATUS "")
foreach(_v PACKAGE PACKAGE_VERSION
PROGRAM_SUFFIX LYX_DATE LYX_DIR_VER LYX_USERDIR_VER
# 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)
- configure_file(${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/pcheaders.h ${TOP_BINARY_DIR}/pcheaders.h)
- configure_file(${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/config.cpp.cmake ${TOP_BINARY_DIR}/config_pch.cpp)
+ 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)
add_definitions(-DLYX_ENABLE_PCH)
if(MSVC)
${TOP_BINARY_DIR}/pcheaders.h)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DLYX_PCH_STL /DLYX_PCH_BOOST /DLYX_PCH_QT4")
- set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /DLYX_PCH_STL /DLYX_PCH_BOOST")
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /DLYX_PCH_STL /DLYX_PCH_BOOST")
endmacro(lyx_add_msvc_pch)
macro(lyx_add_gcc_pch name_)
endmacro()
endmacro()
endif()
+
if(MSVC)
+
if(LYX_VLD)
- set(LYX_LEAK_DETECTION 1 CACHE TYPE STRING FORCE)
- set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
- set(LYX_VLD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../Win32/vld)
- include(${LYX_VLD_PATH}/tools/cmake/vld.cmake)
+ 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)
endif()
if(LYX_WALL)
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${MSVC_W_ERROR} ${MSVC_W_DISABLE}")
endif()
- 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-")
+
+ 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()
message(STATUS "----- Warning level : ${CMAKE_CXX_WARNING_LEVEL} ${WARNING_LEVEL_MESSAGE}")
message(STATUS "----- Warnings as errors : ${MSVC_W_ERROR}")
if(LYX_DEBUG_GLIBC)
- set(_GLIBCXX_DEBUG 1)
+ set(_GLIBCXX_DEBUG ON)
endif()
if(LYX_DEBUG_GLIBC_PEDANTIC)
- set(_GLIBCXX_DEBUG_PEDANTIC 1)
+ set(_GLIBCXX_DEBUG_PEDANTIC ON)
+endif()
+
+# Xcode compiler
+if (CMAKE_GENERATOR MATCHES Xcode)
+ # 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}")
+ENDIF(CMAKE_GENERATOR MATCHES Xcode)
+
+if (WIN32 AND Qt5Core_FOUND)
+ set(Z_PREFIX 1)
endif()
# compiler tests, config.h generation
configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
+if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*")
+ MATH(EXPR QT4_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}")
+endif()
+
+set(_lyx "${PACKAGE_BASE}${PROGRAM_SUFFIX}")
+set(_tex2lyx tex2lyx${PROGRAM_SUFFIX})
+
+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")
+
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")
if(LYX_INSTALL)
- FIND_PROGRAM(LYX_PERL_EXECUTABLE perl)
- if(${LYX_PERL_EXECUTABLE} MATCHES "-NOTFOUND")
- message(FATAL_ERROR "Perl required!")
+ if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
+ message(STATUS "Python required to create doc!")
+ else()
+ add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+ add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
+ endif()
+ if(NOT(LYX_BUNDLE AND APPLE))
+ include(../Install)
endif()
- add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
- add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
- include(../Install)
endif()
+add_subdirectory(sourcedoc "${TOP_BINARY_DIR}/sourcedoc")
+add_subdirectory(development/autotests "${TOP_BINARY_DIR}/autotests")
message(STATUS)
-message(STATUS "Build options, switch LYX_* variables by -DLYX_*=1 or 0:")
+message(STATUS "Build options, switch LYX_* variables by -DLYX_*=ON or OFF:")
message(STATUS)
LYX_OPTION_LIST_ALL(used)
-set(CPACK_PACKAGE_VERSION_MAJOR "${LYX_MAJOR_VERSION}")
-set(CPACK_PACKAGE_VERSION_MINOR "${LYX_MINOR_VERSION}")
-FILE(STRINGS "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_summary.txt" CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+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()
-set(CPACK_SOURCE_GENERATOR TGZ ZIP TBZ2)
-set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${TOP_SRC_DIR};/") # http://www.mail-archive.com/cmake@cmake.org/msg33720.html
+include("${TOP_CMAKE_PATH}/LyxPackaging.cmake")
-set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${LYX_INSTALL_SUFFIX}")
+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})
-set(CPACK_SOURCE_GENERATOR TGZ ZIP TBZ2)
-set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${TOP_SRC_DIR};/") # http://www.mail-archive.com/cmake@cmake.org/msg33720.html
-#
-# needed by rpm
-set(CPACK_SET_DESTDIR "ON")
-FILE(READ "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_license.txt" CPACK_RPM_PACKAGE_LICENSE)
-set(CPACK_RPM_PACKAGE_GROUP "Applications/Publishing")
-set(CPACK_RPM_PACKAGE_VENDOR "The LyX team")
-#
-# the next ones are needed by deb
-set(CPACK_PACKAGE_CONTACT "${PACKAGE_BUGREPORT}")
-set(CPACK_SOURCE_PACKAGE_FILE_NAME "${LYX_PROJECT}-${LYX_INSTALL_SUFFIX}")
-
-# This is experimental, valid on _my_ system (Kornel)
-set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqtgui4 (>= 4.4.3-0)")
-if(ASPELL_FOUND)
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libaspell15 (>= 0.60.6-1),${CPACK_DEBIAN_PACKAGE_DEPENDS}")
-endif()
-if(ENCHANT_FOUND)
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libenchant1c2a (>= 1.6.0-0),${CPACK_DEBIAN_PACKAGE_DEPENDS}")
-endif()
-if(LYX_EXTERNAL_BOOST)
- if(Boost_FOUND)
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-regex1.40.0 (>= 1.40.0-4),libboost-signals1.40.0 (>= 1.40.0-4),${CPACK_DEBIAN_PACKAGE_DEPENDS}")
- endif()
-endif()
-#
-# for the next ones, cpack insists on data with values in some file
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_description.txt")
-set(CPACK_RESOURCE_FILE_LICENSE "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_license.txt")
-
-# Find the revision number and use it as the release in rpm-package-build.
-# This way we may omit the otherwise needed "--force" parameter when
-# installing from that rpm package.
-FIND_PROGRAM(LYX_SVNVERSION svnversion)
-#message(STATUS "svnversion = ${LYX_SVNVERSION}")
-if(NOT ${LYX_SVNVERSION} MATCHES "-NOTFOUND")
- EXECUTE_PROCESS(COMMAND ${LYX_SVNVERSION} WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE CPACK_RPM_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
- # We use this value also to set the package-patch-value
- if(CPACK_RPM_PACKAGE_RELEASE MATCHES "^\([0-9]+\)")
- set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_1})
- endif()
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DIST_NAME}
+ COMMAND ${LYX_GITVERSION} archive --format=${DIST_FORMAT} --output=${CMAKE_CURRENT_BINARY_DIR}/${DIST_NAME} master
+ WORKING_DIRECTORY ${TOP_SRC_DIR})
+ add_custom_target(git-archive DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DIST_NAME})
endif()
-# we do not have a readme or welcome data,
-# so we do not provide infofiles for
-# CPACK_RESOURCE_FILE_README and CPACK_RESOURCE_FILE_WELCOME
-
-if(LYX_CPACK)
- include(CPack)
-endif()
-
-#Now it is possible to create some packages
-# cd <BuildDir>
-# make package
-#############################################################################################
-# So, e.g. for variables
-# CMAKE_PROJECT_NAME : lyx
-# CPACK_PACKAGE_VERSION_MAJOR : 2
-# CPACK_PACKAGE_VERSION_MINOR : 0
-# CPACK_PACKAGE_VERSION_PATCH : 1
-# CMAKE_SYSTEM_NAME : Linux
-# CPACK_BINARY_DEB:BOOL : ON
-#
-# the package name builds as "lyx-2.0.1-Linux.deb"
-#
-############################## rpm ################################### deb ##################
-# create # cpack -G RPM --config CPackConfig.cmake # cpack -G DEB --config CPackConfig.cmake
-# creates =># lyx-2.0.1-Linux.rpm # lyx-2.0.1-Linux.deb
-# list # rpm -qlp lyx-2.0.1-Linux.rpm # dpkg-deb -c lyx-2.0.1-Linux.deb
-# install # rpm -U lyx-2.0.1-Linux.rpm # dpkg -i lyx-2.0.1-Linux.deb
-#
message(STATUS)
-
-endif() #help
-