From 531e4b726dadbefc50ad707b4a72d1343a39660f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Tue, 20 Mar 2007 22:13:21 +0000 Subject: [PATCH] cmake build system: Add "merge" option which minimizes the number of files to build. only the qt4 and boost files will not merged into one file. This really speeds up the compilation. Usage: cmake ../trunk/development/cmake -Dmerge=1 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17495 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/cmake/CMakeLists.txt | 13 +++++++++ development/cmake/modules/LyXMacros.cmake | 14 ++++++++++ development/cmake/src/CMakeLists.txt | 8 +++++- .../cmake/src/frontends/CMakeLists.txt | 8 +++++- .../src/frontends/controllers/CMakeLists.txt | 7 ++++- development/cmake/src/graphics/CMakeLists.txt | 8 +++++- development/cmake/src/insets/CMakeLists.txt | 9 +++++- development/cmake/src/mathed/CMakeLists.txt | 8 +++++- development/cmake/src/support/CMakeLists.txt | 8 +++++- development/cmake/src/tex2lyx/CMakeLists.txt | 28 +++++++++++++------ 10 files changed, 95 insertions(+), 16 deletions(-) diff --git a/development/cmake/CMakeLists.txt b/development/cmake/CMakeLists.txt index d02e4cfa08..2101dec281 100644 --- a/development/cmake/CMakeLists.txt +++ b/development/cmake/CMakeLists.txt @@ -33,6 +33,15 @@ include(LyXPaths) include(LyXMacros) include(ProjectSourceGroup) +if(merge OR MERGE_FILES) + if(NOT MERGE_FILES) + set(MERGE_FILES TRUE CACHE TYPE STRING FORCE) + endif(NOT MERGE_FILES) + message(STATUS "") + message(STATUS "will merge all *.C files of a project into one file (exception: qt4 and boost files)") + message(STATUS "") +endif(merge OR MERGE_FILES) + if(release) set(CMAKE_BUILD_TYPE Release) set(release) @@ -42,6 +51,10 @@ endif(release) set(qt_postfix qt4) project(lyx-${qt_postfix}) find_package(Qt4 REQUIRED) +# maybe anyway +if(MERGE_FILES) + add_definitions(-DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_KEYWORDS) +endif(MERGE_FILES) find_package(ZLIB REQUIRED) find_package(ICONV REQUIRED) diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index caf323506f..dcde46f5f5 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -124,3 +124,17 @@ MACRO (LYX_AUTOMOC) endif (EXISTS ${_abs_FILE} AND NOT _skip) endforeach (_current_FILE) endmacro (LYX_AUTOMOC) + + +macro(lyx_merge_files _filename _list) + set(_tmp) + set(_content) + foreach(_current ${${_list}}) + file(READ ${_current} _tmp) + set(_content ${_content} "\n\n\n\n//----------------------------------------\n/*\n file: ${_current} \n*/\n\n") + set(_content ${_content} ${_tmp}) + endforeach(_current) + file(WRITE ${_filename} "${_content}") +endmacro(lyx_merge_files _list _filename) + + diff --git a/development/cmake/src/CMakeLists.txt b/development/cmake/src/CMakeLists.txt index 90ef06eeaa..1edb6bcfb8 100644 --- a/development/cmake/src/CMakeLists.txt +++ b/development/cmake/src/CMakeLists.txt @@ -37,7 +37,13 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) lyx_add_msvc_pch(lyx) -set(lyx_sources ${lyx_sources} ${CMAKE_CURRENT_BINARY_DIR}/version.C) + +if(NOT MERGE_FILES) + set(lyx_sources ${lyx_sources} ${CMAKE_CURRENT_BINARY_DIR}/version.C) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/lyx_allinone.C lyx_sources) + set(lyx_sources ${CMAKE_CURRENT_BINARY_DIR}/lyx_allinone.C ${CMAKE_CURRENT_BINARY_DIR}/version.C) +endif(NOT MERGE_FILES) add_executable(lyx-${qt_postfix} ${WIN32_CONSOLE} diff --git a/development/cmake/src/frontends/CMakeLists.txt b/development/cmake/src/frontends/CMakeLists.txt index 52c565a180..e420e88734 100644 --- a/development/cmake/src/frontends/CMakeLists.txt +++ b/development/cmake/src/frontends/CMakeLists.txt @@ -17,7 +17,13 @@ file(GLOB frontends_headers ${TOP_SRC_DIR}/src/frontends/*.h) lyx_add_msvc_pch(frontends) -add_library(frontends STATIC ${frontends_sources} ${frontends_headers}) + +if(NOT MERGE_FILES) + add_library(frontends STATIC ${frontends_sources} ${frontends_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/frontends_allinone.C frontends_sources) + add_library(frontends STATIC ${CMAKE_CURRENT_BINARY_DIR}/frontends_allinone.C) +endif(NOT MERGE_FILES) project_source_group("${GROUP_CODE}" frontends_sources frontends_headers) diff --git a/development/cmake/src/frontends/controllers/CMakeLists.txt b/development/cmake/src/frontends/controllers/CMakeLists.txt index 28e613c3c5..9738cdc6f8 100644 --- a/development/cmake/src/frontends/controllers/CMakeLists.txt +++ b/development/cmake/src/frontends/controllers/CMakeLists.txt @@ -13,7 +13,12 @@ lyx_add_msvc_pch(controllers) include_directories(${TOP_SRC_DIR}/src/frontends/controllers) -add_library(controllers STATIC ${controllers_sources} ${controllers_headers}) +if(NOT MERGE_FILES) + add_library(controllers STATIC ${controllers_sources} ${controllers_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/controllers_allinone.C controllers_sources) + add_library(controllers STATIC ${CMAKE_CURRENT_BINARY_DIR}/controllers_allinone.C) +endif(NOT MERGE_FILES) target_link_libraries(controllers boost_regex boost_filesystem) diff --git a/development/cmake/src/graphics/CMakeLists.txt b/development/cmake/src/graphics/CMakeLists.txt index fe24c1e25f..8f62e4382a 100644 --- a/development/cmake/src/graphics/CMakeLists.txt +++ b/development/cmake/src/graphics/CMakeLists.txt @@ -11,9 +11,15 @@ file(GLOB graphics_headers ${TOP_SRC_DIR}/src/graphics/*.h) lyx_add_msvc_pch(graphics) + include_directories(${TOP_SRC_DIR}/src/graphics) -add_library(graphics STATIC ${graphics_sources} ${graphics_headers}) +if(NOT MERGE_FILES) + add_library(graphics STATIC ${graphics_sources} ${graphics_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/graphics_allinone.C graphics_sources) + add_library(graphics STATIC ${CMAKE_CURRENT_BINARY_DIR}/graphics_allinone.C) +endif(NOT MERGE_FILES) project_source_group("${GROUP_CODE}" graphics_sources graphics_headers) diff --git a/development/cmake/src/insets/CMakeLists.txt b/development/cmake/src/insets/CMakeLists.txt index 733f4dc986..25be0c01a4 100644 --- a/development/cmake/src/insets/CMakeLists.txt +++ b/development/cmake/src/insets/CMakeLists.txt @@ -15,7 +15,14 @@ lyx_add_msvc_pch(insets) include_directories(${TOP_SRC_DIR}/src/insets) -add_library(insets STATIC ${insets_sources} ${insets_headers}) + +if(NOT MERGE_FILES) + add_library(insets STATIC ${insets_sources} ${insets_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/insets_allinone.C insets_sources) + add_library(insets STATIC ${CMAKE_CURRENT_BINARY_DIR}/insets_allinone.C) +endif(NOT MERGE_FILES) + project_source_group("${GROUP_CODE}" insets_sources insets_headers) diff --git a/development/cmake/src/mathed/CMakeLists.txt b/development/cmake/src/mathed/CMakeLists.txt index 7c00bd2e44..da67eb15d1 100644 --- a/development/cmake/src/mathed/CMakeLists.txt +++ b/development/cmake/src/mathed/CMakeLists.txt @@ -17,7 +17,13 @@ lyx_add_msvc_pch(mathed) include_directories(${TOP_SRC_DIR}/src/mathed) -add_library(mathed STATIC ${mathed_sources} ${mathed_headers}) +if(NOT MERGE_FILES) + add_library(mathed STATIC ${mathed_sources} ${mathed_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/mathed_allinone.C mathed_sources) + add_library(mathed STATIC ${CMAKE_CURRENT_BINARY_DIR}/mathed_allinone.C) +endif(NOT MERGE_FILES) + project_source_group("${GROUP_CODE}" mathed_sources mathed_headers) diff --git a/development/cmake/src/support/CMakeLists.txt b/development/cmake/src/support/CMakeLists.txt index c23a308170..c2e7d3f120 100644 --- a/development/cmake/src/support/CMakeLists.txt +++ b/development/cmake/src/support/CMakeLists.txt @@ -26,7 +26,13 @@ lyx_add_msvc_pch(support) include_directories(${TOP_SRC_DIR}/src/support ${ICONV_INCLUDE_DIR}) -add_library(support STATIC ${support_sources} ${support_headers}) +if(NOT MERGE_FILES) + add_library(support STATIC ${support_sources} ${support_headers}) +else(NOT MERGE_FILES) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/support_allinone.C support_sources) + add_library(support STATIC ${CMAKE_CURRENT_BINARY_DIR}/support_allinone.C) +endif(NOT MERGE_FILES) + target_link_libraries(support boost_signals) diff --git a/development/cmake/src/tex2lyx/CMakeLists.txt b/development/cmake/src/tex2lyx/CMakeLists.txt index 1883eb5580..e206f44ecf 100644 --- a/development/cmake/src/tex2lyx/CMakeLists.txt +++ b/development/cmake/src/tex2lyx/CMakeLists.txt @@ -12,34 +12,36 @@ set(LINKED_FILES ${TOP_SRC_DIR}/src/FloatList.C ${TOP_SRC_DIR}/src/Floating.C ${TOP_SRC_DIR}/src/counters.C - ${TOP_SRC_DIR}/src/lyxlayout.h ${TOP_SRC_DIR}/src/lyxlayout.C ${TOP_SRC_DIR}/src/lyxtextclass.C - ${TOP_SRC_DIR}/src/lyxtextclass.h ${TOP_SRC_DIR}/src/lyxlex.C ${TOP_SRC_DIR}/src/lyxlex_pimpl.C ) set(tex2lyx_sources - ${TOP_SRC_DIR}/src/tex2lyx/Spacing.h ${TOP_SRC_DIR}/src/tex2lyx/boost.C ${TOP_SRC_DIR}/src/tex2lyx/context.C - ${TOP_SRC_DIR}/src/tex2lyx/ - ${TOP_SRC_DIR}/src/tex2lyx/context.h ${TOP_SRC_DIR}/src/tex2lyx/gettext.C ${TOP_SRC_DIR}/src/tex2lyx/lengthcommon.C ${TOP_SRC_DIR}/src/tex2lyx/lyxfont.C - ${TOP_SRC_DIR}/src/tex2lyx/lyxfont.h ${TOP_SRC_DIR}/src/tex2lyx/texparser.C - ${TOP_SRC_DIR}/src/tex2lyx/texparser.h ${TOP_SRC_DIR}/src/tex2lyx/tex2lyx.C - ${TOP_SRC_DIR}/src/tex2lyx/tex2lyx.h ${TOP_SRC_DIR}/src/tex2lyx/preamble.C ${TOP_SRC_DIR}/src/tex2lyx/math.C ${TOP_SRC_DIR}/src/tex2lyx/table.C ${TOP_SRC_DIR}/src/tex2lyx/text.C ) +set(tex2lyx_headers + ${TOP_SRC_DIR}/src/lyxlayout.h + ${TOP_SRC_DIR}/src/lyxtextclass.h + ${TOP_SRC_DIR}/src/tex2lyx/Spacing.h + ${TOP_SRC_DIR}/src/tex2lyx/context.h + ${TOP_SRC_DIR}/src/tex2lyx/lyxfont.h + ${TOP_SRC_DIR}/src/tex2lyx/texparser.h + ${TOP_SRC_DIR}/src/tex2lyx/tex2lyx.h +) + include_directories(BEFORE ${TOP_SRC_DIR}/src/tex2lyx) if(MSVC) @@ -52,7 +54,15 @@ else(MSVC) "-include ${TOP_SRC_DIR}/src/tex2lyx/lyxfont.h -include ${TOP_SRC_DIR}/src/tex2lyx/Spacing.h") endif(MSVC) -add_executable(tex2lyx ${tex2lyx_sources} ${LINKED_FILES}) + +if(NOT MERGE_FILES) + add_executable(tex2lyx ${tex2lyx_sources} ${LINKED_FILES} ${tex2lyx_headers}) +else(NOT MERGE_FILES) + set(tex2lyx_sources_all ${tex2lyx_sources} ${LINKED_FILES}) + lyx_merge_files(${CMAKE_CURRENT_BINARY_DIR}/tex2lyx_allinone.C tex2lyx_sources_all) + add_executable(tex2lyx ${CMAKE_CURRENT_BINARY_DIR}/tex2lyx_allinone.C) +endif(NOT MERGE_FILES) + target_link_libraries(tex2lyx support -- 2.39.2