[cmake-commits] king committed CMakeLists.txt 1.2 1.3 bar.cxx 1.1 1.2
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed May 23 13:27:02 EDT 2007
Update of /cvsroot/CMake/CMake/Tests/BuildDepends/Project
In directory public:/mounts/ram/cvs-serv10769/Tests/BuildDepends/Project
Modified Files:
CMakeLists.txt bar.cxx
Log Message:
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.
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/BuildDepends/Project/CMakeLists.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CMakeLists.txt 16 May 2007 11:56:56 -0000 1.2
+++ CMakeLists.txt 23 May 2007 17:27:00 -0000 1.3
@@ -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)
Index: bar.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/BuildDepends/Project/bar.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- bar.cxx 16 May 2007 11:55:00 -0000 1.1
+++ bar.cxx 23 May 2007 17:27:00 -0000 1.2
@@ -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;
More information about the Cmake-commits
mailing list