mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
Add documentation, comments. Move some 'Complex' sub-tests into 2 new 'Wrapping' and 'Testing' tests.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user