<div dir="ltr">I've overcome this by using the COMPILE_FLAGS source file property <a href="http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_sf:COMPILE_FLAGS">http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_sf:COMPILE_FLAGS</a><div>

<br></div><div>Those flags will be appended to the rest of the compiler flags, so you can make them override the debug flags. For instance, if your debug flags are "-UNDEBUG -DDEBUG -O1", you can set the COMPILE_FLAGS to "-DNDEBUG -UDEBUG -O3" and (in my experience with GCC and Clang) the compiler will prefer the latter flags.</div>

<div><br></div><div>Cheers,<br>Jack</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 6, 2014 at 8:13 AM, <a href="mailto:sindimo@gmail.com">sindimo@gmail.com</a> <span dir="ltr"><<a href="mailto:sindimo@gmail.com" target="_blank">sindimo@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal">Dear All,</p>
<p class="MsoNormal">We currently have  a FORTRAN library we’re building with CMake (around 1000 files of FORTRAN).</p>
<p class="MsoNormal">ADD_LIBRARY(<u></u><u></u></p>
<p class="MsoNormal">My_Fortran_Lib<u></u><u></u></p>
<p class="MsoNormal">…….<u></u><u></u></p>
<p class="MsoNormal">)</p>
<p class="MsoNormal">For the release build we set the release compilation flags with “CMAKE_Fortran_FLAGS_RELEASE” and set “CMAKE_BUILD_TYPE” to “Release” for those flags to be honored.</p>
<p class="MsoNormal">For the debug build we set the debug compilation flags with “CMAKE_Fortran_FLAGS_DEBUG” and set “CMAKE_BUILD_TYPE” to “Debug” for those flags to be honored.</p>
<p class="MsoNormal">Out of those 1000 files we have a subset that we want to build always in “Release” mode while the rest of the files can be built either in Debug or Release depending on what “CMAKE_BUILD_TYPE” is set to.</p>



<p class="MsoNormal">Is there a way to tell CMake to build a specific subset of files always with Release flags even if “CMAKE_BUILD_TYPE” was Debug?</p>
<p class="MsoNormal">Thank you for your help.</p>
<p class="MsoNormal"><b><span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#3366ff">Mohamad O. Sindi</span></b><span style="color:blue"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#3366ff">EXPEC Advanced Research Center</span></p><p class="MsoNormal"><span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#3366ff"></span><span style="color:rgb(51,102,255);font-family:Arial,sans-serif;font-size:7.5pt">Saudi Aramco</span></p>


<p class="MsoNormal"><u></u></p></div>
</div>

<br>
<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>