From 89693f6bcb860f22039dfeea570ad8f24a3b70f4 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Thu, 4 Mar 2021 20:03:05 +0100 Subject: BUILD(cmake): Exclude files from unity build The *_plugin_import files will cause collisions in a unity build, so we have to make sure that they are built separately as usual. Furthermore the ObjecticeC files don't play well in unity builds (it seems like they are then treated as cpp files). Thus they are excluded from that as well. WinGUID.cpp must also not be included as that breaks the DEFINE_GUID macro wizardry needed to avoid redefinition errors. --- cmake/qt-utils.cmake | 1 + src/mumble/CMakeLists.txt | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cmake/qt-utils.cmake b/cmake/qt-utils.cmake index 794cb8bdc..b1a15fd5e 100644 --- a/cmake/qt-utils.cmake +++ b/cmake/qt-utils.cmake @@ -8,6 +8,7 @@ function(include_qt_plugin TARGET SCOPE PLUGIN) if(NOT EXISTS ${PATH}) file(WRITE ${PATH} "#include \n") set_property(SOURCE ${PATH} PROPERTY GENERATED TRUE SKIP_AUTOGEN TRUE) + set_property(SOURCE ${PATH} PROPERTY SKIP_UNITY_BUILD_INCLUSION TRUE) else() file(READ ${PATH} CONTENT) string(FIND ${CONTENT} ${PLUGIN} INDEX) diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index 949dc6154..18f861cfd 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -402,6 +402,12 @@ if(WIN32) "${CMAKE_SOURCE_DIR}/overlay/ods.cpp" ) + # WinGUIDs.cpp includes initguid.h which causes a macro definition in guiddef.h to be + # chaged in such a way that subsequent usages break (redefinition errors). + # Thus we must not package this source file in a unity build allowing other files + # to include plain guiddef.h without having to worry about side-effects. + set_source_files_properties("WinGUIDs.cpp" PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE) + find_pkg(Boost COMPONENTS system @@ -983,3 +989,18 @@ if(wasapi) set_property(TARGET mumble APPEND_STRING PROPERTY LINK_FLAGS " /DELAYLOAD:avrt.dll") endif() endif() + +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0" AND APPLE) + # Prevent objective C files from being included in unity builds as that causes issues + set_source_files_properties( + "AppNap.mm" + "GlobalShortcut_macx.mm" + "Log_macx.mm" + "os_macx.mm" + "TextToSpeech_macx.mm" + "Overlay_macx.mm" + "CoreAudio.mm" + PROPERTIES + SKIP_UNITY_BUILD_INCLUSION TRUE + ) +endif() -- cgit v1.2.3