New cmake build from top source dir

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38608 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Kornel Benko 2011-05-07 10:38:22 +00:00
parent 45b61c6ecf
commit d096463859
6 changed files with 45 additions and 23 deletions

29
CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
# 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)
project(${LYX_PROJECT})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/development/cmake/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})
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()
add_subdirectory(development/cmake "${TOP_BINARY_DIR}")

View File

@ -13,9 +13,6 @@ if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 OLD)
endif()
set(LYX_PROJECT lyx)
project(${LYX_PROJECT})
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Supress regeneration
@ -23,7 +20,6 @@ set(CMAKE_SUPPRESS_REGENERATION FALSE)
# where to look first for cmake modules,
# before ${CMAKE_ROOT}/Modules is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
include(LyXMacros)
@ -93,7 +89,7 @@ endif()
if(LYX_DEPENDENCIES_DOWNLOAD)
message(STATUS)
set(LYX_DEPENDENCIES_DIR ${CMAKE_BINARY_DIR}/msvc2010-deps)
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)
foreach(it ${deps_files})
@ -112,8 +108,8 @@ endif()
message(STATUS)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${TOP_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${TOP_BINARY_DIR}/lib)
@ -283,7 +279,7 @@ find_package(Qt4 REQUIRED)
find_package(ICONV REQUIRED)
find_package(ZLIB REQUIRED)
include_directories(${CMAKE_BINARY_DIR} ${TOP_SRC_DIR}/src)
include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
if(LYX_ASPELL)
find_package(ASPELL)
@ -377,18 +373,18 @@ if(LYX_PCH)
# 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(${CMAKE_SOURCE_DIR}/pcheaders.h ${CMAKE_BINARY_DIR}/pcheaders.h)
configure_file(${CMAKE_SOURCE_DIR}/config.cpp.cmake ${CMAKE_BINARY_DIR}/config_pch.cpp)
configure_file(${CMAKE_SOURCE_DIR}/pcheaders.h ${TOP_BINARY_DIR}/pcheaders.h)
configure_file(${CMAKE_SOURCE_DIR}/config.cpp.cmake ${TOP_BINARY_DIR}/config_pch.cpp)
add_definitions(-DLYX_ENABLE_PCH)
if(MSVC)
macro(lyx_add_msvc_pch name_)
set_source_files_properties(${${name_}_sources} PROPERTIES
COMPILE_FLAGS "/Yuconfig.h /Fp\$(IntDir)/config.pch")
set_source_files_properties(${CMAKE_BINARY_DIR}/config_pch.cpp PROPERTIES
set_source_files_properties(${TOP_BINARY_DIR}/config_pch.cpp PROPERTIES
COMPILE_FLAGS "/Ycconfig.h /Fp\$(IntDir)/config.pch")
set(${name_}_sources ${${name_}_sources} ${CMAKE_BINARY_DIR}/config_pch.cpp
${CMAKE_BINARY_DIR}/pcheaders.h)
set(${name_}_sources ${${name_}_sources} ${TOP_BINARY_DIR}/config_pch.cpp
${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")
@ -400,7 +396,7 @@ if(LYX_PCH)
endmacro()
macro(lyx_add_gcc_pch name_)
add_definitions(-DLYX_PCH_STL -DLYX_PCH_BOOST -DLYX_PCH_QT4)
ADD_PRECOMPILED_HEADER(${name_} ${CMAKE_BINARY_DIR}/config_pch.cpp ${CMAKE_BINARY_DIR}/config.h.gch)
ADD_PRECOMPILED_HEADER(${name_} ${TOP_BINARY_DIR}/config_pch.cpp ${TOP_BINARY_DIR}/config.h.gch)
endmacro()
endif()
else()
@ -477,13 +473,13 @@ endif()
# compiler tests, config.h generation
if(MSVC AND NOT LYX_CONFIGURE_CHECKS)
configure_file(configCompiler.h.msvc ${CMAKE_BINARY_DIR}/configCompiler.h)
configure_file(configCompiler.h.msvc ${TOP_BINARY_DIR}/configCompiler.h)
else()
include(ConfigureChecks.cmake)
configure_file(configCompiler.h.cmake ${CMAKE_BINARY_DIR}/configCompiler.h)
configure_file(configCompiler.h.cmake ${TOP_BINARY_DIR}/configCompiler.h)
endif()
configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
configure_file(config.h.cmake ${TOP_BINARY_DIR}/config.h)
add_subdirectory(src)

View File

@ -29,7 +29,7 @@ foreach(_rel_doc ${_rel_lyx_docs})
SET_SOURCE_FILES_PROPERTIES(${_created_doc} GENERATED)
add_custom_command(
OUTPUT "${_created_doc}"
COMMAND perl "${CMAKE_SOURCE_DIR}/doc/ReplaceValues.pl" "LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}" "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}"
COMMAND perl "${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.pl" "LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}" "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}"
DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_rel_doc}" DESTINATION "${LYX_DATA_SUBDIR}doc/${_rel_dir_part}")

View File

@ -85,9 +85,6 @@ else()
endif()
get_filename_component(lyx_dir_readme ${CMAKE_SOURCE_DIR}/../../README ABSOLUTE)
get_filename_component(TOP_SRC_DIR ${lyx_dir_readme} PATH)
if(WIN32)
set(locale_dir Resources/locale)
else()

View File

@ -87,7 +87,7 @@ add_gettext_python(layouttranslations lib/layouts *.layout *.inc *.module)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
COMMAND ${LYX_PYTHON_EXECUTABLE}
ARGS "${CMAKE_SOURCE_DIR}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
ARGS "${TOP_SRC_DIR}/development/cmake/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
DEPENDS ${_py_sources}
)

View File

@ -45,7 +45,7 @@ lyx_add_msvc_pch(support)
lyx_automoc(${support_sources})
include_directories(${TOP_SRC_DIR}/src/support
${CMAKE_BINARY_DIR}/src/support
${TOP_BINARY_DIR}/src/support
${TOP_SRC_DIR}/src/support/mythes
${QT_INCLUDES}
${ICONV_INCLUDE_DIR}