From a72d30255633edff3a3c5f1e9175be87e15045a6 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 10 Sep 2015 17:18:51 +0000 Subject: [PATCH] [CMake] Fix Xcode build with LLVM_ENABLE_OBJLIB. This amends chapuni's r246156 to handle an Xcode quirk, one even called out in the CMake documentation: Some native build systems may not like targets that have only object files, so consider adding at least one real source file to any target that references $. I've limited the scope of this hack to Xcode for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247305 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/dummy.cpp | 1 + cmake/modules/AddLLVM.cmake | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 cmake/dummy.cpp diff --git a/cmake/dummy.cpp b/cmake/dummy.cpp new file mode 100644 index 00000000000..c4e7e953687 --- /dev/null +++ b/cmake/dummy.cpp @@ -0,0 +1 @@ +typedef int dummy; diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 840a860b016..8ec6311c3bf 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -590,6 +590,12 @@ macro(add_llvm_executable name) add_windows_version_resource_file(ALL_FILES ${ALL_FILES}) + if(XCODE) + # Note: the dummy.cpp source file provides no definitions. However, + # it forces Xcode to properly link the static library. + list(APPEND ALL_FILES "${LLVM_SOURCE_DIR}/cmake/dummy.cpp") + endif() + if( EXCLUDE_FROM_ALL ) add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES}) else()