<div>Hi Eric, </div><div><br></div>Considering the fact Visual Studio is a multi-configuration system, I don&#39;t think using &quot;<span>CMAKE_BUILD_TYPE&quot; is what you want. Indeed, in such case, the build type is know at build time only. See [1]</span><div>


<font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">Hth</font></div><div><font color="#222222" face="arial, sans-serif">Jc</font></div><div><font color="#222222" face="arial, sans-serif"><br>


</font></div><div><font color="#222222" face="arial, sans-serif">[1] </font><a href="http://www.cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_CFG_INTDIR" target="_blank">http://www.cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_CFG_INTDIR</a><font color="#222222" face="arial, sans-serif"><br>


</font><div><font color="#222222" face="arial, sans-serif"><br></font><br><div class="gmail_quote">On Mon, May 14, 2012 at 11:16 AM, pellegrini <span dir="ltr">&lt;<a href="mailto:pellegrini@ill.fr" target="_blank">pellegrini@ill.fr</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div>
    On 5/11/2012 5:30 PM, Jean-Christophe Fillion-Robin wrote:
    </div><div><div><blockquote type="cite">Hi Eric, 
      <div><br>
      </div>
      <div>In our different projects, we use an approach similar to this
        one:</div>
      <div><br>
      </div>
      <div>
        <pre style="word-wrap:break-word;white-space:pre-wrap"># Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS &quot;Setting build type to &#39;Debug&#39; as none was specified.&quot;)
  set(CMAKE_BUILD_TYPE Debug CACHE STRING &quot;Choose the type of build.&quot; FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS &quot;Debug&quot; &quot;Release&quot;
    &quot;MinSizeRel&quot; &quot;RelWithDebInfo&quot;)
endif()</pre>
      </div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>See <a href="http://vtk.org/gitweb?p=VTK.git;a=blob;f=CMakeLists.txt;h=a57fd66ef333fc26bf74fe658c88c3c634f54c3a;hb=HEAD#l12" target="_blank">http://vtk.org/gitweb?p=VTK.git;a=blob;f=CMakeLists.txt;h=a57fd66ef333fc26bf74fe658c88c3c634f54c3a;hb=HEAD#l12</a></div>



      <div><br>
        <br>
        Hth</div>
      <div>Jc</div>
      <div><br>
        <div class="gmail_quote">On Fri, May 11, 2012 at 11:21 AM,
          pellegrini <span dir="ltr">&lt;<a href="mailto:pellegrini@ill.fr" target="_blank">pellegrini@ill.fr</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
            <br>
            when cmake is run without specifying the build type using -D
            CMAKE_BUILD_TYPE, it is the Debug mode that is selected as<br>
            the default. I would like to find a way to use Release as
            the default value when the user does not specify any build<br>
            type in the cmake command line.<br>
            <br>
            From one of my previous post concerning CMAKE_INSTALL_PREFIX
            variable, I was thinking to use a similar approach i.e.:<br>
            <br>
            project(Foo)<br>
            <br>
            if (CMAKE_BUILD_TYPE_INITIALIZED_TO_DEFAULT)<br>
               set(CMAKE_BUILD_TYPE Release)<br>
            endif<br>
            <br>
            but cmake still sets CMAKE_BUILD_TYPE to Debug in the
            CMakeCache.txt file.<br>
            <br>
            Would you have any idea about what is wrong with my
            implementation ?<br>
            <br>
            thanks a lot.<br>
            <br>
            Eric<br>
            --<br>
            <br>
            Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
            <br>
            Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
            <br>
            Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
            <br>
            Follow this link to subscribe/unsubscribe:<br>
            <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <a href="tel:%2B1%20919%20869%208849" value="+19198698849" target="_blank">+1 919 869 8849</a><br>
        <br>
      </div>
    </blockquote></div></div>
    Hi Jean-Christophe,<br>
    <br>
    I found a hack for my problem. First it seems to be a windows
    specific problem (I found one other message that <br>
    mention this).<br>
    <br>
    What I did is just to put the following before (compulsory) the
    project declaration:<br>
    <br>
    if (NOT DEFINED CMAKE_BUILD_TYPE)<br>
        set(CMAKE_BUILD_TYPE CACHE Release STRING &quot;hfsfhskj&quot; FORCE)<br>
    endif()<br>
    <br>
    It would be interesting to get the feedback of the CMake team about
    the &quot;uglyness&quot; of such a hack.<br>
    <br>
    Bye<br>
    <br>
    Eric<br>
  </div>

</blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="tel:%2B1%20919%20869%208849" value="+19198698849" target="_blank">+1 919 869 8849</a><br><br>
</div></div>