summaryrefslogtreecommitdiffstats
path: root/Tests/ComplexRelativePaths/Executable
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/ComplexRelativePaths/Executable')
-rw-r--r--Tests/ComplexRelativePaths/Executable/CMakeLists.txt16
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx103
2 files changed, 76 insertions, 43 deletions
diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
index 15808b4..26d3df5 100644
--- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
@@ -1,8 +1,14 @@
+#
+# Create exe.
+#
ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
+#
+# Link to CMake lib
+#
FIND_LIBRARY(CMAKE_LIB
CMakeLib
${Complex_BINARY_DIR}/../../Source
@@ -12,15 +18,11 @@ FIND_LIBRARY(CMAKE_LIB
${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
-LINK_LIBRARIES(${CMAKE_LIB})
#
-# Testing
-#
-ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
-
-#
-# More coverage
+# Extra coverage.Not used.
#
INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex)
+
+SOURCE_GROUP(A_GROUP ".cxx")
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 6a55b5c..21576e9 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -8,18 +8,24 @@
int passed = 0;
int failed = 0;
+// ======================================================================
+
void Failed(const char* Message, const char* m2= "")
{
std::cerr << "Failed: " << Message << m2 << "\n";
failed++;
}
+// ======================================================================
+
void Passed(const char* Message, const char* m2="")
{
std::cout << "Passed: " << Message << m2 << "\n";
passed++;
}
+// ======================================================================
+
void TestAndRemoveFile(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
@@ -39,6 +45,8 @@ void TestAndRemoveFile(const char* filename)
}
}
+// ======================================================================
+
void TestDir(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
@@ -58,6 +66,7 @@ void TestDir(const char* filename)
}
}
+// ======================================================================
int main()
{
@@ -88,12 +97,18 @@ int main()
Passed("Call to file2 function returned 1.");
}
+ // ----------------------------------------------------------------------
+ // Test ADD_DEFINITIONS
+
#ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed.");
#else
Passed("CMAKE_IS_FUN is defined.");
#endif
+ // ----------------------------------------------------------------------
+ // Test SET, VARIABLE_REQUIRES
+
#ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else
@@ -106,6 +121,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined.");
#endif
+#ifndef ONE_VAR
+ Failed("cmakedefine is broken, ONE_VAR is not defined.");
+#else
+ Passed("ONE_VAR is defined.");
+#endif
+
+#ifndef ONE_VAR_IS_DEFINED
+ Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
+ "ONE_VAR_IS_DEFINED is not defined.");
+#else
+ Passed("ONE_VAR_IS_DEFINED is defined.");
+#endif
+
+#ifdef ZERO_VAR
+ Failed("cmakedefine is broken, ZERO_VAR is defined.");
+#else
+ Passed("ZERO_VAR is not defined.");
+#endif
+
+#ifndef STRING_VAR
+ Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
+#else
+ if(strcmp(STRING_VAR, "CMake is great") != 0)
+ {
+ Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
+ STRING_VAR);
+ }
+ else
+ {
+ Passed("STRING_VAR == ", STRING_VAR);
+ }
+#endif
+
+ // ----------------------------------------------------------------------
+ // Test various IF/ELSE combinations
+
#ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else
@@ -142,38 +193,8 @@ int main()
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif
-#ifndef ONE_VAR
- Failed("cmakedefine is broken, ONE_VAR is not defined.");
-#else
- Passed("ONE_VAR is defined.");
-#endif
-
-#ifndef ONE_VAR_IS_DEFINED
- Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
- "ONE_VAR_IS_DEFINED is not defined.");
-#else
- Passed("ONE_VAR_IS_DEFINED is defined.");
-#endif
-
-#ifdef ZERO_VAR
- Failed("cmakedefine is broken, ZERO_VAR is defined.");
-#else
- Passed("ZERO_VAR is not defined.");
-#endif
-
-#ifndef STRING_VAR
- Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
-#else
- if(strcmp(STRING_VAR, "CMake is great") != 0)
- {
- Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
- STRING_VAR);
- }
- else
- {
- Passed("STRING_VAR == ", STRING_VAR);
- }
-#endif
+ // ----------------------------------------------------------------------
+ // Test FOREACH
#ifndef FOREACH_VAR1
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@@ -205,6 +226,9 @@ int main()
}
#endif
+ // ----------------------------------------------------------------------
+ // Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
+
#ifndef FILENAME_VAR_PATH_NAME
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_PATH_NAME is not defined.");
@@ -280,6 +304,9 @@ int main()
}
#endif
+ // ----------------------------------------------------------------------
+ // Test LOAD_CACHE
+
#ifndef CACHE_TEST_VAR1
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
"CACHE_TEST_VAR1 is not defined.");
@@ -325,22 +352,26 @@ int main()
}
#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}/Library/postbuild.txt.
+ // It runs ${CREATE_FILE_EXE} which will create a file.
TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
+ // ----------------------------------------------------------------------
// A custom target has been created (see Library/).
- // It run ${CREATE_FILE_EXE} which will create the file
- // ${Complex_BINARY_DIR}/Library/custom_target1.txt.
+ // It runs ${CREATE_FILE_EXE} which will create a file.
TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
+ // ----------------------------------------------------------------------
// A directory has been created.
TestDir(BINARY_DIR "/make_dir");
+ // ----------------------------------------------------------------------
+ // Summary
+
std::cout << "Passed: " << passed << "\n";
if(failed)
{