MantisBT - CMake
View Issue Details
0010494CMakeCMakepublic2010-03-31 09:362011-04-04 12:00
Elizabeta 
David Cole 
normalmajoralways
closedfixed 
CMake-2-8 
CMake 2.8.4CMake 2.8.3 
0010494: Can not use ${CMAKE_CFG_INTDIR} as output in add_custom_command of VS 2010 generator
I am using Cmake 2.8.1. and VS2010 generator

If I use the following code, the command is executed every time I build my solution, although the input file ( myfile.txt ) is not changed.

set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Foo.txt")

add_custom_command(OUTPUT "${outfile}"
 COMMAND echo Foo > "${outfile}"
 DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myfile.txt"
 )
add_custom_target(Foo DEPENDS "${outfile}")

I came to conclusion that this is because foo.txt.rule is not generated by cmake on disk.

If I set outfile to the following :

set(outfile "Foo.txt")

then everything works as it should. That is because in this case foo.txt.rule is made by cmake on the disk.

With Visual Studio 2005 generator both examples work as it should, cause VS2005 does not require foo.txt.rule to exist on disk ( actually cmake vs2005 generator does not make such file on disk ).


No tags attached.
txt cmakelists.txt (495) 2010-03-31 09:36
https://public.kitware.com/Bug/file/3001/cmakelists.txt
Issue History
2010-03-31 09:36ElizabetaNew Issue
2010-03-31 09:36ElizabetaFile Added: cmakelists.txt
2010-12-14 16:32David ColeStatusnew => assigned
2010-12-14 16:32David ColeAssigned To => David Cole
2010-12-17 07:41David ColeTarget Version => CMake 2.8.4
2010-12-17 18:21David ColeNote Added: 0024257
2010-12-17 18:21David ColeStatusassigned => resolved
2010-12-17 18:21David ColeFixed in Version => CMake 2.8.3
2010-12-17 18:21David ColeResolutionopen => fixed
2011-04-04 12:00David ColeNote Added: 0026075
2011-04-04 12:00David ColeStatusresolved => closed

Notes
(0024257)
David Cole   
2010-12-17 18:21   
This appears to be fixed in CMake 2.8.3.

Try using 2.8.3 -- please re-open this issue and attach further details if you still have problems.

One thing I noticed while reproducing this issue is that you do not include the custom target in "ALL" - so something has to depend on the target in order to get the build rules to execute. If nothing depends on it, and nothing explicitly builds the custom target, then your build rules will not execute as part of a "Build Solution" operation in Visual Studio. (Just an FYI...)

I'm guessing you do have something that depends on it, or you simply omitted the ALL when reporting the bug...

Let me know if you need further help, but I think this one is fixed.
(0026075)
David Cole   
2011-04-04 12:00   
Closing resolved issues that have not been updated in more than 3 months.