[cmake-developers] [CMake 0012302]: Unable to use CMAKE_CFG_OUTDIR in the OUTPUT of a CUSTOM_COMMAND

Mantis Bug Tracker mantis at public.kitware.com
Fri Jun 24 10:46:09 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=12302 
====================================================================== 
Reported By:                Adam Clements
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12302
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-06-24 10:46 EDT
Last Modified:              2011-06-24 10:46 EDT
====================================================================== 
Summary:                    Unable to use CMAKE_CFG_OUTDIR in the OUTPUT of a
CUSTOM_COMMAND
Description: 
I have a custom command step in my build process that copies non-source
resources (xml schemas) from my source to my build tree if they have been
updated. For this I have a custom command which OUTPUTs the file in the binary
directory and DEPENDs on the file in the source tree. The COMMAND then copies
from the source to the binary tree and COMMENTs which file has changed and is
being updated (so that I can keep track in my build status).

This works fine until I try and make it copy into the configuration specific
build directories. I initially tried using $(ConfigurationName) in the path,
then found ${CMAKE_CFG_INTDIR}, but while that copies the right files to the
right places, it doesn't seem to keep track of the OUTPUT file, and so the copy
step happens every time (as opposed to before when it only activated when the
file had changed).

If I don't specify the directory using ${CMAKE_CFG_INTDIR} then the file is
output to the base of the binary tree, rather than in the configuration as I
originally expected.

Steps to Reproduce: 
# Here's a simplified version of my build script (pulling some things out of
macros
# for clarity)

#...

Add_Executable(MainExecutable ${SOURCES})

#...

# Working example - only copies when the file is changed, but is 
# configuration specific
Set ( DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/foo.xsd )
Add_Custom_Command(
  OUTPUT ${DESTINATION}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different foo.xsd ${DESTINATION}
  DEPENDS foo.xsd
  COMMENT "Updating foo.xsd ..." )
		
Set (POST_BUILD_OUTPUT_DEPS ${POST_BUILD_OUTPUT_DEPS} ${DESTINATION})

# What I tried originally, expecting ${CMAKE_CURRENT_BINARY_DIR} to 
# include the Release/Debug part of the path to the executable
Set ( DESTINATION foo.xsd )
Add_Custom_Command(
  OUTPUT ${DESTINATION}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different foo.xsd ${DESTINATION}
  DEPENDS foo.xsd
  COMMENT "Updating foo.xsd ..." )
		
Set (POST_BUILD_OUTPUT_DEPS ${POST_BUILD_OUTPUT_DEPS} ${DESTINATION})


# Desired code, but copies the file every time regardless of changes
Set ( DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/foo.xsd )
Add_Custom_Command(
  OUTPUT ${DESTINATION}
  COMMAND ${CMAKE_COMMAND} -E copy_if_different foo.xsd ${DESTINATION}
  DEPENDS foo.xsd
  COMMENT "Updating foo.xsd ..." )
		
Set (POST_BUILD_OUTPUT_DEPS ${POST_BUILD_OUTPUT_DEPS} ${DESTINATION})


#...

Add_Custom_Target(SYNC_UNCOMPILED ALL DEPENDS ${POST_BUILD_OUTPUT_DEPS})
Add_Dependencies(MainExecutable SYNC_UNCOMPILED)
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-06-24 10:46 Adam Clements  New Issue                                    
======================================================================




More information about the cmake-developers mailing list