summaryrefslogtreecommitdiffstats
path: root/Tests/CustomCommand
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-04-11 15:06:19 (GMT)
committerBrad King <brad.king@kitware.com>2006-04-11 15:06:19 (GMT)
commitd5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0 (patch)
tree714a99bed97290f96ff8f846fa6864cebbdc0a28 /Tests/CustomCommand
parentb613cf0be806cc1d37d2b590f1a5ba7898236ae8 (diff)
downloadCMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.zip
CMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.tar.gz
CMake-d5719f22c1dca3e100f1e3b5dfaa4fe7d26796a0.tar.bz2
ENH: Added support for multiple outputs generated by a single custom command. For Visual Studio generators the native tool provides support. For Xcode and Makefile generators a simple trick is used. The first output is considered primary and has the build rule attached. Other outputs simply depend on the first output with no build rule. During cmake_check_build_system CMake detects when a secondary output is missing and removes the primary output to make sure all outputs are regenerated. This approach always builds the custom command at the right time and only once even during parallel builds.
Diffstat (limited to 'Tests/CustomCommand')
-rw-r--r--Tests/CustomCommand/CMakeLists.txt5
-rw-r--r--Tests/CustomCommand/wrapper.cxx11
2 files changed, 10 insertions, 6 deletions
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index f62be0e..97c4d81 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -48,11 +48,11 @@ ADD_EXECUTABLE(wrapper wrapper.cxx)
# is instantiated for the output, with GENERATED 1
# at the end of the day this becomes a what in VS ?
ADD_CUSTOM_COMMAND(
- OUTPUT ${PROJECT_BINARY_DIR}/wrapped.c
+ OUTPUT ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c
DEPENDS wrapper
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/wrapped.h
COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/wrapper
- ARGS ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_SOURCE_DIR}/wrapped.h
+ ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c
)
################################################################
@@ -145,6 +145,7 @@ ADD_EXECUTABLE(CustomCommand
${PROJECT_BINARY_DIR}/foo.h
${PROJECT_BINARY_DIR}/foo.c
${PROJECT_BINARY_DIR}/wrapped.c
+ ${PROJECT_BINARY_DIR}/wrapped_help.c
${PROJECT_BINARY_DIR}/generated.c
)
diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx
index 3a1149d..f65eb9b 100644
--- a/Tests/CustomCommand/wrapper.cxx
+++ b/Tests/CustomCommand/wrapper.cxx
@@ -2,14 +2,17 @@
int main(int argc, char *argv[])
{
- if ( argc < 2 )
+ if ( argc < 3 )
{
- fprintf(stderr, "Usage: %s <file>\n", argv[0]);
+ fprintf(stderr, "Usage: %s <file1> <file2>\n", argv[0]);
return 1;
}
FILE *fp = fopen(argv[1],"w");
-
- fprintf(fp,"int wrapped() { return 5; }\n");
+ fprintf(fp,"extern int wrapped_help(void);\n");
+ fprintf(fp,"int wrapped(void) { return wrapped_help(); }\n");
+ fclose(fp);
+ fp = fopen(argv[2],"w");
+ fprintf(fp,"int wrapped_help(void) { return 5; }\n");
fclose(fp);
return 0;
}