diff options
| author | Chris Bieneman <chris.bieneman@me.com> | 2019-07-08 18:29:29 +0000 |
|---|---|---|
| committer | Chris Bieneman <chris.bieneman@me.com> | 2019-07-08 18:29:29 +0000 |
| commit | 7023bdc46fbbd7f5c4f458488497888f767cd2e0 (patch) | |
| tree | fe8f3dd2cdcb0233d5a60f928cc7e19a2d1096ce | |
| parent | b324c64b6d4c807c44d2aba4b408dd573b850f1b (diff) | |
| download | bcm5719-llvm-7023bdc46fbbd7f5c4f458488497888f767cd2e0.tar.gz bcm5719-llvm-7023bdc46fbbd7f5c4f458488497888f767cd2e0.zip | |
Fix issues building libraries as more than one type with Xcode
Summary:
CMake+Xcode doesn't seem to handle targets that only have object
sources. This patch works around that limitation by adding a dummy
soruce file to any library target that is generated by llvm_add_library
when object libraries are generated.
Object libraries are generated whenever llvm_add_library is passed more
than one library type, which is now the default case for clang static
libraries (which generate STATIC and OBJECT libraries).
Reviewers: zturner, compnerd, joanlluch
Reviewed By: joanlluch
Subscribers: joanlluch, xbolva00, mgorny, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64300
llvm-svn: 365365
| -rw-r--r-- | llvm/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | llvm/cmake/modules/AddLLVM.cmake | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 041c847fd1a..1b5a6b9de98 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -40,6 +40,12 @@ if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQ "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) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index fc69cdfa430..d2ba017e3dd 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -433,7 +433,12 @@ function(llvm_add_library name) ${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}) |

