From bf699505bc7fc378abf07ec4dfa0f0cc4fb89686 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 9 Mar 2004 16:20:41 -0500 Subject: [PATCH] ENH: create new test to test subdir exclude --- Tests/SubDir/CMakeLists.txt | 3 ++ Tests/SubDir/Examples/CMakeLists.txt | 2 ++ Tests/SubDir/Examples/example1/CMakeLists.txt | 6 ++++ Tests/SubDir/Examples/example1/example1.cxx | 7 ++++ Tests/SubDir/Examples/example2/CMakeLists.txt | 2 ++ Tests/SubDir/Examples/example2/example2.cxx | 7 ++++ Tests/SubDir/Executable/CMakeLists.txt | 1 + Tests/SubDir/Executable/test.cxx | 36 +++++++++++++++++++ 8 files changed, 64 insertions(+) create mode 100644 Tests/SubDir/CMakeLists.txt create mode 100644 Tests/SubDir/Examples/CMakeLists.txt create mode 100644 Tests/SubDir/Examples/example1/CMakeLists.txt create mode 100644 Tests/SubDir/Examples/example1/example1.cxx create mode 100644 Tests/SubDir/Examples/example2/CMakeLists.txt create mode 100644 Tests/SubDir/Examples/example2/example2.cxx create mode 100644 Tests/SubDir/Executable/CMakeLists.txt create mode 100644 Tests/SubDir/Executable/test.cxx diff --git a/Tests/SubDir/CMakeLists.txt b/Tests/SubDir/CMakeLists.txt new file mode 100644 index 000000000..b70b312c5 --- /dev/null +++ b/Tests/SubDir/CMakeLists.txt @@ -0,0 +1,3 @@ +PROJECT(SUBDIR) +SUBDIRS(Executable EXCLUDE_FROM_ALL Examples) +WRITE_FILE(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.") diff --git a/Tests/SubDir/Examples/CMakeLists.txt b/Tests/SubDir/Examples/CMakeLists.txt new file mode 100644 index 000000000..44f2ad236 --- /dev/null +++ b/Tests/SubDir/Examples/CMakeLists.txt @@ -0,0 +1,2 @@ +PROJECT(Examples) +SUBDIRS(example1 example2) diff --git a/Tests/SubDir/Examples/example1/CMakeLists.txt b/Tests/SubDir/Examples/example1/CMakeLists.txt new file mode 100644 index 000000000..e465899d5 --- /dev/null +++ b/Tests/SubDir/Examples/example1/CMakeLists.txt @@ -0,0 +1,6 @@ +PROJECT(example1) +ADD_EXECUTABLE(example1 example1.cxx) + +ADD_CUSTOM_COMMAND(TARGET example1 POST_BUILD + COMMAND "${CMAKE_COMMAND}" ARGS -E remove ${SUBDIR_BINARY_DIR}/ShouldBeHere + COMMENT "Remove marker file that should exist because this should not be run") diff --git a/Tests/SubDir/Examples/example1/example1.cxx b/Tests/SubDir/Examples/example1/example1.cxx new file mode 100644 index 000000000..3c4819415 --- /dev/null +++ b/Tests/SubDir/Examples/example1/example1.cxx @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("example1\n"); + return 0; +} diff --git a/Tests/SubDir/Examples/example2/CMakeLists.txt b/Tests/SubDir/Examples/example2/CMakeLists.txt new file mode 100644 index 000000000..19a537686 --- /dev/null +++ b/Tests/SubDir/Examples/example2/CMakeLists.txt @@ -0,0 +1,2 @@ +PROJECT(example2) +ADD_EXECUTABLE(example2 example2.cxx) diff --git a/Tests/SubDir/Examples/example2/example2.cxx b/Tests/SubDir/Examples/example2/example2.cxx new file mode 100644 index 000000000..60ef3c940 --- /dev/null +++ b/Tests/SubDir/Examples/example2/example2.cxx @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("example2\n"); + return 0; +} diff --git a/Tests/SubDir/Executable/CMakeLists.txt b/Tests/SubDir/Executable/CMakeLists.txt new file mode 100644 index 000000000..d679168d8 --- /dev/null +++ b/Tests/SubDir/Executable/CMakeLists.txt @@ -0,0 +1 @@ +ADD_EXECUTABLE(test test.cxx) diff --git a/Tests/SubDir/Executable/test.cxx b/Tests/SubDir/Executable/test.cxx new file mode 100644 index 000000000..12913e8a2 --- /dev/null +++ b/Tests/SubDir/Executable/test.cxx @@ -0,0 +1,36 @@ +#include +#include +#include +#include + + +// return true if the file exists +int FileExists(const char* filename) +{ +#ifdef _MSC_VER +# define access _access +#endif +#ifndef F_OK +#define F_OK 0 +#endif + if ( access(filename, F_OK) != 0 ) + { + return false; + } + else + { + return true; + } +} + + +int main(int ac, char** av) +{ + if(!FileExists(av[1])) + { + printf("Missing file %s\n", av[1]); + return 1; + } + printf("%s is there!", av[1]); + return 0; +}