I discovered at least for a custom command that ${CMAKE_CFG_INTDIR} expanded to $(OutDir) not $(IntDir). Interestingly enough $(OutDir) was "Debug" and $(IntDir) was "project.dir/Debug". At any rate, I think what I wanted was this:<br>
<br><span style="font-family: courier new,monospace;"> # Figure out which configure we will use and pass that in as an argument to</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> # the script. We need to defer the decision until compilation time, because</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> # for VS projects we won't know if we are making a debug or release build</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> # until build time.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if(CMAKE_GENERATOR MATCHES "Visual Studio")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> set( MY_build_configuration "$(ConfigurationName)" )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> else()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> set( MY_build_configuration "${CMAKE_BUILD_TYPE}")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> endif()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> add_custom_command(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> OUTPUT ${generated_file}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> COMMAND ${CMAKE_COMMAND} ARGS</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> -D build_configuration:STRING=${MY_build_configuration}</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> -P "${custom_target_script}"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> )</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">James<br style="font-family: courier new,monospace;"><br><div class="gmail_quote">On Fri, May 15, 2009 at 4:51 AM, David Cole <span dir="ltr"><<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you use "${CMAKE_CFG_INTDIR}" in a custom command it should show up as $(Config) in the generated VS vcproj files...<div>
<br></div><div>Does this do what you want?<div class="im"><br>add_custom_command(${OUTPUT_FILE}<br></div> COMMAND ${CMAKE_COMMAND} ARGS -DCONFIG:STRING=${CMAKE_CFG_INTDIR} -P "${my_custom_script}"<br>
)<br><div class="gmail_quote"><br></div><div class="gmail_quote">For makefile based systems, ${CMAKE_CFG_INTDIR} should evaluate to "." -- you should be able to use that as a per-configuration directory name in path expressions.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">HTH,</div><div class="gmail_quote">David</div><font color="#888888"><div class="gmail_quote"><br></div><div class="gmail_quote">
<br></div></font><div class="gmail_quote"><div><div></div><div class="h5">
On Thu, May 14, 2009 at 5:59 PM, James Bigler <span dir="ltr"><<a href="mailto:jamesbigler@gmail.com" target="_blank">jamesbigler@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">
Is there a configuration environment variable for VS that I could use to change the behavior of an add_custom_command based on whether I'm building a debug or release build?<br><br>I want something like this:<br><br>
add_custom_command(${OUTPUT_FILE}<br>
COMMAND ${CMAKE_COMMAND} ARGS "$(Config)" -P "${my_custom_script}"<br> )<br><br>Thanks,<br><font color="#888888">James<br>
</font><br></div></div><div class="im">_______________________________________________<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></blockquote></div><br></div>
</blockquote></div><br>