I have a simple console project, which have "main.h" and "main.cpp".
main.h is an empty file, select the option "Compile file", and use custom build command: cmd /c copy $file main1.h, select the priority weight to 0.
main.cpp's content:
#include "main1.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
First press build button the log is below:
-------------- Build: Debug in depend (compiler: GNU GCC Compiler)---------------
[ 33.3%] cmd /c copy E:\code\cb\test_code\depend\main.h main1.h
1 file(s) copied.
[ 66.7%] g++.exe -Wall -fexceptions -g -c E:\code\cb\test_code\depend\main.cpp -o obj\Debug\main.o
[100.0%] g++.exe -o bin\Debug\depend.exe obj\Debug\main.o
Output file is bin\Debug\depend.exe with size 52.54 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Now, press build again, I have the custom build command run again, then link again.
-------------- Build: Debug in depend (compiler: GNU GCC Compiler)---------------
[ 50.0%] cmd /c copy E:\code\cb\test_code\depend\main.h main1.h
1 file(s) copied.
[100.0%] g++.exe -o bin\Debug\depend.exe obj\Debug\main.o
Output file is bin\Debug\depend.exe with size 52.54 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
press build again, I get the same result as before, so my questions are:
1, I don't change main.h, why the custom command run again?
2, why the linker run again and again?
3, if the dependency checker know main1.h changed, why not compile main.cpp?