cmake/Tests/CustomCommand/wrapper.cxx

30 lines
752 B
C++
Raw Normal View History

#include <stdio.h>
#include <string.h>
2016-07-09 11:21:54 +02:00
int main(int argc, char* argv[])
{
2016-07-09 11:21:54 +02:00
if (argc < 3) {
fprintf(stderr, "Usage: %s <file1> <file2>\n", argv[0]);
return 1;
2016-07-09 11:21:54 +02:00
}
FILE* fp = fopen(argv[1], "w");
fprintf(fp, "extern int wrapped_help();\n");
fprintf(fp, "int wrapped() { return wrapped_help(); }\n");
fclose(fp);
2016-07-09 11:21:54 +02:00
fp = fopen(argv[2], "w");
fprintf(fp, "int wrapped_help() { return 5; }\n");
fclose(fp);
#ifdef CMAKE_INTDIR
2016-07-09 11:21:54 +02:00
const char* cfg = (argc >= 4) ? argv[3] : "";
if (strcmp(cfg, CMAKE_INTDIR) != 0) {
2018-08-09 18:06:22 +02:00
fprintf(stderr,
"Did not receive expected configuration argument:\n"
" expected [" CMAKE_INTDIR "]\n"
" received [%s]\n",
2016-07-09 11:21:54 +02:00
cfg);
return 1;
2016-07-09 11:21:54 +02:00
}
#endif
return 0;
}