# Copyright (c) 2008-2010 Kornel Benko, <Kornel.Benko@berlin.de>
-cmake_minimum_required(VERSION 2.4)
+cmake_minimum_required(VERSION 2.6.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 OLD)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/
-# is checked
+# where to look first for cmake modules,
+# before ${CMAKE_ROOT}/Modules is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
+include(LyXMacros)
+
+message(STATUS)
+message(STATUS "Switch LYX_* variables by -DLYX_*=1 or 0:")
+LYX_OPTION(INSTALL "Build install projects/rules" ON)
+LYX_OPTION(DISABLE_PCH "Disable precompiled headers" ON)
+LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF)
+LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++pedantic debug mode" OFF)
+LYX_OPTION(USE_EXTERNAL_BOOST "Use external boost" OFF)
+LYX_OPTION(NLS "Use nls" OFF)
+LYX_OPTION(ASPELL "Use aspell" OFF)
+LYX_OPTION(NO_CONSOLE "Suppress Console on Windows" OFF)
+LYX_OPTION(USE_VERSION_SUFFIX "Use version suffix for packaging" OFF)
+LYX_OPTION(VLD "Use VLD on with MSVC" OFF)
+LYX_OPTION(MERGE_FILES "Merge source files into one copilation unit" OFF)
+LYX_OPTION(DEBUG "Build debug version" OFF)
+LYX_OPTION(RELEASE "Build release" ON)
+LYX_OPTION(PROFILE "Enable profile build for GCC" OFF)
+LYX_OPTION(STDLIB_DEBUG "Use debug stdstdlib" OFF)
+LYX_OPTION(CONCEPT_CHECKS "Enable concept-checks" OFF)
+LYX_OPTION(QUIET "Don't generate verbose makefiles" OFF)
+LYX_OPTION(SHARED_LIBRARIES "Build shared libraries" OFF)
+LYX_OPTION(USE_EXTERNAL_LIBINTL "Use external libintl" ON)
+message(STATUS)
+
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
-option(LYX_DEBUG_GLIBC "Enable libstdc++ debug mode" OFF)
-option(LYX_DEBUG_GLIBC_PEDANTIC "Enable libstdc++pedantic debug mode" OFF)
-option(LYX_INSTALL "Build install projects/rules" ON)
-option(LYX_USE_VERSION_SUFFIX "Using executables with versioned suffix" OFF)
-option(LYX_ASPELL "Use aspell library" OFF)
-option(LYX_NLS "Enable build with nls support" OFF)
-option(LYX_USE_EXTERNAL_BOOST "Use external boost" OFF)
-option(LYX_DISABLE_PCH "Disable precompiled headers" ON)
+
if(UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
endforeach(_c_l)
if(LYX_USE_VERSION_SUFFIX)
- message(STATUS "-- Using versioned PACKAGE. Disable with -DLYX_USE_VERSION_SUFFIX=OFF")
set(PACKAGE ${PACKAGE_BASE}${LYX_INSTALL_SUFFIX})
set(PROGRAM_SUFFIX "${LYX_INSTALL_SUFFIX}")
-else()
- message(STATUS "-- PACKAGE not versioned, to enable use -DLYX_USE_VERSION_SUFFIX=ON")
+else()
set(PACKAGE ${PACKAGE_BASE})
set(PROGRAM_SUFFIX "")
endif()
set(LYX_HPP_FILES *.h)
set(LYX_MOC_FILES moc_*.cpp)
-include(LyXMacros)
+
include(ProjectSourceGroup)
-if(merge OR merge_rebuild)
- set(merge 1 CACHE TYPE STRING FORCE)
- set(MERGE_FILES 1 CACHE TYPE STRING FORCE)
- message(STATUS "")
- message(STATUS "All *.cpp files of a project are merged into two files, disable with -Dmerge=0")
- message(STATUS "")
+if(LYX_MERGE_FILES)
add_definitions(-DLYX_MERGED_BUILD)
-else()
- set(merge 0 CACHE TYPE STRING FORCE)
- set(MERGE_FILES 0 CACHE TYPE STRING FORCE)
- message(STATUS "Enable merging files with -Dmerge=1")
endif()
set(CMAKE_BUILD_TYPE Release)
-if(profile)
+if(LYX_PROFILE)
set(CMAKE_BUILD_TYPE Profile CACHE TYPE STRING FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg"
- CACHE TYPE STRING FORCE)
- set(profile)
+ CACHE TYPE STRING FORCE)
endif()
-if(release)
+if(LYX_RELEASE)
set(CMAKE_BUILD_TYPE Release CACHE TYPE STRING FORCE)
- set(release TRUE CACHE TYPE STRING FORCE)
- set(release)
endif()
-if(debug)
+if(LYX_DEBUG)
set(CMAKE_BUILD_TYPE Debug CACHE TYPE STRING FORCE)
- set(debug TRUE CACHE TYPE STRING FORCE)
- set(debug)
endif()
-if(shared)
+
+
+if(LYX_SHARED_LIBRARIES)
set(library_type SHARED)
- message(STATUS "building shared libraries")
else()
set(library_type STATIC)
endif()
if(NOT MSVC)
- if(NOT quiet)
- set(CMAKE_VERBOSE_MAKEFILE ON CACHE TYPE STRING FORCE)
- message(STATUS "verbose Makefile, disable with -Dquiet=1")
- message(STATUS "")
- else()
- set(CMAKE_VERBOSE_MAKEFILE OFF CACHE TYPE STRING FORCE)
+ if(NOT LYX_QUIET)
+ set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
set(LYX_CXX_FLAGS -Wall)
- if(stdlib-debug)
+ if(LYX_STDLIB_DEBUG)
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
endif()
- if(concept-checks)
+ if(LYX_CONCEPT_CHECKS)
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)
find_package(ZLIB REQUIRED)
-if(all OR LYX_ASPELL)
- set(LYX_ASPELL TRUE CACHE TYPE STRING)
+if(LYX_ASPELL)
find_package(ASPELL REQUIRED)
else()
find_package(ASPELL)
endif()
-set(LYX_ASPELL)
-set(use_external_libintl TRUE)
-if(use_external_libintl)
+if(LYX_USE_EXTERNAL_LIBINTL)
find_package(Libintl REQUIRED)
add_definitions(-DHAVE_GETTEXT)
endif()
+
if(WIN32)
find_library(HUNSPELL_LIBRARY "libhunspell")
else()
if (HUNSPELL_FOUND)
add_definitions(-DUSE_HUNSPELL=1)
- message(STATUS "----- Building with USE_HUNSPELL")
+ message(STATUS "Building with USE_HUNSPELL")
else()
- message(STATUS "----- Hunspell not found, building without hunspell support")
+ message(STATUS "Hunspell not found, building without hunspell support")
endif()
if(WIN32)
if (ENCHANT_LIBRARY AND ENCHANT_INCLUDE_DIR)
set(ENCHANT_FOUND TRUE)
add_definitions(-DUSE_ENCHANT=1)
- message(STATUS "----- Building with USE_ENCHANT")
+ message(STATUS "Building with USE_ENCHANT")
else()
- message(STATUS "----- Enchant not found, building without enchant support")
+ message(STATUS "Enchant not found, building without enchant support")
endif()
-message(STATUS "")
-if(LYX_NLS OR all)
- set(LYX_NLS TRUE CACHE TYPE STRING)
- add_definitions(-DENABLE_NLS=1)
- message(STATUS "----- Building with ENABLE_NLS")
-else()
- message(STATUS "----- No nls, to enable use -DLYX_NLS=1")
+
+if(LYX_NLS)
+ add_definitions(-DENABLE_NLS=1)
endif()
-set(LYX_NLS)
+
if(ASPELL_FOUND)
add_definitions(-DUSE_ASPELL=1)
- message(STATUS "----- Building with USE_ASPELL")
-else()
- message(STATUS "----- No aspell, to get more information use -DLYX_ASPELL=ON")
endif()
-set(all)
if(WIN32)
- option(LYX_NO_CONSOLE "Compile LyX as a GUI" OFF)
- if(LYX_NO_CONSOLE)
- set(LYX_NO_CONSOLE TRUE CACHE TYPE STRING)
+ if(LYX_NO_CONSOLE)
set(WIN32_CONSOLE WIN32)
set(LYX_QTMAIN_LIBRARY ${QT_QTMAIN_LIBRARY})
- message(STATUS "----- Console disabled")
- else()
- message(STATUS "----- Console enabled, disable it with -DLYX_NO_CONSOLE=ON")
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX)
if(NOT LYX_DISABLE_PCH)
- message(STATUS "-----")
- message(STATUS "----- using precompiled headers, disable with -DLYX_DISABLE_PCH=1")
- message(STATUS "-----")
configure_file(${CMAKE_SOURCE_DIR}/pcheaders.h ${CMAKE_BINARY_DIR}/pcheaders.h)
configure_file(${CMAKE_SOURCE_DIR}/config.cpp.cmake ${CMAKE_BINARY_DIR}/config_pch.cpp)
add_definitions(-DLYX_ENABLE_PCH)
endmacro()
endif()
else()
- if(MSVC)
- message(STATUS "-----")
- message(STATUS "----- precompiled headers disabled, enable with -DLYX_DISABLE_PCH=0")
- message(STATUS "-----")
- endif()
set(LYX_DISABLE_PCH TRUE CACHE TYPE STRING)
macro(lyx_add_msvc_pch)
endmacro(lyx_add_msvc_pch)
endif()
if(MSVC)
- if(vld)
- set(vld 1 CACHE TYPE STRING FORCE)
+ if(LYX_VLD)
set(LYX_LEAK_DETECTION 1 CACHE TYPE STRING FORCE)
- message(STATUS "")
- message(STATUS "Leak detection enabled, disable with -Dvld=0")
- message(STATUS "")
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
set(vld_path ${CMAKE_CURRENT_SOURCE_DIR}/../Win32/vld)
include(${vld_path}/tools/cmake/vld.cmake)
- else()
- set(vld 0 CACHE TYPE STRING FORCE)
- set(LYX_LEAK_DETECTION 0 CACHE TYPE STRING FORCE)
- message(STATUS "")
- message(STATUS "Enable leak detection with -Dvld=1")
- message(STATUS "")
endif()
+ # TODO options
if(WALL)
set(WALL 1 CACHE TYPE STRING FORCE)
FIND_PROGRAM(_PERL_EXECUTABLE perl)
if(NOT ${_PERL_EXECUTABLE} MATCHES "-NOTFOUND")
- if(LYX_NLS OR all)
+ if(LYX_NLS)
find_package(LyXGettext REQUIRED)
include_directories(${TOP_SRC_DIR}/po)
add_subdirectory(po)
endif()
endif()
+
+
if(LYX_DEBUG_GLIBC)
set(_GLIBCXX_DEBUG 1)
endif()
${CMAKE_BINARY_DIR}
${TOP_SRC_DIR}/src)
+
if(LYX_USE_EXTERNAL_BOOST)
message(STATUS "Searching for boost")
find_package(Boost COMPONENTS signals regex)
message(FATAL_ERROR "Boost not found" ${Boost_ERROR_REASON})
endif()
else()
- message(STATUS "----- Using internal boost. To build with installed version use -DLYX_USE_EXTERNAL_BOOST:BOOL=ON")
if(LYX_USE_TR1_REGEX)
set(Lyx_Boost_Libraries boost_signals)
else()
endif()
-if(NOT use_external_libintl)
+if(NOT LYX_USE_EXTERNAL_LIBINTL)
add_subdirectory(intl)
endif()
add_subdirectory(src)
# 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(_svnversion svnversion)
-message(STATUS "svnversion = ${_svnversion}")
-if(NOT ${_svnversion} MATCHES "-NOTFOUND")
- EXECUTE_PROCESS(COMMAND ${_svnversion} WORKING_DIRECTORY "${TOP_SRC_DIR}" OUTPUT_VARIABLE CPACK_RPM_PACKAGE_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
+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})
# 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)