cmake_minimum_required(VERSION 2.6.4)
-
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)
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(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, enforce with =FORCE" ON MSVC)
# Check option dependencies
-if(LYX_CPACK)
- set(LYX_INSTALL ON)
-endif()
-
if(LYX_DMG)
set(LYX_BUNDLE ON)
set(LYX_CPACK ON)
endif()
+if(LYX_CPACK)
+ set(LYX_INSTALL ON)
+endif()
+
if(LYX_INSTALL)
set(LYX_NLS ON)
if (WIN32)
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()
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)
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)
# 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
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(APPLE)
set(osx_bundle_program_name ${PACKAGE_BASE}${PROGRAM_SUFFIX})
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()
endif()
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(Magic)
if(Magic_FOUND)
set(HAVE_MAGIC_H 1)
if(LYX_NLS)
FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS ${GNUWIN32_DIR}/python)
- if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
- message(FATAL_ERROR "Python 2.6 needed!")
- endif()
- find_package(LyXGettext REQUIRED)
- add_subdirectory(po "${TOP_BINARY_DIR}/po")
-endif()
-
-if(LYX_NLS)
- if(LYX_EXTERNAL_LIBINTL)
- find_package(Libintl REQUIRED)
- if(DEFINED LIBINTL_LIBRARIES)
- # find getext when configuring
- list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBINTL_LIBRARIES})
- # on mac use iconv also form ports
- get_filename_component(ICONV_RELATIVE_TO_LIBINTL ${LIBINTL_LIBRARIES} PATH)
- endif()
+ find_package(LyXGettext)
+ if(LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND)
+ add_subdirectory(po "${TOP_BINARY_DIR}/po")
else()
- add_subdirectory(intl "${TOP_BINARY_DIR}/intl")
+ # 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()
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)
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}")
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
if(MSVC AND NOT LYX_CONFIGURE_CHECKS)
configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
-# Compute qt4-version from ${QTVERSION}
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")
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_*=ON or OFF:")
message(STATUS)
message(STATUS "Building Native Language Support (LYX_NLS is set), used libraries:")
message(STATUS)
- message(STATUS " * intl")
- message(STATUS " - header : ${LIBINTL_HEADER}")
- message(STATUS " - library: ${LIBINTL_LIBRARIES}")
message(STATUS " * iconv")
message(STATUS " - header : ${ICONV_HEADER}")
message(STATUS " - library: ${ICONV_LIBRARY}")
message(STATUS)
endif()
-include("${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyxPackaging.cmake")
+include("${TOP_CMAKE_PATH}/LyxPackaging.cmake")
+
+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(
+ 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()
message(STATUS)