<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_BUILD_TYPE is blank by default (the current attempt to set to Debug is broken)"
   href="https://llvm.org/bugs/show_bug.cgi?id=26666">26666</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CMAKE_BUILD_TYPE is blank by default (the current attempt to set to Debug is broken)
          </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>Linux
          </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>cmake
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When configuring with cmake, the code attempts to set CMAKE_BUILD_TYPE to Debug
if it is not explicitly set.  However, this is incorrectly done prior to the
project() command, which clears it out.  The result is that CMAKE_BUILD_TYPE is
blank, which leads to a strange build that is something in between Release and
Debug but is missing assertions and much debug info.

The page at <a href="http://llvm.org/docs/GettingStarted.html">http://llvm.org/docs/GettingStarted.html</a> says:
"-DCMAKE_BUILD_TYPE=type — Valid options for type are Debug, Release,
RelWithDebInfo, and MinSizeRel. Default is Debug."

References elsewhere also assume that CMAKE_BUILD_TYPE is never blank: e.g., in 
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - trivial (no options) CMake build fails"
   href="show_bug.cgi?id=23322">https://llvm.org/bugs/show_bug.cgi?id=23322</a>.

To reproduce, simply compare these two:

# cmake -DCMAKE_BUILD_TYPE=Debug <path-to-sources>
# cmake <path-to-sources>

Notice how only the former sets -D_DEBUG (look in the makefiles or build.ninja
for -GNinja) and enables LLVM_ENABLE_ASSERTIONS, while the latter enables 
"-Wl,-O3 -Wl,--gc-sections".  The former results in a 22GB build directory
(this is llvm + clang) while the latter is only 4.1GB.

It looks like the code that tries to set a default was added in
<a href="http://reviews.llvm.org/D7360">http://reviews.llvm.org/D7360</a> but I do not understand how it ever worked.  I
tested with cmake 2.8.10 as well as several other versions and it's always
blanked by project().

The fix is simple: move the current code that sets a blank type down below
project().  I will send a patch.</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>