<div dir="ltr"><div>Hi Miller,</div><div><br></div>You could add a check in your application's top-level CMakeLists.txt like the following:<div><br></div><div><font face="courier new, monospace">```</font></div><div><font face="courier new, monospace">set(ACCEPTED_BUILD_TYPES Release Debug RelWithDebInfo)</font></div>

<div><font face="courier new, monospace">list(FIND ACCEPTED_BUILD_TYPES ${CMAKE_BUILD_TYPE} IS_BUILD_TYPE_ACCEPTED)</font></div><div><font face="courier new, monospace">if(${IS_BUILD_TYPE_ACCEPTED} EQUAL -1)</font></div>
<div>
<font face="courier new, monospace">  message(FATAL_ERROR "CMAKE_BUILD_TYPE of ${CMAKE_BUILD_TYPE} is not accepted.")</font></div><div><font face="courier new, monospace">endif()</font></div><div><font face="courier new, monospace">```</font></div>

<div><br></div><div>You might want to uppercase the accepted list and ${CMAKE_BUILD_TYPE} to be flexible to different cases.</div><div><br></div><div>Cheers,<br>Jack<br><div><br></div><div><br></div></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 11:04 AM, Miller Henry <span dir="ltr"><<a href="mailto:MillerHenry@johndeere.com" target="_blank">MillerHenry@johndeere.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">








<div>
<font face="Calibri"><span style="font-size:11pt">
<div>One of my co-workers just did a build where they ran cmake with the option –DCMAKE_BUILD_TYPE=RelWithDebugInfo  Of course what was obviously meant was RelWithDbgInfo.  Because of this incorrect option the build was not as expected, but it took a while
to figure out why it failed.  Of course once we realize the problem it is obvious that they expected to build with optimizations, but instead they build with no optimizations. Is there some way to make cmake abort when the option is not recognized?  I realize
I could add any build type, but in this case it doesn’t make sense.</div>
<div> </div>
<div>The reason the build failed was at some point we have a test that is something like this:</div>
<div>        #ifdef DEBUG</div>
<div>                EXPECT_FLOAT_EQ(7.47869, value);</div>
<div>        #else</div>
<div>                EXPECT_FLOAT_EQ(6.19632, value);</div>
<div>        #endif</div>
<div> </div>
<div>The code under test was written about 10 years before we even heard of tests, and we have years of real world use that shows it works.  Since the algorithms are complex in the typical ways of legacy code: nobody has figured out what is going on that compiler
optimizations can change a floating point value by this much.  This test is just a characterization of current behavior so we don’t accidentally break it if we have to touch it.</div>
<div> </div>
<div>I’m also investigating if I can something different in the preprocessor to get the information I need, but this is outside the scope of cmake, and it seems that cmake should warn me if my build type option is set to something that isn’t valid.</div>


<div> </div>
</span></font>
</div>

<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</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>
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></div>