View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0012302 | CMake | CMake | public | 2011-06-24 10:46 | 2012-01-02 15:56 | ||||
Reporter | Adam Clements | ||||||||
Assigned To | David Cole | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | duplicate | ||||||
Platform | VS10 | OS | Windows | OS Version | 7 | ||||
Product Version | CMake 2.8.4 | ||||||||
Target Version | CMake 2.8.5 | Fixed in Version | CMake 2.8.5 | ||||||
Summary | 0012302: Unable to use CMAKE_CFG_INTDIR 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) | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | Cmake_Custom_output_testcase.zip [^] (1,654 bytes) 2011-06-24 12:59 | ||||||||
Relationships | ||||||
|
Relationships |
Notes | |
(0026962) Clinton Stimpson (developer) 2011-06-24 11:37 |
Have you tried using an absolute path in this part? DEPENDS foo.xsd |
(0026964) Adam Clements (reporter) 2011-06-24 12:15 |
Hm, I just made a completely separate project with what I thought was the problem and I'm now failing to reproduce it, there's something else at work here. Doing further testing, will report back |
(0026966) Adam Clements (reporter) 2011-06-24 13:01 edited on: 2011-06-24 13:18 |
Having looked into it further, it seems it only happens when I'm trying to copy the resources to a further subdirectory within the configuration directory. I have made a test project and attached it, it contains both working and non-working examples of what I want to achieve (non-working is commented out). This is the CmakeLists.txt from the attachment, illustrating the issue: Function(PostBuildCopy FILENAME DIRFROM DIRTO) Add_Custom_Command( OUTPUT ${DIRTO}/${FILENAME} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DIRFROM}/${FILENAME} ${DIRTO}/${FILENAME} DEPENDS ${DIRFROM}/${FILENAME} COMMENT "Updating ${FILENAME} because it changed...") Set (POST_BUILD_OUTPUT_DEPS ${POST_BUILD_OUTPUT_DEPS} ${DIRTO}/${FILENAME} PARENT_SCOPE) Set ( ALL_SOURCES ${ALL_SOURCES} ${DIRFROM}/${FILENAME} PARENT_SCOPE) EndFunction() File( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Debug/Resources) File( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Release/Resources) Set(ALL_SOURCES ${ALL_SOURCES} hello.cpp) # Works - only the changed files are copied PostBuildCopy(requiredResource.txt ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) PostBuildCopy(someconfig.xml ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) PostBuildCopy(validationschema.xsd ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) # Does not work - all the files are copied every time #PostBuildCopy(requiredResource.txt ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Resources) #PostBuildCopy(someconfig.xml ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Resources) #PostBuildCopy(validationschema.xsd ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Resources) Add_Executable(MainExecutable ${ALL_SOURCES} ) Add_Custom_Target(SYNC_UNCOMPILED ALL DEPENDS ${POST_BUILD_OUTPUT_DEPS}) Add_Dependencies(MainExecutable SYNC_UNCOMPILED) |
(0027223) David Cole (manager) 2011-08-17 12:42 |
So is there a real problem here or not? Can this issue be marked as "fixed" or "not a bug" ... ? |
(0027245) Adam Clements (reporter) 2011-08-19 05:26 |
There is a real problem, perhaps it needs to be closed and reopened as another bug, as I clarified what the underlying problem was in the above notes (and apparently can't edit the summary). Attached is a project test case which demonstrates exactly what is going wrong. |
(0027247) David Cole (manager) 2011-08-19 11:53 |
I cannot reproduce this issue using VS10 and CMake 2.8.4 or CMake 2.8.5 with the attached zip file ... After the first build, the custom commands do not re-execute for me, neither via "cmake --build . --config Release" on the command line, nor via opening the .sln file in VS10 and using "Build Solution" repeatedly. I suspect that perhaps the underlying cause of this issue is the same as discussed recently here on the CMake mailing list: http://public.kitware.com/pipermail/cmake-developers/2011-August/002009.html [^] I pushed the fix discussed there yesterday to CMake 'next' with this commit: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb02acb695ed257093af0375a0ca5acbb9034985 [^] Perhaps you could try it with our nightly build of CMake ( simply download and install from http://www.cmake.org/files/dev/cmake-2.8.5.20110818-gd83c9-win32-x86.exe [^] ) to see if one of the changes included there fixes it? |
(0027249) David Cole (manager) 2011-08-19 14:43 |
Never mind my previous note...... I *DID* reproduce this with CMake 2.8.4, and VS10. I had not read carefully enough: I had to modify the CMakeLists.txt file in the zip file to uncomment the "doesn't work" section, and then it reproduced just fine. The good news is, though, that it is already fixed in CMake 2.8.5. This report is basically a duplicate of 0011927 -- this got fixed when that got fixed. Please re-open and attach more information if upgrading to CMake 2.8.5 or later does not fix this for you. |
(0028131) David Cole (manager) 2012-01-02 15:56 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2011-06-24 10:46 | Adam Clements | New Issue | |
2011-06-24 11:37 | Clinton Stimpson | Note Added: 0026962 | |
2011-06-24 12:00 | Adam Clements | Note Added: 0026963 | |
2011-06-24 12:15 | Adam Clements | Note Added: 0026964 | |
2011-06-24 12:59 | Adam Clements | File Added: Cmake_Custom_output_testcase.zip | |
2011-06-24 13:01 | Adam Clements | Note Added: 0026966 | |
2011-06-24 13:15 | Adam Clements | Note Deleted: 0026963 | |
2011-06-24 13:18 | Adam Clements | Note Edited: 0026966 | |
2011-08-17 12:42 | David Cole | Note Added: 0027223 | |
2011-08-19 05:26 | Adam Clements | Note Added: 0027245 | |
2011-08-19 11:40 | David Cole | Assigned To | => David Cole |
2011-08-19 11:40 | David Cole | Status | new => assigned |
2011-08-19 11:40 | David Cole | Target Version | => CMake 2.8.6 |
2011-08-19 11:53 | David Cole | Note Added: 0027247 | |
2011-08-19 14:38 | David Cole | Target Version | CMake 2.8.6 => CMake 2.8.5 |
2011-08-19 14:43 | David Cole | Note Added: 0027249 | |
2011-08-19 14:43 | David Cole | Relationship added | duplicate of 0011927 |
2011-08-19 14:43 | David Cole | Status | assigned => resolved |
2011-08-19 14:43 | David Cole | Fixed in Version | => CMake 2.8.5 |
2011-08-19 14:43 | David Cole | Resolution | open => duplicate |
2011-08-19 14:44 | David Cole | Summary | Unable to use CMAKE_CFG_OUTDIR in the OUTPUT of a CUSTOM_COMMAND => Unable to use CMAKE_CFG_INTDIR in the OUTPUT of a CUSTOM_COMMAND |
2012-01-02 15:56 | David Cole | Note Added: 0028131 | |
2012-01-02 15:56 | David Cole | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |