Skip to content

Commit

Permalink
[CMake] Fix Xcode build with LLVM_ENABLE_OBJLIB.
Browse files Browse the repository at this point in the history
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 $<TARGET_OBJECTS:objlib>.

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
  • Loading branch information
jrose-apple committed Sep 10, 2015
1 parent 40b623b commit a72d302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/dummy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typedef int dummy;
6 changes: 6 additions & 0 deletions cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a72d302

Please sign in to comment.