MantisBT - CMake
View Issue Details
0011584CMakeCMakepublic2010-12-08 12:312010-12-10 11:29
Petr Petrov 
David Cole 
urgentmajoralways
closedno change required 
CMake 2.8.3 
CMake 2.8.4CMake 2.8.4 
0011584: Temporary files overlap in VS2010 generator
I have a big project which works fine with CMake on VS2005, VS2008 and Unix generators. It consists more than 100 executables & dynamic link libraries.

It contains a lot of small examples,
such as ADD_EXECUTABLE(Example1 main.cpp).

In VS2010 I have the following error in the different small examples, such as:

  CMake does not need to re-run because D:\ProjectName\examples\ReportExample\CMakeFiles\generate.stamp is up-to-date.
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: The "CustomBuild" task failed unexpectedly. [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: System.IO.IOException: The process cannot access the file 'C:\Users\petr\AppData\Local\Temp\7bf85b669bd34561b56a1267d38c2645.cmd' because it is being used by another process. [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at System.IO.File.Delete(String path) [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at Microsoft.Build.Utilities.ToolTask.Execute() [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute() [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) [d:\ProjectName\examples\ReportExample\ReportExample.vcxproj]

Please note that I am using /m:1 switch for msbuild.exe utility,
so, I am using 1 core for building this project.

I think that previous or some other project (as part of my big project) used the temporary cmd file (i.e. Temp\7bf85b669bd34561b56a1267d38c2645.cmd) for compiling and the current project is trying to use the exactly same name.

Is any work-around for this problem?
I can not figure-out a small example to reproduce, sorry
No tags attached.
Issue History
2010-12-08 12:31Petr PetrovNew Issue
2010-12-08 13:24David ColeNote Added: 0023803
2010-12-09 13:14Petr PetrovNote Added: 0023850
2010-12-09 14:18Petr PetrovNote Added: 0023852
2010-12-10 11:23Petr PetrovNote Added: 0023870
2010-12-10 11:28David ColeAssigned To => David Cole
2010-12-10 11:28David ColeStatusnew => assigned
2010-12-10 11:29David ColeNote Added: 0023871
2010-12-10 11:29David ColeStatusassigned => closed
2010-12-10 11:29David ColeResolutionopen => no change required
2010-12-10 11:29David ColeFixed in Version => CMake 2.8.4
2010-12-10 11:29David ColeTarget Version => CMake 2.8.4

Notes
(0023803)
David Cole   
2010-12-08 13:24   
A similar issue with multiple custom commands trying to write output to the same log file simultaneuosly was fixed with this commit:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ed37fc3ea398b03bbba175ae337f14b6af58daee [^]

That change should be in the CMake 2.8.3 release.

Since you cannot provide a small reproducible example, can you give us access to your project instead? (Or is it private?)

Seems like any large project trying to build in parallel would hit this sort of issue.

Do you have targets with same name, but in different directories? Maybe VS10 uses the target name as the base name for its generated *.cmd files, and parallel stuff just won't work with multiple targets having the same name...?
(0023850)
Petr Petrov   
2010-12-09 13:14   
Sorry, it is a private project. So, I can not share.

>Do you have targets with same name, but in different directories? Maybe VS10 >uses the target name as the base name for its generated *.cmd files, and >parallel stuff just won't work with multiple targets having the same name...?
No, all targets are unique.

>Seems like any large project trying to build in parallel would hit this sort of issue.
I am using msbuild /m:1 option. It specifies that 1 core should be used for compilation. Will be parallel compilation used?
(0023852)
Petr Petrov   
2010-12-09 14:18   
Thank you for the advise

another strange thing - main project is being compiled twice.
(0023870)
Petr Petrov   
2010-12-10 11:23   
I think that I have found a reason of such behavior.

I terminated my previous build (by control-c sequence).
And the temporary files are from previous build.
(0023871)
David Cole   
2010-12-10 11:29   
Closing bug. If the only problem here is that Visual Studio leaves junk around when the user hits Ctrl+C to cancel a build... then it is not a problem that CMake can actually solve.

Thanks for the udpate.