-
# 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)
+set(LYX_PROJECT lyx)
+
+set(LYX_CMAKE_DIR "development/cmake")
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/${LYX_CMAKE_DIR}/modules")
+
+get_filename_component(lyx_dir_readme ${CMAKE_SOURCE_DIR}/README ABSOLUTE)
+get_filename_component(TOP_SRC_DIR ${lyx_dir_readme} PATH)
+
+set(CMAKE_PROJECT_NAME ${LYX_PROJECT})
+
+message(STATUS)
+if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+ 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()
+
+
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 OLD)
cmake_policy(SET CMP0005 OLD)
include(LyXMacros)
-
# Usage LYX_OPTION
# 1. parameter: option name without prefix 'LYX_'
# 2. parameter: description
LYX_OPTION_INIT()
# Options for all compilers/systems
-LYX_OPTION(CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL)
-LYX_OPTION(INSTALL "Build install projects/rules (implies a bunch of other options)" OFF ALL)
-LYX_OPTION(NLS "Use nls" OFF 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" ON 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(CPACK "Use the CPack management (Implies LYX_INSTALL option)" OFF ALL)
+LYX_OPTION(INSTALL "Build install projects/rules (implies a bunch of other options)" OFF 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(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)
# 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(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(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
-LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC)
+LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
+LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF GCC)
# MSVC specific
-LYX_OPTION(CONSOLE "Show console on Windows" 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(CONSOLE "Show console on Windows" 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)
+
+if(help OR HELP)
+ message(STATUS)
+ message(STATUS "Available options: (dis/enable with -D=0/1)")
+ message(STATUS)
+ LYX_OPTION_LIST_ALL(help)
+ message(STATUS)
+else()
+
+# 'project' triggers the searching for a compiler
+project(${LYX_PROJECT})
+
+
# Check option dependencies
+
if(LYX_CPACK)
set(LYX_INSTALL ON)
endif()
# Try to get some informations from configure.ac
-include(LyXPaths) #called here to define the needed TOP_SRC_DIR-variable
+include(LyXPaths)
file(STRINGS "${TOP_SRC_DIR}/configure.ac" _config_lines)
if(WIN32)
find_package(Qt4 REQUIRED)
-find_package(ICONV REQUIRED)
-find_package(ZLIB REQUIRED)
+
include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
endif()
find_package(LyXGettext REQUIRED)
include_directories(${TOP_SRC_DIR}/po)
- add_subdirectory(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)
+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()
else()
- # do not compile if nls disabled
+ add_subdirectory(intl "${TOP_BINARY_DIR}/intl")
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()
add_definitions(-DBOOST_USER_CONFIG="<config.h>")
include_directories(${TOP_SRC_DIR}/boost)
- add_subdirectory(boost)
+ add_subdirectory(boost "${TOP_BINARY_DIR}/boost")
endif()
# 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}/development/cmake/pcheaders.h ${TOP_BINARY_DIR}/pcheaders.h)
- configure_file(${TOP_SRC_DIR}/development/cmake/config.cpp.cmake ${TOP_BINARY_DIR}/config_pch.cpp)
+ 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)
add_definitions(-DLYX_ENABLE_PCH)
if(MSVC)
# compiler tests, config.h generation
if(MSVC AND NOT LYX_CONFIGURE_CHECKS)
- configure_file(configCompiler.h.msvc ${TOP_BINARY_DIR}/configCompiler.h)
+ configure_file(${LYX_CMAKE_DIR}/configCompiler.h.msvc ${TOP_BINARY_DIR}/configCompiler.h)
else()
- include(ConfigureChecks.cmake)
- configure_file(configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h)
+ include(${LYX_CMAKE_DIR}/ConfigureChecks.cmake)
+ configure_file(${LYX_CMAKE_DIR}/configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h)
endif()
-configure_file(config.h.cmake ${TOP_BINARY_DIR}/config.h)
+configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
-add_subdirectory(src)
-add_subdirectory(lyx2lyx)
-add_subdirectory(scripts)
+add_subdirectory(src "${TOP_BINARY_DIR}/src")
+add_subdirectory(lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx")
+add_subdirectory(lib/scripts "${TOP_BINARY_DIR}/scripts")
if(LYX_INSTALL)
if(${LYX_PERL_EXECUTABLE} MATCHES "-NOTFOUND")
message(FATAL_ERROR "Perl required!")
endif()
- add_subdirectory(man)
- add_subdirectory(doc)
+ add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+ add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
include(../Install)
endif()
message(STATUS)
message(STATUS "Build options, switch LYX_* variables by -DLYX_*=1 or 0:")
message(STATUS)
-LYX_OPTION_LIST_ALL()
+LYX_OPTION_LIST_ALL(used)
+if(LYX_NLS)
+ 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 " * zlib")
+ message(STATUS " - header : ${ZLIB_HEADER}")
+ message(STATUS " - library: ${ZLIB_LIBRARY}")
+ message(STATUS)
+endif()
+
set(CPACK_PACKAGE_VERSION_MAJOR "${LYX_MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${LYX_MINOR_VERSION}")
-FILE(STRINGS "${TOP_SRC_DIR}/development/cmake/LyX_summary.txt" CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+FILE(STRINGS "${TOP_SRC_DIR}/${LYX_CMAKE_DIR}/LyX_summary.txt" CPACK_PACKAGE_DESCRIPTION_SUMMARY)
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}/development/cmake/LyX_license.txt" CPACK_RPM_PACKAGE_LICENSE)
+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")
#
endif()
#
# for the next ones, cpack insists on data with values in some file
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${TOP_SRC_DIR}/development/cmake/LyX_description.txt")
-set(CPACK_RESOURCE_FILE_LICENSE "${TOP_SRC_DIR}/development/cmake/LyX_license.txt")
+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
# install # rpm -U lyx-2.0.1-Linux.rpm # dpkg -i lyx-2.0.1-Linux.deb
#
message(STATUS)
+
+endif() #help
+