Hi Sarina,
Thanks for your answer. But probably I explained the problem not clear enough...
Of course, I don't duplicate post-build event in the local options of specific file. I only need it to be done after the whole build process is finished.
The problem is that the post-build event (if it exists) is duplicated automatically in the local properties of the file, when we create those local properties. And I don't know how to remove/disable it then.
Consider the following workflow:
1. Create C++ project with several source files (aka units).
2. Create global post-build event (all configurations, all platforms), which does something like
copy $(OUTPUTPATH) C:\some_other_dir
3. Right-click some source file (unit) -> "Edit local options". Let's call it "MySpecialSource.cpp"
4. Change some local options (in my case I disable some specific warning).
5. Save everything.
6. Try to compile.
=> I'd expect that it will fail on first run. And if you examine output, you'll see, that after MySpecialSource.cpp is compiled the post-build event is executed. But output executable (or dll) is not linked yet, so there is nothing to copy, which triggers the error).
To make things more obvious you may replace "copy" command with "echo". Something like "echo This is post-build event". And then check the output of the build (in the "Output" tab of "Messages" window). You'll see, that post-build event is triggered twice: once after compilation of "MySpecialSource.cpp" and second time after the build is completed.
Below you can find the output of the build of sample project created as described above. You can see, that "echo Hi there" is called twice: first time after "Unit1.cpp" is compiled and the second time after the build is completed.
So, the question is how to disable first occasion, while keeping local options of the file.
The build output:
Build started 30.04.2015 08:10:12.
__________________________________________________
Project "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" (Make target(s)):
Target MakeObjs:
Target _CppDepCheck:
Modified: File1.cpp;Unit1.cpp
Target CppCompile:
Target _CppCoreCompile:
Target _BCC32CoreCompile:
c:\program files (x86)\embarcadero\studio\14.0\bin\bcc32.exe -D_DEBUG -n.\Win32\Debug -ITestPostBuildEvents;"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39\boost\tr1\tr1";"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39";"c:\program files (x86)\embarcadero\studio\14.0\include";"c:\program files (x86)\embarcadero\studio\14.0\include\dinkumware";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\crtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\sdk";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\rtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\vcl";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -y -Q -k -r- -c -tC -C8 -o.\Win32\Debug\File1.obj -w-par -Od -v -vi- -H=.\Win32\Debug\Project1.pch -H File1.cpp
Build started 30.04.2015 08:10:13.
Target _BCC32CoreCompile:
__________________________________________________
Project "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" is building "C:\Users\dsemikin\Documents\Embarcadero\Studio\Projects\TestPostBuildEvents\Project1.cbproj" (MakeOne target(s)):
Target _MakeOne:
Target _CppCoreCompile:
Target _BCC32CoreCompile:
c:\program files (x86)\embarcadero\studio\14.0\bin\bcc32.exe -D_DEBUG -n.\Win32\Debug -ITestPostBuildEvents;"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39\boost\tr1\tr1";"C:\Program Files (x86)\Embarcadero\Studio\14.0\include\boost_1_39";"c:\program files (x86)\embarcadero\studio\14.0\include";"c:\program files (x86)\embarcadero\studio\14.0\include\dinkumware";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\crtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\sdk";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\rtl";"c:\program files (x86)\embarcadero\studio\14.0\include\windows\vcl";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32" -y -Q -k -r- -c -tC -C8 -o.\Win32\Debug\Unit1.obj -w-par -Od -v -vi- -H=.\Win32\Debug\Project1.pch -H Unit1.cpp
Target PostBuildEvent:
echo Hi there
Hi there
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.27
Target RcCompile:
Target BuildVersionResource:
c:\program files (x86)\embarcadero\studio\14.0\bin\cgrc.exe -c65001 Project1.vrc -foProject1.res
CodeGear Resource Compiler/Binder
Version 1.2.2 Copyright (c) 2008-2012 Embarcadero Technologies Inc.
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Deleting file "Project1.vrc".
Target _PerformLink:
Target _PerformBCCILink:
c:\program files (x86)\embarcadero\studio\14.0\bin\ilink32.exe -G8 -L.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";TestPostBuildEvents;"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release";"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release\psdk";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32";C:\Users\Public\Documents\Embarcadero\Studio\14.0\DCP -j.\Win32\Debug;"c:\program files (x86)\embarcadero\studio\14.0\lib\Win32\debug";TestPostBuildEvents;"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release";"c:\program files (x86)\embarcadero\studio\14.0\lib\win32\release\psdk";"C:\Program Files (x86)\Raize\CS5\Lib\RS-XE6\Win32";C:\Users\Public\Documents\Embarcadero\Studio\14.0\DCP -l.\Win32\Debug -v -Tpe c0x32 .\Win32\Debug\File1.obj .\Win32\Debug\Unit1.obj , .\Win32\Debug\Project1.exe , .\Win32\Debug\Project1.map , import32.lib cw32.lib , , Project1.res
Target PostBuildEvent:
echo Hi there
Hi there
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.23