From: Jordan Rose Date: Fri, 4 Oct 2019 18:17:58 +0000 (+0000) Subject: [CMake] Clang: Don't use object libraries with Xcode X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fd467feb813e9999efe3558da434cb038213582;p=platform%2Fupstream%2Fllvm.git [CMake] Clang: Don't use object libraries with Xcode Undoes some of the effects of r360946 when using the Xcode CMake generator---it doesn't handle object libraries correctly at all. Attempts to still honor BUILD_SHARED_LIBS for Xcode, but I didn't actually test it. Should have no effect on non-Xcode generators. https://reviews.llvm.org/D68430 llvm-svn: 373769 --- diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index cbd618e..5a1b5cd 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -86,9 +86,13 @@ macro(add_clang_library name) # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set, # so we need to handle it here. if(BUILD_SHARED_LIBS) - set(LIBTYPE SHARED OBJECT) + set(LIBTYPE SHARED) else() - set(LIBTYPE STATIC OBJECT) + set(LIBTYPE STATIC) + endif() + if(NOT XCODE) + # The Xcode generator doesn't handle object libraries correctly. + list(APPEND LIBTYPE OBJECT) endif() set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name}) endif() diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index 4e9e8c1..a0fc8f6 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -6,7 +6,13 @@ endif() get_property(clang_libs GLOBAL PROPERTY CLANG_STATIC_LIBS) foreach (lib ${clang_libs}) - list(APPEND _OBJECTS $) + if(XCODE) + # Xcode doesn't support object libraries, so we have to trick it into + # linking the static libraries instead. + list(APPEND _DEPS "-force_load" ${lib}) + else() + list(APPEND _OBJECTS $) + endif() list(APPEND _DEPS $) list(APPEND _DEPS $) endforeach ()