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(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})
+ 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 " 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")
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)
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()
endif()
endif()
+if(LYX_EXTERNAL_LIBINTL)
+ set(intl_link ${LIBINTL_LIBRARIES})
+else()
+ set(intl_link intl)
+endif()
+
find_package(ICONV REQUIRED)
find_package(ZLIB REQUIRED)
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}")
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")
add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
endif()
- include(../Install)
+ if(NOT(LYX_BUNDLE AND APPLE))
+ include(../Install)
+ endif()
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)
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)