<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - cmake with BUILD_SHARED_LIBS / LLVM_BUILD_LLVM_DYLIB gives an error"
   href="https://bugs.llvm.org/show_bug.cgi?id=39530">39530</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>cmake with BUILD_SHARED_LIBS / LLVM_BUILD_LLVM_DYLIB gives an error
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Build scripts
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>cmake
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jsshin@sor.snu.ac.kr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21068" name="attach_21068" title="cmake error output">attachment 21068</a> <a href="attachment.cgi?id=21068&action=edit" title="cmake error output">[details]</a></span>
cmake error output

cmake -DCMAKE_BUILD_TYPE="Debug" -DLLVM_TARGETS_TO_BUILD="host;ARM"
-DLLVM_PARALLEL_COMPILE_JOBS="6" -DLLVM_PARALLEL_LINK_JOBS="1" 
-DLLVM_OPTIMIZED_TABLEGEN="ON"          -DLLVM_BINUTILS_INCDIR=/usr/include 
-DLLVM_BUILD_LLVM_DYLIB=ON   -GNinja ../llvm

complains as follows:

CMake Error at tools/llvm-shlib/CMakeLists.txt:44 (list):
  list sub-command REMOVE_DUPLICATES requires list to be present. 

Googling the problem, I found that the following solution works.

diff --git a/tools/llvm-shlib/CMakeLists.txt b/tools/llvm-shlib/CMakeLists.txt
index 187066e..23e768c 100644
--- a/tools/llvm-shlib/CMakeLists.txt
+++ b/tools/llvm-shlib/CMakeLists.txt
@@ -41,7 +41,9 @@ if(LLVM_BUILD_LLVM_DYLIB)

   add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})

-  list(REMOVE_DUPLICATES LIB_NAMES)
+  if(LIB_NAMES)
+    list(REMOVE_DUPLICATES LIB_NAMES)
+  endif()
   if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
      OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
      OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>