summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tests/Complex/CMakeLists.txt46
-rw-r--r--Tests/Complex/Executable/complex.cxx38
-rw-r--r--Tests/Complex/Library/CMakeLists.txt16
-rw-r--r--Tests/Complex/Library/create_file.cxx28
-rw-r--r--Tests/Complex/cmTestConfigure.h.in1
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt46
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx38
-rw-r--r--Tests/ComplexOneConfig/Library/CMakeLists.txt16
-rw-r--r--Tests/ComplexOneConfig/Library/create_file.cxx28
-rw-r--r--Tests/ComplexOneConfig/cmTestConfigure.h.in1
-rw-r--r--Tests/ComplexRelativePaths/CMakeLists.txt46
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx38
-rw-r--r--Tests/ComplexRelativePaths/Library/CMakeLists.txt16
-rw-r--r--Tests/ComplexRelativePaths/Library/create_file.cxx28
-rw-r--r--Tests/ComplexRelativePaths/cmTestConfigure.h.in1
15 files changed, 339 insertions, 48 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 83f78748a0..51a5656298 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -1,31 +1,53 @@
-# a simple test case
+#
+# A simple test case
+#
PROJECT (Complex)
-# use the ansi CXX compile flag for building cmake
+#
+# Use the ansi CXX compile flag for building cmake
+#
IF (CMAKE_ANSI_CXXFLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
-SUBDIRS(Library Executable)
-SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
-${Complex_SOURCE_DIR}/cmTestConfigure.h.in
-${Complex_BINARY_DIR}/cmTestConfigure.h)
+ ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
+ ${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
-${Complex_BINARY_DIR}
-${Complex_SOURCE_DIR}/Library
-${Complex_SOURCE_DIR}/../../Source
+ ${Complex_BINARY_DIR}
+ ${Complex_SOURCE_DIR}/Library
+ ${Complex_SOURCE_DIR}/../../Source
)
+
LINK_DIRECTORIES(
-${Complex_BINARY_DIR}/Library
+ ${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
-SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
-SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")
+SET (LIBRARY_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all libraries.")
+
+SET (EXECUTABLE_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all executables.")
+
+#
+# Where will executable tests be written ?
+#
+IF (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
+ELSE (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH .)
+ENDIF (EXECUTABLE_OUTPUT_PATH)
+
+SUBDIRS(Library Executable)
+SUBDIR_DEPENDS(Executable Library)
+
+
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 8202cee3f5..4bbb14be85 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -3,6 +3,17 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <io.h>
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+#define _unlink unlink
+#else
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
int passed = 0;
int failed = 0;
@@ -38,6 +49,7 @@ int main()
{
Passed("Call to file1 function returned 1.");
}
+
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
@@ -46,6 +58,7 @@ int main()
{
Passed("Call to file2 function returned 1.");
}
+
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
@@ -76,8 +89,6 @@ int main()
Passed("ZERO_VAR is not defined.");
#endif
-
-
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
@@ -92,13 +103,32 @@ int main()
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
+
+ // Attach a post-build custom-command to the lib.
+ // It run ${CREATE_FILE_EXE} which will create the file
+ // ${Complex_BINARY_DIR}/postbuild.txt.
+ // The 'complex' executable will then test if this file exists,
+ // and remove it.
+
+ struct stat fs;
+ if (stat(BINARY_DIR "/postbuild.txt", &fs) != 0)
+ {
+ Failed("Could not find " BINARY_DIR "/postbuild.txt (created as a post-build custom command for the shared lib).");
+ }
+ else
+ {
+ if (unlink(BINARY_DIR "/postbuild.txt") != 0)
+ {
+ Failed("Unable to remove " BINARY_DIR "/postbuild.txt (does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed).");
+ }
+ }
+
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
+
return 0;
}
-
-
diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt
index bc890eb2b5..73f5ab4771 100644
--- a/Tests/Complex/Library/CMakeLists.txt
+++ b/Tests/Complex/Library/CMakeLists.txt
@@ -2,7 +2,23 @@ AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
+
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
+UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
+ADD_EXECUTABLE(create_file create_file.cxx)
+
+ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
+
+# Attach a post-build custom-command to the lib.
+# It run ${CREATE_FILE_EXE} which will create the file
+# ${Complex_BINARY_DIR}/postbuild.txt.
+# The 'complex' executable will then test if this file exists,
+# and remove it.
+
+ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
+ COMMAND ${CREATE_FILE_EXE}
+ ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ TARGET CMakeTestLibraryShared)
diff --git a/Tests/Complex/Library/create_file.cxx b/Tests/Complex/Library/create_file.cxx
new file mode 100644
index 0000000000..68a9bb8469
--- /dev/null
+++ b/Tests/Complex/Library/create_file.cxx
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main (int argc, char *argv[])
+{
+ if (argc < 2)
+ {
+ fprintf(stderr, "Missing name of file to create.\n");
+ return EXIT_FAILURE;
+ }
+
+ FILE *stream = fopen(argv[1], "w");
+ if(stream == NULL)
+ {
+ fprintf(stderr, "Unable to open %s for writing!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ if(fclose(stream))
+ {
+ fprintf(stderr, "Unable to close %s!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ fprintf(stdout, "Creating %s!\n", argv[1]);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in
index a7bffb7a8c..5c2563bed6 100644
--- a/Tests/Complex/cmTestConfigure.h.in
+++ b/Tests/Complex/cmTestConfigure.h.in
@@ -2,6 +2,7 @@
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"
+#define BINARY_DIR "${Complex_BINARY_DIR}"
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 83f78748a0..51a5656298 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -1,31 +1,53 @@
-# a simple test case
+#
+# A simple test case
+#
PROJECT (Complex)
-# use the ansi CXX compile flag for building cmake
+#
+# Use the ansi CXX compile flag for building cmake
+#
IF (CMAKE_ANSI_CXXFLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
-SUBDIRS(Library Executable)
-SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
-${Complex_SOURCE_DIR}/cmTestConfigure.h.in
-${Complex_BINARY_DIR}/cmTestConfigure.h)
+ ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
+ ${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
-${Complex_BINARY_DIR}
-${Complex_SOURCE_DIR}/Library
-${Complex_SOURCE_DIR}/../../Source
+ ${Complex_BINARY_DIR}
+ ${Complex_SOURCE_DIR}/Library
+ ${Complex_SOURCE_DIR}/../../Source
)
+
LINK_DIRECTORIES(
-${Complex_BINARY_DIR}/Library
+ ${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
-SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
-SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")
+SET (LIBRARY_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all libraries.")
+
+SET (EXECUTABLE_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all executables.")
+
+#
+# Where will executable tests be written ?
+#
+IF (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
+ELSE (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH .)
+ENDIF (EXECUTABLE_OUTPUT_PATH)
+
+SUBDIRS(Library Executable)
+SUBDIR_DEPENDS(Executable Library)
+
+
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 8202cee3f5..4bbb14be85 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -3,6 +3,17 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <io.h>
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+#define _unlink unlink
+#else
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
int passed = 0;
int failed = 0;
@@ -38,6 +49,7 @@ int main()
{
Passed("Call to file1 function returned 1.");
}
+
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
@@ -46,6 +58,7 @@ int main()
{
Passed("Call to file2 function returned 1.");
}
+
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
@@ -76,8 +89,6 @@ int main()
Passed("ZERO_VAR is not defined.");
#endif
-
-
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
@@ -92,13 +103,32 @@ int main()
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
+
+ // Attach a post-build custom-command to the lib.
+ // It run ${CREATE_FILE_EXE} which will create the file
+ // ${Complex_BINARY_DIR}/postbuild.txt.
+ // The 'complex' executable will then test if this file exists,
+ // and remove it.
+
+ struct stat fs;
+ if (stat(BINARY_DIR "/postbuild.txt", &fs) != 0)
+ {
+ Failed("Could not find " BINARY_DIR "/postbuild.txt (created as a post-build custom command for the shared lib).");
+ }
+ else
+ {
+ if (unlink(BINARY_DIR "/postbuild.txt") != 0)
+ {
+ Failed("Unable to remove " BINARY_DIR "/postbuild.txt (does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed).");
+ }
+ }
+
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
+
return 0;
}
-
-
diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt
index bc890eb2b5..73f5ab4771 100644
--- a/Tests/ComplexOneConfig/Library/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt
@@ -2,7 +2,23 @@ AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
+
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
+UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
+ADD_EXECUTABLE(create_file create_file.cxx)
+
+ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
+
+# Attach a post-build custom-command to the lib.
+# It run ${CREATE_FILE_EXE} which will create the file
+# ${Complex_BINARY_DIR}/postbuild.txt.
+# The 'complex' executable will then test if this file exists,
+# and remove it.
+
+ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
+ COMMAND ${CREATE_FILE_EXE}
+ ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ TARGET CMakeTestLibraryShared)
diff --git a/Tests/ComplexOneConfig/Library/create_file.cxx b/Tests/ComplexOneConfig/Library/create_file.cxx
new file mode 100644
index 0000000000..68a9bb8469
--- /dev/null
+++ b/Tests/ComplexOneConfig/Library/create_file.cxx
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main (int argc, char *argv[])
+{
+ if (argc < 2)
+ {
+ fprintf(stderr, "Missing name of file to create.\n");
+ return EXIT_FAILURE;
+ }
+
+ FILE *stream = fopen(argv[1], "w");
+ if(stream == NULL)
+ {
+ fprintf(stderr, "Unable to open %s for writing!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ if(fclose(stream))
+ {
+ fprintf(stderr, "Unable to close %s!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ fprintf(stdout, "Creating %s!\n", argv[1]);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in
index a7bffb7a8c..5c2563bed6 100644
--- a/Tests/ComplexOneConfig/cmTestConfigure.h.in
+++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in
@@ -2,6 +2,7 @@
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"
+#define BINARY_DIR "${Complex_BINARY_DIR}"
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt
index 83f78748a0..51a5656298 100644
--- a/Tests/ComplexRelativePaths/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/CMakeLists.txt
@@ -1,31 +1,53 @@
-# a simple test case
+#
+# A simple test case
+#
PROJECT (Complex)
-# use the ansi CXX compile flag for building cmake
+#
+# Use the ansi CXX compile flag for building cmake
+#
IF (CMAKE_ANSI_CXXFLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
-SUBDIRS(Library Executable)
-SUBDIR_DEPENDS(Executable Library)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
CONFIGURE_FILE(
-${Complex_SOURCE_DIR}/cmTestConfigure.h.in
-${Complex_BINARY_DIR}/cmTestConfigure.h)
+ ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
+ ${Complex_BINARY_DIR}/cmTestConfigure.h)
INCLUDE_DIRECTORIES(
-${Complex_BINARY_DIR}
-${Complex_SOURCE_DIR}/Library
-${Complex_SOURCE_DIR}/../../Source
+ ${Complex_BINARY_DIR}
+ ${Complex_SOURCE_DIR}/Library
+ ${Complex_SOURCE_DIR}/../../Source
)
+
LINK_DIRECTORIES(
-${Complex_BINARY_DIR}/Library
+ ${Complex_BINARY_DIR}/Library
)
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
-SET (LIBRARY_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
-SET (EXECUTABLE_OUTPUT_PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")
+SET (LIBRARY_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all libraries.")
+
+SET (EXECUTABLE_OUTPUT_PATH
+ ${Complex_BINARY_DIR}/bin/ CACHE PATH
+ "Single output directory for building all executables.")
+
+#
+# Where will executable tests be written ?
+#
+IF (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
+ELSE (EXECUTABLE_OUTPUT_PATH)
+ SET (CXX_TEST_PATH .)
+ENDIF (EXECUTABLE_OUTPUT_PATH)
+
+SUBDIRS(Library Executable)
+SUBDIR_DEPENDS(Executable Library)
+
+
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 8202cee3f5..4bbb14be85 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -3,6 +3,17 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
+#include <sys/stat.h>
+#include <stdio.h>
+#include <io.h>
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+#define _unlink unlink
+#else
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
int passed = 0;
int failed = 0;
@@ -38,6 +49,7 @@ int main()
{
Passed("Call to file1 function returned 1.");
}
+
if(file2() != 1)
{
Failed("Call to file2 function from library failed.");
@@ -46,6 +58,7 @@ int main()
{
Passed("Call to file2 function returned 1.");
}
+
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
@@ -76,8 +89,6 @@ int main()
Passed("ZERO_VAR is not defined.");
#endif
-
-
#ifndef STRING_VAR
Failed("configureFile is broken, STRING_VAR is not defined.");
#else
@@ -92,13 +103,32 @@ int main()
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
+
+ // Attach a post-build custom-command to the lib.
+ // It run ${CREATE_FILE_EXE} which will create the file
+ // ${Complex_BINARY_DIR}/postbuild.txt.
+ // The 'complex' executable will then test if this file exists,
+ // and remove it.
+
+ struct stat fs;
+ if (stat(BINARY_DIR "/postbuild.txt", &fs) != 0)
+ {
+ Failed("Could not find " BINARY_DIR "/postbuild.txt (created as a post-build custom command for the shared lib).");
+ }
+ else
+ {
+ if (unlink(BINARY_DIR "/postbuild.txt") != 0)
+ {
+ Failed("Unable to remove " BINARY_DIR "/postbuild.txt (does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed).");
+ }
+ }
+
std::cout << "Passed:" << passed << "\n";
if(failed)
{
std::cout << "Failed: " << failed << "\n";
return failed;
}
+
return 0;
}
-
-
diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt
index bc890eb2b5..73f5ab4771 100644
--- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt
@@ -2,7 +2,23 @@ AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
+
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
+UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
+ADD_EXECUTABLE(create_file create_file.cxx)
+
+ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
+
+# Attach a post-build custom-command to the lib.
+# It run ${CREATE_FILE_EXE} which will create the file
+# ${Complex_BINARY_DIR}/postbuild.txt.
+# The 'complex' executable will then test if this file exists,
+# and remove it.
+
+ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
+ COMMAND ${CREATE_FILE_EXE}
+ ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ TARGET CMakeTestLibraryShared)
diff --git a/Tests/ComplexRelativePaths/Library/create_file.cxx b/Tests/ComplexRelativePaths/Library/create_file.cxx
new file mode 100644
index 0000000000..68a9bb8469
--- /dev/null
+++ b/Tests/ComplexRelativePaths/Library/create_file.cxx
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main (int argc, char *argv[])
+{
+ if (argc < 2)
+ {
+ fprintf(stderr, "Missing name of file to create.\n");
+ return EXIT_FAILURE;
+ }
+
+ FILE *stream = fopen(argv[1], "w");
+ if(stream == NULL)
+ {
+ fprintf(stderr, "Unable to open %s for writing!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ if(fclose(stream))
+ {
+ fprintf(stderr, "Unable to close %s!\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+
+ fprintf(stdout, "Creating %s!\n", argv[1]);
+
+ return EXIT_SUCCESS;
+}
diff --git a/Tests/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in
index a7bffb7a8c..5c2563bed6 100644
--- a/Tests/ComplexRelativePaths/cmTestConfigure.h.in
+++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in
@@ -2,6 +2,7 @@
#cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}"
+#define BINARY_DIR "${Complex_BINARY_DIR}"
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS