From 28b85d2f58f1b2cd5730a461b031ecf84510358a Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 10 Jan 2020 14:17:59 -0700 Subject: [PATCH] CMake: Work around CMake issue 20206 --- cmake/macros/CompositeSources.cmake | 11 +++++++++++ direct/src/showbase/CMakeLists.txt | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/cmake/macros/CompositeSources.cmake b/cmake/macros/CompositeSources.cmake index a624cebfb6..82decc5400 100644 --- a/cmake/macros/CompositeSources.cmake +++ b/cmake/macros/CompositeSources.cmake @@ -37,6 +37,17 @@ set(COMPOSITE_GENERATOR "${CMAKE_SOURCE_DIR}/cmake/scripts/MakeComposite.cmake") function(composite_sources target sources_var) if(NOT CMAKE_VERSION VERSION_LESS "3.16") # CMake 3.16+ implements CMAKE_UNITY_BUILD* natively; no need to continue! + + # Actually - <=3.16.2 has difficulty with multi-language support, so only + # allow .cxx in. Hopefully this can be removed soon. + foreach(_source ${${sources_var}}) + get_filename_component(_source_ext "${_source}" EXT) + if(NOT _source_ext STREQUAL ".cxx") + set_source_files_properties(${_source} PROPERTIES + SKIP_UNITY_BUILD_INCLUSION YES) + endif() + endforeach(_source) + return() endif() diff --git a/direct/src/showbase/CMakeLists.txt b/direct/src/showbase/CMakeLists.txt index 815aeb5bc2..a45fa14b4b 100644 --- a/direct/src/showbase/CMakeLists.txt +++ b/direct/src/showbase/CMakeLists.txt @@ -8,6 +8,11 @@ set(P3SHOWBASE_SOURCES if(APPLE) list(APPEND P3SHOWBASE_SOURCES showBase_assist.mm) + + # Bug in CMake 3.16.2: it tries to put .mm with the .cxx + set_source_files_properties(showBase_assist.mm PROPERTIES + SKIP_UNITY_BUILD_INCLUSION YES) + endif() add_component_library(p3showbase NOINIT SYMBOL BUILDING_DIRECT_SHOWBASE