summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Tests/Complex/CMakeLists.txt26
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt16
-rw-r--r--Tests/Complex/Executable/complex.cxx97
-rw-r--r--Tests/Complex/Library/CMakeLists.txt11
-rw-r--r--Tests/Complex/cmTestConfigure.h.in5
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt26
-rw-r--r--Tests/ComplexOneConfig/Executable/CMakeLists.txt16
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx97
-rw-r--r--Tests/ComplexOneConfig/Library/CMakeLists.txt11
-rw-r--r--Tests/ComplexOneConfig/cmTestConfigure.h.in5
-rw-r--r--Tests/ComplexRelativePaths/CMakeLists.txt26
-rw-r--r--Tests/ComplexRelativePaths/Executable/CMakeLists.txt16
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx97
-rw-r--r--Tests/ComplexRelativePaths/Library/CMakeLists.txt11
-rw-r--r--Tests/ComplexRelativePaths/cmTestConfigure.h.in5
15 files changed, 390 insertions, 75 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 10f270e..050cd3e 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# A simple test case
+# A more complex test case
#
PROJECT (Complex)
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
+#
+# More coverage
+#
+ABSTRACT_FILES(
+ ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index f0df86f..4bd1620 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -1,4 +1,20 @@
ADD_EXECUTABLE(complex complex)
+
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
+FIND_LIBRARY(CMAKE_LIB
+ CMakeLib
+ ${Complex_BINARY_DIR}/../../Source
+ ${Complex_BINARY_DIR}/../../Source/Debug
+ ${Complex_BINARY_DIR}/../../Source/Release
+ ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+ ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 5740dfc..b2f5162 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -3,16 +3,7 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
int passed = 0;
int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
void TestAndRemoveFile(const char* filename)
{
- struct stat fs;
- if (stat(filename, &fs) != 0)
+ if (!cmSystemTools::FileExists(filename))
{
Failed("Could not find file: ", filename);
}
else
{
- if (unlink(filename) != 0)
+ if (!cmSystemTools::RemoveFile(filename))
{
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
}
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
}
}
+void TestDir(const char* filename)
+{
+ if (!cmSystemTools::FileExists(filename))
+ {
+ Failed("Could not find dir: ", filename);
+ }
+ else
+ {
+ if (!cmSystemTools::FileIsDirectory(filename))
+ {
+ Failed("Unable to check if file is a directory: ", filename);
+ }
+ else
+ {
+ Passed("Find dir: ", filename);
+ }
+ }
+}
+
+
int main()
{
if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
}
#endif
- // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR3, "1") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+#endif
+
+ // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/postbuild.txt.
+ // ${Complex_BINARY_DIR}/Library/postbuild.txt.
- TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+ TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
- // A custom target has been created.
+ // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/custom_target1.txt.
+ // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+ TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+ // A directory has been created.
- TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+ TestDir(BINARY_DIR "/make_dir");
std::cout << "Passed: " << passed << "\n";
if(failed)
diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt
index 798b6e1..5d6c89f 100644
--- a/Tests/Complex/Library/CMakeLists.txt
+++ b/Tests/Complex/Library/CMakeLists.txt
@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
#
# Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
COMMAND ${CREATE_FILE_EXE}
- ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
TARGET CMakeTestLibraryShared)
#
# Add custom target
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
ADD_CUSTOM_TARGET(custom_target1
ALL
${CREATE_FILE_EXE}
- "${Complex_BINARY_DIR}/custom_target1.txt")
+ "${Complex_BINARY_DIR}/Library/custom_target1.txt")
ADD_DEPENDENCIES(custom_target1 create_file)
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")
diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in
index 3c3e2fa..52baea1 100644
--- a/Tests/Complex/cmTestConfigure.h.in
+++ b/Tests/Complex/cmTestConfigure.h.in
@@ -18,6 +18,10 @@
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"
-
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 10f270e..050cd3e 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# A simple test case
+# A more complex test case
#
PROJECT (Complex)
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
+#
+# More coverage
+#
+ABSTRACT_FILES(
+ ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+
diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
index f0df86f..4bd1620 100644
--- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
@@ -1,4 +1,20 @@
ADD_EXECUTABLE(complex complex)
+
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
+FIND_LIBRARY(CMAKE_LIB
+ CMakeLib
+ ${Complex_BINARY_DIR}/../../Source
+ ${Complex_BINARY_DIR}/../../Source/Debug
+ ${Complex_BINARY_DIR}/../../Source/Release
+ ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+ ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 5740dfc..b2f5162 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -3,16 +3,7 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
int passed = 0;
int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
void TestAndRemoveFile(const char* filename)
{
- struct stat fs;
- if (stat(filename, &fs) != 0)
+ if (!cmSystemTools::FileExists(filename))
{
Failed("Could not find file: ", filename);
}
else
{
- if (unlink(filename) != 0)
+ if (!cmSystemTools::RemoveFile(filename))
{
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
}
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
}
}
+void TestDir(const char* filename)
+{
+ if (!cmSystemTools::FileExists(filename))
+ {
+ Failed("Could not find dir: ", filename);
+ }
+ else
+ {
+ if (!cmSystemTools::FileIsDirectory(filename))
+ {
+ Failed("Unable to check if file is a directory: ", filename);
+ }
+ else
+ {
+ Passed("Find dir: ", filename);
+ }
+ }
+}
+
+
int main()
{
if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
}
#endif
- // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR3, "1") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+#endif
+
+ // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/postbuild.txt.
+ // ${Complex_BINARY_DIR}/Library/postbuild.txt.
- TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+ TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
- // A custom target has been created.
+ // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/custom_target1.txt.
+ // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+ TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+ // A directory has been created.
- TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+ TestDir(BINARY_DIR "/make_dir");
std::cout << "Passed: " << passed << "\n";
if(failed)
diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt
index 798b6e1..5d6c89f 100644
--- a/Tests/ComplexOneConfig/Library/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt
@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
#
# Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
COMMAND ${CREATE_FILE_EXE}
- ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
TARGET CMakeTestLibraryShared)
#
# Add custom target
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
ADD_CUSTOM_TARGET(custom_target1
ALL
${CREATE_FILE_EXE}
- "${Complex_BINARY_DIR}/custom_target1.txt")
+ "${Complex_BINARY_DIR}/Library/custom_target1.txt")
ADD_DEPENDENCIES(custom_target1 create_file)
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")
diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in
index 3c3e2fa..52baea1 100644
--- a/Tests/ComplexOneConfig/cmTestConfigure.h.in
+++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in
@@ -18,6 +18,10 @@
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"
-
diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt
index 10f270e..050cd3e 100644
--- a/Tests/ComplexRelativePaths/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# A simple test case
+# A more complex test case
#
PROJECT (Complex)
@@ -14,6 +14,8 @@ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.txt)
+LOAD_CACHE(${Complex_SOURCE_DIR})
+
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
@@ -59,3 +61,25 @@ IF (EXEC_PROGRAM)
EXEC_PROGRAM("echo EXEC_PROGRAM")
ENDIF (EXEC_PROGRAM)
+#
+# More coverage
+#
+ABSTRACT_FILES(
+ ExtraSources/file1.cxx
+)
+
+INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
+
+#
+# Create directory.
+# The 'complex' executable will then test if this dir exists,
+# sadly it won't be able to remove it.
+#
+MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
+
+#
+# Test Cable
+#
+CABLE_CLASS_SET(Float float)
+CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
+
diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
index f0df86f..4bd1620 100644
--- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
@@ -1,4 +1,20 @@
ADD_EXECUTABLE(complex complex)
+
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
+FIND_LIBRARY(CMAKE_LIB
+ CMakeLib
+ ${Complex_BINARY_DIR}/../../Source
+ ${Complex_BINARY_DIR}/../../Source/Debug
+ ${Complex_BINARY_DIR}/../../Source/Release
+ ${Complex_BINARY_DIR}/../../Source/MinSizeRel
+ ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
+
+TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
+LINK_LIBRARIES(${CMAKE_LIB})
+
+# More coverage
+
+INSTALL_TARGETS(/tmp complex)
+INSTALL_PROGRAMS(/tmp complex)
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 5740dfc..b2f5162 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -3,16 +3,7 @@
#include "file2.h"
#include "sharedFile.h"
#include "cmStandardIncludes.h"
-#include <sys/stat.h>
-#include <stdio.h>
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-#define _unlink unlink
-#else
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
+#include "cmSystemTools.h"
int passed = 0;
int failed = 0;
@@ -31,14 +22,13 @@ void Passed(const char* Message, const char* m2="")
void TestAndRemoveFile(const char* filename)
{
- struct stat fs;
- if (stat(filename, &fs) != 0)
+ if (!cmSystemTools::FileExists(filename))
{
Failed("Could not find file: ", filename);
}
else
{
- if (unlink(filename) != 0)
+ if (!cmSystemTools::RemoveFile(filename))
{
Failed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
}
@@ -49,6 +39,26 @@ void TestAndRemoveFile(const char* filename)
}
}
+void TestDir(const char* filename)
+{
+ if (!cmSystemTools::FileExists(filename))
+ {
+ Failed("Could not find dir: ", filename);
+ }
+ else
+ {
+ if (!cmSystemTools::FileIsDirectory(filename))
+ {
+ Failed("Unable to check if file is a directory: ", filename);
+ }
+ else
+ {
+ Passed("Find dir: ", filename);
+ }
+ }
+}
+
+
int main()
{
if(sharedFunction() != 1)
@@ -234,17 +244,66 @@ int main()
}
#endif
- // A post-build custom-command has been attached to the lib.
+#ifndef CACHE_TEST_VAR1
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR2
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
+ }
+#endif
+
+#ifndef CACHE_TEST_VAR3
+ Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 is not defined.");
+#else
+ if(strcmp(CACHE_TEST_VAR3, "1") != 0)
+ {
+ Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
+ "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+ else
+ {
+ Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
+ }
+#endif
+
+ // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/postbuild.txt.
+ // ${Complex_BINARY_DIR}/Library/postbuild.txt.
- TestAndRemoveFile(BINARY_DIR "/postbuild.txt");
+ TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
- // A custom target has been created.
+ // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/custom_target1.txt.
+ // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+
+ TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+
+ // A directory has been created.
- TestAndRemoveFile(BINARY_DIR "/custom_target1.txt");
+ TestDir(BINARY_DIR "/make_dir");
std::cout << "Passed: " << passed << "\n";
if(failed)
diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt
index 798b6e1..5d6c89f 100644
--- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt
@@ -17,7 +17,7 @@ ADD_EXECUTABLE(create_file create_file.cxx)
#
# Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/postbuild.txt.
+# ${Complex_BINARY_DIR}/Library/postbuild.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
@@ -25,20 +25,23 @@ ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
COMMAND ${CREATE_FILE_EXE}
- ARGS "${Complex_BINARY_DIR}/postbuild.txt"
+ ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
TARGET CMakeTestLibraryShared)
#
# Add custom target
# It run ${CREATE_FILE_EXE} which will create the file
-# ${Complex_BINARY_DIR}/custom_target1.txt.
+# ${Complex_BINARY_DIR}/Library/custom_target1.txt.
# The 'complex' executable will then test if this file exists,
# and remove it.
#
ADD_CUSTOM_TARGET(custom_target1
ALL
${CREATE_FILE_EXE}
- "${Complex_BINARY_DIR}/custom_target1.txt")
+ "${Complex_BINARY_DIR}/Library/custom_target1.txt")
ADD_DEPENDENCIES(custom_target1 create_file)
+# More coverage
+
+SOURCE_GROUP(A_GROUP ".cxx")
diff --git a/Tests/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in
index 3c3e2fa..52baea1 100644
--- a/Tests/ComplexRelativePaths/cmTestConfigure.h.in
+++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in
@@ -18,6 +18,10 @@
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
+#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
+#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
+#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
+
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"
@@ -27,4 +31,3 @@
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"
-