<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 3.3 warns when multiple custom commands use the same MAIN_DEPENDENCY source file" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23595&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=disUrZRtovUPSyPZZJgRdjzpaAV-mTiKyWjiYzW6BEM&s=2Gbq8V3JL9nxuSOvubFjMSwk14YTkehrYKb14xDc1IU&e=">23595</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CMake 3.3 warns when multiple custom commands use the same MAIN_DEPENDENCY source file
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>brad.king@kitware.com, kcc@google.com, kuba.brecka@gmail.com, llvmbugs@cs.uiuc.edu, samsonov@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is the text of the warning:

CMake Warning (dev) at
projects/compiler-rt/cmake/Modules/CompilerRTCompile.cmake:58
(add_custom_command):
  Policy CMP0057 is not set: Disallow multiple MAIN_DEPENDENCY specifications
  for the same file.  Run "cmake --help-policy CMP0057" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  "D:/src/llvm/utils/unittest/googletest/src/gtest-all.cc" can only be
  specified as a custom command MAIN_DEPENDENCY once.
Call Stack (most recent call first):
  projects/compiler-rt/lib/asan/tests/CMakeLists.txt:122 (clang_compile)
  projects/compiler-rt/lib/asan/tests/CMakeLists.txt:253 (asan_compile)
  projects/compiler-rt/lib/asan/tests/CMakeLists.txt:265
(add_asan_tests_for_arch_and_kind)
This warning is for project developers.  Use -Wno-dev to suppress it.

I ran `cmake --help-policy CMP0057` as suggested and got this:
  $ cmake --help-policy CMP0057
  CMP0057
  -------

  Disallow multiple ``MAIN_DEPENDENCY`` specifications for the same file.

  CMake 3.3 and above no longer allow the same input file to be used
  as a ``MAIN_DEPENDENCY`` in more than one custom command.

  Listing the same input file more than once in this context has not been
  supported by earlier versions either and would lead to build time issues
  but was not diagnosed.

  The ``OLD`` behavior for this policy is to allow using the same input file
  in a ``MAIN_DEPENDENCY`` specfication more than once.
  The ``NEW`` behavior is to disallow using the same input file in a
  ``MAIN_DEPENDENCY`` specification more than once.

  This policy was introduced in CMake version 3.3.
  CMake version 3.2.20150318 warns when the policy is not set and uses
  ``OLD`` behavior.  Use the ``cmake_policy()`` command to set
  it to ``OLD`` or ``NEW`` explicitly.

The problem is that we actually do want to compile the same source file
multiple times in different configurations. Using cmake_policy(CMP0057 OLD)
would work, but I assume it would leave some IDE project generators (VS and
XCode) in a broken state. Maybe we don't care about VS, but Apple might want to
be able to test ASan from XCode.

I'm going to commit the policy and leave this bug open for people to decide
what to do.</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>