Is it a bug that project() does not append to the user-specified configurations? Sure seems like one...<br clear="all"><div><br></div><div>---------</div>Robert Dailey<br>
<br><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 4:52 PM, Michael Hertling <span dir="ltr"><<a href="mailto:mhertling@online.de">mhertling@online.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 01/13/2012 05:06 PM, David Cole wrote:<br>
> On Fri, Jan 13, 2012 at 10:22 AM, Michael Hertling <<a href="mailto:mhertling@online.de">mhertling@online.de</a>> wrote:<br>
>> On 01/12/2012 10:23 PM, Robert Dailey wrote:<br>
>>> I see there is documentation for this but it doesn't have an implementation<br>
>>> for VS generators:<br>
>>> <a href="http://www.cmake.org/Bug/view.php?id=5811" target="_blank">http://www.cmake.org/Bug/view.php?id=5811</a><br>
>>><br>
>>> Any status updates on this bug? I'd like to be able to create my own debug<br>
>>> configuration called DebugStatic that uses the /MTd flag in all projects to<br>
>>> link statically against the Microsoft libraries such as CRT.<br>
>>><br>
>>> Any help?<br>
>><br>
>> Look at the following exemplary project:<br>
>><br>
>> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>
>> PROJECT(P C)<br>
>> SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} DebugStatic<br>
>> CACHE STRING "" FORCE)<br>
>> SET(CMAKE_C_FLAGS_DEBUGSTATIC "/MTd"<br>
>> CACHE STRING "" FORCE)<br>
>> SET(CMAKE_EXE_LINKER_FLAGS_DEBUGSTATIC ""<br>
>> CACHE STRING "" FORCE)<br>
>> FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")<br>
>> ADD_EXECUTABLE(main main.c)<br>
>><br>
>> After "cmake <srcdir>" and a subsequent "cmake ." from within the build<br>
>> directory, I can see the DebugStatic configuration appear in the VS IDE<br>
>> when the generated solution is opened. Is this what you intend?<br>
>><br>
>> However, I do not see DebugStatic when I open the solution right after<br>
>> the initial configuration, i.e. without the reconfiguration step. Can<br>
>> you confirm this behavior? Does anybody know why the reconfiguration<br>
>> is necessary to make the custom configuration appear? This is with<br>
>> CMake 2.8.7 and VS 2008.<br>
>><br>
>> Regards,<br>
>><br>
>> Michael<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>
><br>
> I don't know why it doesn't appear straight away, (although I suspect<br>
> it's because the variable is set after the project command)<br>
<br>
</div></div>Yes, that's it; placing the SET() command for CMAKE_CONFIGURATION_TYPES<br>
before PROJECT() makes the new configuration appear at once, but it is<br>
*solely* the new one. Apparently, CMake's standard configurations are<br>
defined by PROJECT() only if there aren't already any configurations<br>
in the cache. A working alternative is to drop the language(s) from<br>
PROJECT(), augment the list of configurations thereafter and use<br>
ENABLE_LANGUAGE() finally, i.e.:<br>
<br>
PROJECT(XYZ) # <-- No language(s) here!<br>
LIST(APPEND CMAKE_CONFIGURATION_TYPES ...)<br>
LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)<br>
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES}<br>
CACHE STRING "CMake configuration types" FORCE)<br>
ENABLE_LANGUAGE(C)<br>
<div class="im"><br>
> But you should never do this unconditionally:<br>
><br>
> SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} DebugStatic<br>
> CACHE STRING "" FORCE)<br>
><br>
> That will simply continuously append to the variable in the cache, and<br>
> it will grow on each subsequent configure in the same build tree...<br>
> Real code should check whether DebugStatic is in there already, and<br>
> avoiding appending if already present.<br>
<br>
</div>Uhhh... absolutely, bad mistake! Thanks for pointing this out.<br>
<div class="HOEnZb"><div class="h5"><br>
Regards,<br>
<br>
Michael<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>
</div></div></blockquote></div><br>