Browse Source

CMake: Work around CMake issue 20206

Sam Edwards 6 years ago
parent
commit
28b85d2f58
2 changed files with 16 additions and 0 deletions
  1. 11 0
      cmake/macros/CompositeSources.cmake
  2. 5 0
      direct/src/showbase/CMakeLists.txt

+ 11 - 0
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()
 

+ 5 - 0
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