summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-06-01 17:01:31 (GMT)
committerBrad King <brad.king@kitware.com>2006-06-01 17:01:31 (GMT)
commit09f2be12b803ca3d6955b89e90f816928154aa1b (patch)
tree4ad0ad3d08e0a9a7bf78a8552c315b76a76ebecc /Tests
parent4189370497f4f00c7a7d3ec6ba221879bfc8b58c (diff)
downloadCMake-09f2be12b803ca3d6955b89e90f816928154aa1b.zip
CMake-09f2be12b803ca3d6955b89e90f816928154aa1b.tar.gz
CMake-09f2be12b803ca3d6955b89e90f816928154aa1b.tar.bz2
ENH: Added test for generation of files listed explicitly as sources but not used during the build of a target.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CustomCommand/CMakeLists.txt29
-rw-r--r--Tests/CustomCommand/config.h.in1
-rw-r--r--Tests/CustomCommand/foo.in14
3 files changed, 33 insertions, 11 deletions
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index 97c4d81..2fb4725 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -131,22 +131,31 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.c
${PROJECT_BINARY_DIR}/foo.c
)
-# These object dependencies can be removed to test the
-# auto-object-depends feature of the Makefile generator. Currently
-# the feature does not seem to work in Visual Studio generators so
-# these dependencies are needed.
-#SET_SOURCE_FILES_PROPERTIES(${PROJECT_BINARY_DIR}/foo.c
-#PROPERTIES
-# OBJECT_DEPENDS "${PROJECT_BINARY_DIR}/doc1.h;${PROJECT_BINARY_DIR}/foo.h"
-#)
-
-# add the library
+# Add custom command to generate not_included.h, which is a header
+# file that is not included by any source in this project. This will
+# test whether all custom command outputs explicitly listed as sources
+# get generated even if they are not needed by an object file.
+ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h
+ DEPENDS ${PROJECT_SOURCE_DIR}/foo.h.in
+ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/foo.h.in
+ ${PROJECT_BINARY_DIR}/not_included.h
+ )
+
+# Tell the executable where to find not_included.h.
+CONFIGURE_FILE(
+ ${PROJECT_SOURCE_DIR}/config.h.in
+ ${PROJECT_BINARY_DIR}/config.h
+ @ONLY IMMEDIATE
+ )
+
+# add the executable
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
+ ${PROJECT_BINARY_DIR}/not_included.h
)
TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader)
diff --git a/Tests/CustomCommand/config.h.in b/Tests/CustomCommand/config.h.in
new file mode 100644
index 0000000..86c97bd
--- /dev/null
+++ b/Tests/CustomCommand/config.h.in
@@ -0,0 +1 @@
+#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@"
diff --git a/Tests/CustomCommand/foo.in b/Tests/CustomCommand/foo.in
index 62b04b2..08c559d 100644
--- a/Tests/CustomCommand/foo.in
+++ b/Tests/CustomCommand/foo.in
@@ -1,5 +1,8 @@
#include "doc1.h"
#include "foo.h"
+#include "config.h"
+
+#include <stdio.h>
int generated();
int wrapped();
@@ -8,7 +11,16 @@ int main ()
{
if (generated()*wrapped()*doc() == 3*5*7)
{
- return 0;
+ FILE* fin = fopen(PROJECT_BINARY_DIR "/not_included.h", "r");
+ if(fin)
+ {
+ fclose(fin);
+ return 0;
+ }
+ else
+ {
+ return -2;
+ }
}
return -1;