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:
# Figure out which configure we will use and pass that in as an argument
to
# the script. We need to defer the decision until compilation time,
because
# for VS projects we won't know if we are making a debug or release build
# until build time.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set( MY_build_configuration "$(ConfigurationName)" )
else()
set( MY_build_configuration "${CMAKE_BUILD_TYPE}")
endif()
add_custom_command(
OUTPUT ${generated_file}
COMMAND ${CMAKE_COMMAND} ARGS
-D build_configuration:STRING=${MY_build_configuration}
-P "${custom_target_script}"
)
James
On Fri, May 15, 2009 at 4:51 AM, David Cole <[email protected]> wrote:
> If you use "${CMAKE_CFG_INTDIR}" in a custom command it should show up as
> $(Config) in the generated VS vcproj files...
> Does this do what you want?
> add_custom_command(${OUTPUT_FILE}
> COMMAND ${CMAKE_COMMAND} ARGS -DCONFIG:STRING=${CMAKE_CFG_INTDIR} -P
> "${my_custom_script}"
> )
>
> 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.
>
>
> HTH,
> David
>
>
> On Thu, May 14, 2009 at 5:59 PM, James Bigler <[email protected]>wrote:
>
>> 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?
>>
>> I want something like this:
>>
>> add_custom_command(${OUTPUT_FILE}
>> COMMAND ${CMAKE_COMMAND} ARGS "$(Config)" -P "${my_custom_script}"
>> )
>>
>> Thanks,
>> James
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake