summaryrefslogtreecommitdiffstats
path: root/Tests/BuildDepends
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-05-23 17:27:00 (GMT)
committerBrad King <brad.king@kitware.com>2007-05-23 17:27:00 (GMT)
commitc288da754a3f1221ca4ebfd9c9efb8c935d499d6 (patch)
tree998d24826c3e2e32158b8255d5c1c8715139761c /Tests/BuildDepends
parent702d785c9ae49015a770530a9c5f27e7bfaff716 (diff)
downloadCMake-c288da754a3f1221ca4ebfd9c9efb8c935d499d6.zip
CMake-c288da754a3f1221ca4ebfd9c9efb8c935d499d6.tar.gz
CMake-c288da754a3f1221ca4ebfd9c9efb8c935d499d6.tar.bz2
BUG: Target names in the COMMAND part of a custom command should not create a file-level dependency that forces the command to rerun when the executable target rebuilds, but the target-level dependency should still be created. Target names in a DEPENDS should do both a target-level and file-level dependency. Updated the BuildDepends test to check that this works.
Diffstat (limited to 'Tests/BuildDepends')
-rw-r--r--Tests/BuildDepends/CMakeLists.txt2
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt28
-rw-r--r--Tests/BuildDepends/Project/bar.cxx17
3 files changed, 41 insertions, 6 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 80793bc..3a4ba26 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -60,5 +60,5 @@ message("${out}")
if("${out}" STREQUAL "foo changed ")
message("Worked!")
else("${out}" STREQUAL "foo changed ")
- message(SEND_ERROR "Program did not rebuild with changed file")
+ message(SEND_ERROR "Project did not rebuild properly!")
endif("${out}" STREQUAL "foo changed ")
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index f9cbc56..e831676 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -1,4 +1,30 @@
project(testRebuild)
add_library(foo STATIC ${testRebuild_BINARY_DIR}/foo.cxx)
-add_executable(bar bar.cxx)
+
+# Add a generated header that regenerates when the generator is
+# rebuilt.
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regen.h
+ COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/regen.h regen
+ DEPENDS generator # adds file-level dependency to re-run rule
+ )
+
+# Add a generated header that does NOT regenerate when the generator
+# is rebuilt.
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/noregen.h
+ COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/noregen.h noregen
+ )
+
+# Test that the generator rebuilds when the static library source file
+# changes. This should cause regen.h to be recreated also.
+add_executable(generator generator.cxx)
+target_link_libraries(generator foo)
+
+# Build an executable to drive the build and rebuild.
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+add_executable(bar bar.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/regen.h
+ ${CMAKE_CURRENT_BINARY_DIR}/noregen.h
+ )
target_link_libraries(bar foo)
diff --git a/Tests/BuildDepends/Project/bar.cxx b/Tests/BuildDepends/Project/bar.cxx
index 4764af5..76e934f 100644
--- a/Tests/BuildDepends/Project/bar.cxx
+++ b/Tests/BuildDepends/Project/bar.cxx
@@ -1,10 +1,19 @@
-#include "stdio.h"
+#include <stdio.h>
+#include <string.h>
+#include <regen.h>
+#include <noregen.h>
-const char* foo();
int main()
{
- int i;
- printf("%s\n", foo());
+ /* Make sure the noregen header was not regenerated. */
+ if(strcmp("foo", noregen_string) != 0)
+ {
+ printf("FAILED: noregen.h was regenerated!\n");
+ return 1;
+ }
+
+ /* Print out the string that should have been regenerated. */
+ printf("%s\n", regen_string);
fflush(stdout);
for(;;);
return 0;