[PATCH] D64300: Fix issues building libraries as more than one type with Xcode

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 11:30:03 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365365: Fix issues building libraries as more than one type with Xcode (authored by cbieneman, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64300?vs=208301&id=208466#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64300/new/

https://reviews.llvm.org/D64300

Files:
  llvm/trunk/CMakeLists.txt
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/CMakeLists.txt
===================================================================
--- llvm/trunk/CMakeLists.txt
+++ llvm/trunk/CMakeLists.txt
@@ -40,6 +40,12 @@
                   "host compiler, pass -Thost=x64 on the CMake command line.")
 endif()
 
+if (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT CMAKE_OSX_ARCHITECTURES)
+  # Some CMake features like object libraries get confused if you don't
+  # explicitly specify an architecture setting with the Xcode generator.
+  set(CMAKE_OSX_ARCHITECTURES "x86_64")
+endif()
+
 project(LLVM
   VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
   LANGUAGES C CXX ASM)
Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -433,7 +433,12 @@
       ${ALL_FILES}
       )
     llvm_update_compile_flags(${obj_name})
-    set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>")
+    if(CMAKE_GENERATOR STREQUAL "Xcode")
+      set(DUMMY_FILE ${CMAKE_CURRENT_BINARY_DIR}/Dummy.c)
+      file(WRITE ${DUMMY_FILE} "// This file intentionally empty\n")
+      set_property(SOURCE ${DUMMY_FILE} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-empty-translation-unit")
+    endif()
+    set(ALL_FILES "$<TARGET_OBJECTS:${obj_name}>" ${DUMMY_FILE})
 
     # Do add_dependencies(obj) later due to CMake issue 14747.
     list(APPEND objlibs ${obj_name})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64300.208466.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190708/c1b93246/attachment.bin>


More information about the llvm-commits mailing list