From 3d6d933f65578e2805335f1a946b6a850f111031 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sun, 21 Sep 2014 11:00:06 +0200 Subject: [PATCH] cotire 1.6.6 --- CMake/cotire.cmake | 60 +++++++++++++++++-------------- HISTORY.md | 8 +++++ MANUAL.md | 8 +++++ Patches/fsedit-qt5.patch | 74 ++++++++++++++++++++++++++++++++++++++ Patches/fseditor-1.0.patch | 68 +++++++++++++++++++++++++++++++++++ README.md | 2 +- 6 files changed, 192 insertions(+), 28 deletions(-) create mode 100644 Patches/fsedit-qt5.patch create mode 100644 Patches/fseditor-1.0.patch diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake index b00b0d4..d855c1d 100644 --- a/CMake/cotire.cmake +++ b/CMake/cotire.cmake @@ -45,7 +45,7 @@ if (NOT CMAKE_SCRIPT_MODE_FILE) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.6.5") +set (COTIRE_CMAKE_MODULE_VERSION "1.6.6") include(CMakeParseArguments) include(ProcessorCount) @@ -1890,8 +1890,8 @@ function (cotire_get_prefix_header_dependencies _language _target _dependencySou # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) - if (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") - # Clang raises a fatal error if a file is not found during preprocessing + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GCC and clang raise a fatal error if a file is not found during preprocessing # thus we depend on target's generated source files for prefix header generation cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) if (_generatedSources) @@ -2712,9 +2712,10 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) # copy interface stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_STRING + COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES - INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + INTERFACE_AUTOUIC_OPTIONS) # copy link stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH @@ -2727,7 +2728,8 @@ function (cotire_setup_unity_build_target _languages _configurations _targetSour NO_SONAME SOVERSION VERSION) # copy Qt stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - AUTOMOC AUTOMOC_MOC_OPTIONS) + AUTOMOC AUTOMOC_MOC_OPTIONS AUTOUIC AUTOUIC_OPTIONS AUTORCC AUTORCC_OPTIONS + AUTOGEN_TARGET_DEPENDS) # copy cmake stuff cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) @@ -2847,6 +2849,24 @@ function (cotire_target _target) endif() endfunction(cotire_target) +function (cotire_map_libraries _strategy _mappedLibrariesVar) + set (_mappedLibraries "") + foreach (_library ${ARGN}) + if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") + get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_libraryUnityTargetName}") + list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + else() + list (APPEND _mappedLibraries "${_library}") + endif() + else() + list (APPEND _mappedLibraries "${_library}") + endif() + endforeach() + list (REMOVE_DUPLICATES _mappedLibraries) + set (${_mappedLibrariesVar} ${_mappedLibraries} PARENT_SCOPE) +endfunction() + function (cotire_target_link_libraries _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_unityTargetName}") @@ -2857,29 +2877,15 @@ function (cotire_target_link_libraries _target) if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") if (CMAKE_VERSION VERSION_LESS "2.8.11") message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") - return() - endif() - get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) - if (_linkLibraries) + else() + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries} ${_interfaceLinkLibraries}) if (COTIRE_DEBUG) - message (STATUS "target ${_target} link libraries: ${_linkLibraries}") + message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") endif() - set (_unityTargetLibraries "") - foreach (_library ${_linkLibraries}) - if (TARGET "${_library}" AND "${_linkLibrariesStrategy}" MATCHES "COPY_UNITY") - get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) - if (TARGET "${_libraryUnityTargetName}") - list (APPEND _unityTargetLibraries "${_libraryUnityTargetName}") - else() - list (APPEND _unityTargetLibraries "${_library}") - endif() - else() - list (APPEND _unityTargetLibraries "${_library}") - endif() - endforeach() - set_property(TARGET ${_unityTargetName} APPEND PROPERTY LINK_LIBRARIES ${_unityTargetLibraries}) - if (COTIRE_DEBUG) - message (STATUS "set unity target ${_unityTargetName} link libraries: ${_unityTargetLibraries}") + if (_unityLinkLibraries) + target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) endif() endif() endif() diff --git a/HISTORY.md b/HISTORY.md index 2d7baac..55c3ea4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,11 @@ +## 1.6.6 (2014-09-21) + +* fix GCC issue with prefix header generation when source files are missing. +* fix bug where some target properties were not properly propagated to the generated unity target. +* use `target_link_libraries` to set up the unity target link libraries. +* add Qt4 and Qt5 examples to the `Patches` directory. +* documentation updates. + ## 1.6.5 (2014-08-26) * correctly handle generator expressions used in compile definitions, compile flags and include diff --git a/MANUAL.md b/MANUAL.md index d8641b9..b842f74 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -607,6 +607,12 @@ the property value from its enclosing directory. To make all targets in the proj ... set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") +### using cotire with Qt + +Cotire is compatible with both Qt4 and Qt5 projects that use CMake as build system. The `Patches` +directory contains examples for the [Qt4][fsedit_qt4] and [Qt5][fsedit_qt5] based variants of the +*FSEditor* sample Qt application. + cotire usage restrictions ------------------------- @@ -647,6 +653,8 @@ Cotire is not compatible with [Xoreax IncrediBuild][XGE]. [ccch]:http://ccache.samba.org/ [ccch_pch]:http://ccache.samba.org/manual.html#_precompiled_headers [clang_pch]:http://clang.llvm.org/docs/UsersManual.html#precompiledheaders +[fsedit_qt4]:http://www.vikingsoft.eu/fseditor.html +[fsedit_qt5]:https://github.com/joonhwan/fsedit-qt5 [gcc_pch]:http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html [kde4macros]:http://kbfxmenu.googlecode.com/svn/trunk/kbfx3/cmakemodules/KDE4Macros.cmake [msvc_pch]:http://msdn.microsoft.com/en-us/library/szfdksca(v=vs.90).aspx diff --git a/Patches/fsedit-qt5.patch b/Patches/fsedit-qt5.patch new file mode 100644 index 0000000..c76aeab --- /dev/null +++ b/Patches/fsedit-qt5.patch @@ -0,0 +1,74 @@ +diff -rupN fsedit-qt5-master/CMakeLists.txt fsedit-qt5-cotire/CMakeLists.txt +--- fsedit-qt5-master/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/CMakeLists.txt 2014-08-28 17:59:58.000000000 +0200 +@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8 FATAL + cmake_policy(SET CMP0020 NEW) + project(FSEditor) + ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") ++ + include(InstallRequiredSystemLibraries) + + set(VERSION_MAJOR 1) +diff -rupN fsedit-qt5-master/source/application/CMakeLists.txt fsedit-qt5-cotire/source/application/CMakeLists.txt +--- fsedit-qt5-master/source/application/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/application/CMakeLists.txt 2014-08-28 16:48:42.000000000 +0200 +@@ -20,3 +20,7 @@ install(TARGETS fseditor DESTINATION bin + + include(tr_sources) + add_tr_sources(${sources}) ++ ++if (COMMAND cotire) ++ cotire(fseditor) ++endif() +diff -rupN fsedit-qt5-master/source/libfstest/CMakeLists.txt fsedit-qt5-cotire/source/libfstest/CMakeLists.txt +--- fsedit-qt5-master/source/libfstest/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libfstest/CMakeLists.txt 2014-08-28 16:49:11.000000000 +0200 +@@ -3,8 +3,12 @@ + + add_library(fstest STATIC fstest.h fstest.cpp) + target_link_libraries(fstest +- Qt5::Widgets # ${QT_LIBRARIES} ++ Qt5::Widgets Qt5::Test # ${QT_LIBRARIES} + ) + set_target_properties(fstest + PROPERTIES PROJECT_LABEL "libfstest" + ) ++ ++if (COMMAND cotire) ++ cotire(fstest) ++endif() +diff -rupN fsedit-qt5-master/source/libmodel/CMakeLists.txt fsedit-qt5-cotire/source/libmodel/CMakeLists.txt +--- fsedit-qt5-master/source/libmodel/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libmodel/CMakeLists.txt 2014-08-28 16:49:18.000000000 +0200 +@@ -37,3 +37,7 @@ fstest(test_libmodel LibModel) + + include(tr_sources) + add_tr_sources(${sources} ${headers} ${moc_headers}) ++ ++if (COMMAND cotire) ++ cotire(model) ++endif() +diff -rupN fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt +--- fsedit-qt5-master/source/libmodelcommands/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libmodelcommands/CMakeLists.txt 2014-08-28 16:49:25.000000000 +0200 +@@ -21,3 +21,7 @@ target_link_libraries(modelcommands + + include(tr_sources) + add_tr_sources(${sources} ${headers}) ++ ++if (COMMAND cotire) ++ cotire(modelcommands) ++endif() +diff -rupN fsedit-qt5-master/source/libui/CMakeLists.txt fsedit-qt5-cotire/source/libui/CMakeLists.txt +--- fsedit-qt5-master/source/libui/CMakeLists.txt 2013-09-25 17:02:56.000000000 +0200 ++++ fsedit-qt5-cotire/source/libui/CMakeLists.txt 2014-08-28 12:03:28.000000000 +0200 +@@ -48,3 +48,7 @@ target_link_libraries(ui + + include(tr_sources) + add_tr_sources(${sources} ${headers} ${moc_headers} ${forms}) ++ ++if (COMMAND cotire) ++ cotire(ui) ++endif() diff --git a/Patches/fseditor-1.0.patch b/Patches/fseditor-1.0.patch new file mode 100644 index 0000000..32598b0 --- /dev/null +++ b/Patches/fseditor-1.0.patch @@ -0,0 +1,68 @@ +diff -rupN fseditor-1.0/CMakeLists.txt fseditor-1.0.cotire/CMakeLists.txt +--- fseditor-1.0/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/CMakeLists.txt 2014-08-28 18:28:39.000000000 +0200 +@@ -1,6 +1,9 @@ + CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + PROJECT(FSEditor) + ++include(cotire) ++set_property(DIRECTORY PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") ++ + INCLUDE(InstallRequiredSystemLibraries) + + SET(VERSION_MAJOR 1) +diff -rupN fseditor-1.0/source/application/CMakeLists.txt fseditor-1.0.cotire/source/application/CMakeLists.txt +--- fseditor-1.0/source/application/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/application/CMakeLists.txt 2014-08-28 18:24:56.000000000 +0200 +@@ -17,3 +17,7 @@ INSTALL(TARGETS fseditor DESTINATION bin + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources}) ++ ++if (COMMAND cotire) ++ cotire(fseditor) ++endif() +diff -rupN fseditor-1.0/source/libfstest/CMakeLists.txt fseditor-1.0.cotire/source/libfstest/CMakeLists.txt +--- fseditor-1.0/source/libfstest/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libfstest/CMakeLists.txt 2014-08-28 18:25:41.000000000 +0200 +@@ -3,3 +3,7 @@ INCLUDE(${QT_USE_FILE}) + + ADD_LIBRARY(fstest STATIC fstest.h fstest.cpp) + SET_TARGET_PROPERTIES(fstest PROPERTIES PROJECT_LABEL "libfstest") ++ ++if (COMMAND cotire) ++ cotire(fstest) ++endif() +diff -rupN fseditor-1.0/source/libmodel/CMakeLists.txt fseditor-1.0.cotire/source/libmodel/CMakeLists.txt +--- fseditor-1.0/source/libmodel/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libmodel/CMakeLists.txt 2013-10-06 20:05:06.000000000 +0200 +@@ -34,3 +34,7 @@ FSTEST(test_libmodel LibModel) + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers} ${moc_headers}) ++ ++if (COMMAND cotire) ++ cotire(model) ++endif() +diff -rupN fseditor-1.0/source/libmodelcommands/CMakeLists.txt fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt +--- fseditor-1.0/source/libmodelcommands/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libmodelcommands/CMakeLists.txt 2013-10-06 20:05:11.000000000 +0200 +@@ -18,3 +18,7 @@ TARGET_LINK_LIBRARIES(modelcommands mode + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers}) ++ ++if (COMMAND cotire) ++ cotire(modelcommands) ++endif() +diff -rupN fseditor-1.0/source/libui/CMakeLists.txt fseditor-1.0.cotire/source/libui/CMakeLists.txt +--- fseditor-1.0/source/libui/CMakeLists.txt 2010-10-01 07:43:16.000000000 +0200 ++++ fseditor-1.0.cotire/source/libui/CMakeLists.txt 2013-10-06 20:05:18.000000000 +0200 +@@ -44,3 +44,7 @@ TARGET_LINK_LIBRARIES(ui model modelcomm + + INCLUDE(tr_sources) + ADD_TR_SOURCES(${sources} ${headers} ${moc_headers} ${forms}) ++ ++if (COMMAND cotire) ++ cotire(ui) ++endif() diff --git a/README.md b/README.md index 7b43e09..69a67d2 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ known issues [vslstd]:http://msdn.microsoft.com/vstudio/ [xcdt]:http://developer.apple.com/tools/xcode/ [PCHH]:http://gcc.gnu.org/wiki/PCHHaters -[EoUB]:http://leewinder.co.uk/blog/?p=394 +[EoUB]:http://engineering-game-dev.com/2009/12/15/the-evils-of-unity-builds/ [jom]:http://qt-project.org/wiki/jom [intel]:http://software.intel.com/en-us/c-compilers [XGE]:http://www.incredibuild.com