More tests + coverage
This commit is contained in:
parent
df5131adc2
commit
049a4820a2
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
||||||
|
|
||||||
//A var.
|
//A var.
|
||||||
CACHE_TEST_VAR3:BOOL=1
|
CACHE_TEST_VAR3:BOOL=1
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
# INTERNAL cache entries
|
||||||
|
########################
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||||
|
|
|
@ -19,7 +19,11 @@ IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
|
|
||||||
LOAD_CACHE(${Complex_SOURCE_DIR})
|
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||||
|
EXCLUDE
|
||||||
|
CACHE_TEST_VAR_EXCLUDED
|
||||||
|
INCLUDE_INTERNALS
|
||||||
|
CACHE_TEST_VAR_INTERNAL)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
||||||
|
|
||||||
#
|
#
|
||||||
# Specify include and lib dirs
|
# Specify include and lib dirs
|
||||||
|
# (BEFORE is for coverage)
|
||||||
#
|
#
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${Complex_BINARY_DIR}
|
|
||||||
${Complex_SOURCE_DIR}/Library
|
${Complex_SOURCE_DIR}/Library
|
||||||
${Complex_SOURCE_DIR}/../../Source
|
${Complex_SOURCE_DIR}/../../Source
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(BEFORE
|
||||||
|
${Complex_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||||
|
|
||||||
LINK_DIRECTORIES(
|
LINK_DIRECTORIES(
|
||||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
||||||
# Exec program (TODO: test a result)
|
# Exec program (TODO: test a result)
|
||||||
# Increase coverage.
|
# Increase coverage.
|
||||||
#
|
#
|
||||||
|
MESSAGE("Trying to increase coverage...")
|
||||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||||
IF (NOT NO_EXEC_PROGRAM)
|
IF (NOT NO_EXEC_PROGRAM)
|
||||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Output the files required by 'complex' to a file.
|
||||||
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
|
# The contents of this file is not tested (absolute paths).
|
||||||
|
#
|
||||||
|
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||||
|
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Extra coverage.Not used.
|
# Extra coverage.Not used.
|
||||||
#
|
#
|
||||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
||||||
INSTALL_PROGRAMS(/tmp complex)
|
INSTALL_PROGRAMS(/tmp complex)
|
||||||
|
|
||||||
SOURCE_GROUP(A_GROUP ".cxx")
|
SOURCE_GROUP(A_GROUP ".cxx")
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
int passed = 0;
|
int cm_passed = 0;
|
||||||
int failed = 0;
|
int cm_failed = 0;
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Failed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||||
failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Passed(const char* Message, const char* m2="")
|
void cmPassed(const char* Message, const char* m2="")
|
||||||
{
|
{
|
||||||
std::cout << "Passed: " << Message << m2 << "\n";
|
std::cout << "Passed: " << Message << m2 << "\n";
|
||||||
passed++;
|
cm_passed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find file: ", filename);
|
cmFailed("Could not find file: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::RemoveFile(filename))
|
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);
|
cmFailed("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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find and remove file: ", filename);
|
cmPassed("Find and remove file: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find dir: ", filename);
|
cmFailed("Could not find dir: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileIsDirectory(filename))
|
if (!cmSystemTools::FileIsDirectory(filename))
|
||||||
{
|
{
|
||||||
Failed("Unable to check if file is a directory: ", filename);
|
cmFailed("Unable to check if file is a directory: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find dir: ", filename);
|
cmPassed("Find dir: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,85 +72,85 @@ int main()
|
||||||
{
|
{
|
||||||
if(sharedFunction() != 1)
|
if(sharedFunction() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to sharedFunction from shared library failed.");
|
cmFailed("Call to sharedFunction from shared library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to sharedFunction from shared library worked.");
|
cmPassed("Call to sharedFunction from shared library worked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file1() != 1)
|
if(file1() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file1 function from library failed.");
|
cmFailed("Call to file1 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file1 function returned 1.");
|
cmPassed("Call to file1 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file2() != 1)
|
if(file2() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file2 function from library failed.");
|
cmFailed("Call to file2 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file2 function returned 1.");
|
cmPassed("Call to file2 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test ADD_DEFINITIONS
|
// Test ADD_DEFINITIONS
|
||||||
|
|
||||||
#ifndef CMAKE_IS_FUN
|
#ifndef CMAKE_IS_FUN
|
||||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||||
#else
|
#else
|
||||||
Passed("CMAKE_IS_FUN is defined.");
|
cmPassed("CMAKE_IS_FUN is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test SET, VARIABLE_REQUIRES
|
// Test SET, VARIABLE_REQUIRES
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED
|
#ifdef SHOULD_NOT_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED
|
#ifndef SHOULD_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED is defined.");
|
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR
|
#ifndef ONE_VAR
|
||||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR is defined.");
|
cmPassed("ONE_VAR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR_IS_DEFINED
|
#ifndef ONE_VAR_IS_DEFINED
|
||||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||||
"ONE_VAR_IS_DEFINED is not defined.");
|
"ONE_VAR_IS_DEFINED is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZERO_VAR
|
#ifdef ZERO_VAR
|
||||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ZERO_VAR is not defined.");
|
cmPassed("ZERO_VAR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STRING_VAR
|
#ifndef STRING_VAR
|
||||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||||
{
|
{
|
||||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||||
STRING_VAR);
|
STRING_VAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("STRING_VAR == ", STRING_VAR);
|
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,71 +158,83 @@ int main()
|
||||||
// Test various IF/ELSE combinations
|
// Test various IF/ELSE combinations
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_AND
|
#ifndef SHOULD_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
cmPassed("SHOULD_BE_DEFINED_AND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_OR
|
#ifndef SHOULD_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
cmPassed("SHOULD_BE_DEFINED_OR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_MATCHES
|
#ifndef SHOULD_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test FOREACH
|
// Test FOREACH
|
||||||
|
|
||||||
#ifndef FOREACH_VAR1
|
#ifndef FOREACH_VAR1
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 is not defined.");
|
"FOREACH_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FOREACH_VAR2
|
#ifndef FOREACH_VAR2
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 is not defined.");
|
"FOREACH_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,77 +242,77 @@ int main()
|
||||||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_PATH_NAME
|
#ifndef FILENAME_VAR_PATH_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME
|
#ifndef FILENAME_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME is not defined.");
|
"FILENAME_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_EXT
|
#ifndef FILENAME_VAR_EXT
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT is not defined.");
|
"FILENAME_VAR_EXT is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME_WE
|
#ifndef FILENAME_VAR_NAME_WE
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE is not defined.");
|
"FILENAME_VAR_NAME_WE is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_VAR_NAME
|
#ifndef PATH_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME is not defined.");
|
"PATH_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -308,47 +320,69 @@ int main()
|
||||||
// Test LOAD_CACHE
|
// Test LOAD_CACHE
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR1
|
#ifndef CACHE_TEST_VAR1
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 is not defined.");
|
"CACHE_TEST_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR2
|
#ifndef CACHE_TEST_VAR2
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 is not defined.");
|
"CACHE_TEST_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR3
|
#ifndef CACHE_TEST_VAR3
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 is not defined.");
|
"CACHE_TEST_VAR3 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||||
|
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||||
|
#else
|
||||||
|
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -369,14 +403,21 @@ int main()
|
||||||
|
|
||||||
TestDir(BINARY_DIR "/make_dir");
|
TestDir(BINARY_DIR "/make_dir");
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test OUTPUT_REQUIRED_FILES
|
||||||
|
// The files required by 'complex' have been output to a file.
|
||||||
|
// The contents of this file is not tested (absolute paths).
|
||||||
|
|
||||||
|
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
std::cout << "Passed: " << passed << "\n";
|
std::cout << "Passed: " << cm_passed << "\n";
|
||||||
if(failed)
|
if(cm_failed)
|
||||||
{
|
{
|
||||||
std::cout << "Failed: " << failed << "\n";
|
std::cout << "Failed: " << cm_failed << "\n";
|
||||||
return failed;
|
return cm_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
||||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||||
|
|
||||||
|
IF(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||||
|
ELSE(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||||
|
ENDIF(COMMAND "IF")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test FOREACH
|
# Test FOREACH
|
||||||
#
|
#
|
||||||
|
@ -58,5 +64,5 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
||||||
|
|
||||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||||
|
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||||
|
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||||
|
|
||||||
// Test internal CMake vars from C++ flags
|
// Test internal CMake vars from C++ flags
|
||||||
|
|
||||||
|
|
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
||||||
|
|
||||||
//A var.
|
//A var.
|
||||||
CACHE_TEST_VAR3:BOOL=1
|
CACHE_TEST_VAR3:BOOL=1
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
# INTERNAL cache entries
|
||||||
|
########################
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||||
|
|
|
@ -19,7 +19,11 @@ IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
|
|
||||||
LOAD_CACHE(${Complex_SOURCE_DIR})
|
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||||
|
EXCLUDE
|
||||||
|
CACHE_TEST_VAR_EXCLUDED
|
||||||
|
INCLUDE_INTERNALS
|
||||||
|
CACHE_TEST_VAR_INTERNAL)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
||||||
|
|
||||||
#
|
#
|
||||||
# Specify include and lib dirs
|
# Specify include and lib dirs
|
||||||
|
# (BEFORE is for coverage)
|
||||||
#
|
#
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${Complex_BINARY_DIR}
|
|
||||||
${Complex_SOURCE_DIR}/Library
|
${Complex_SOURCE_DIR}/Library
|
||||||
${Complex_SOURCE_DIR}/../../Source
|
${Complex_SOURCE_DIR}/../../Source
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(BEFORE
|
||||||
|
${Complex_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||||
|
|
||||||
LINK_DIRECTORIES(
|
LINK_DIRECTORIES(
|
||||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
||||||
# Exec program (TODO: test a result)
|
# Exec program (TODO: test a result)
|
||||||
# Increase coverage.
|
# Increase coverage.
|
||||||
#
|
#
|
||||||
|
MESSAGE("Trying to increase coverage...")
|
||||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||||
IF (NOT NO_EXEC_PROGRAM)
|
IF (NOT NO_EXEC_PROGRAM)
|
||||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Output the files required by 'complex' to a file.
|
||||||
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
|
# The contents of this file is not tested (absolute paths).
|
||||||
|
#
|
||||||
|
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||||
|
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Extra coverage.Not used.
|
# Extra coverage.Not used.
|
||||||
#
|
#
|
||||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
||||||
INSTALL_PROGRAMS(/tmp complex)
|
INSTALL_PROGRAMS(/tmp complex)
|
||||||
|
|
||||||
SOURCE_GROUP(A_GROUP ".cxx")
|
SOURCE_GROUP(A_GROUP ".cxx")
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
int passed = 0;
|
int cm_passed = 0;
|
||||||
int failed = 0;
|
int cm_failed = 0;
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Failed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||||
failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Passed(const char* Message, const char* m2="")
|
void cmPassed(const char* Message, const char* m2="")
|
||||||
{
|
{
|
||||||
std::cout << "Passed: " << Message << m2 << "\n";
|
std::cout << "Passed: " << Message << m2 << "\n";
|
||||||
passed++;
|
cm_passed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find file: ", filename);
|
cmFailed("Could not find file: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::RemoveFile(filename))
|
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);
|
cmFailed("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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find and remove file: ", filename);
|
cmPassed("Find and remove file: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find dir: ", filename);
|
cmFailed("Could not find dir: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileIsDirectory(filename))
|
if (!cmSystemTools::FileIsDirectory(filename))
|
||||||
{
|
{
|
||||||
Failed("Unable to check if file is a directory: ", filename);
|
cmFailed("Unable to check if file is a directory: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find dir: ", filename);
|
cmPassed("Find dir: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,85 +72,85 @@ int main()
|
||||||
{
|
{
|
||||||
if(sharedFunction() != 1)
|
if(sharedFunction() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to sharedFunction from shared library failed.");
|
cmFailed("Call to sharedFunction from shared library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to sharedFunction from shared library worked.");
|
cmPassed("Call to sharedFunction from shared library worked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file1() != 1)
|
if(file1() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file1 function from library failed.");
|
cmFailed("Call to file1 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file1 function returned 1.");
|
cmPassed("Call to file1 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file2() != 1)
|
if(file2() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file2 function from library failed.");
|
cmFailed("Call to file2 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file2 function returned 1.");
|
cmPassed("Call to file2 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test ADD_DEFINITIONS
|
// Test ADD_DEFINITIONS
|
||||||
|
|
||||||
#ifndef CMAKE_IS_FUN
|
#ifndef CMAKE_IS_FUN
|
||||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||||
#else
|
#else
|
||||||
Passed("CMAKE_IS_FUN is defined.");
|
cmPassed("CMAKE_IS_FUN is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test SET, VARIABLE_REQUIRES
|
// Test SET, VARIABLE_REQUIRES
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED
|
#ifdef SHOULD_NOT_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED
|
#ifndef SHOULD_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED is defined.");
|
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR
|
#ifndef ONE_VAR
|
||||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR is defined.");
|
cmPassed("ONE_VAR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR_IS_DEFINED
|
#ifndef ONE_VAR_IS_DEFINED
|
||||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||||
"ONE_VAR_IS_DEFINED is not defined.");
|
"ONE_VAR_IS_DEFINED is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZERO_VAR
|
#ifdef ZERO_VAR
|
||||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ZERO_VAR is not defined.");
|
cmPassed("ZERO_VAR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STRING_VAR
|
#ifndef STRING_VAR
|
||||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||||
{
|
{
|
||||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||||
STRING_VAR);
|
STRING_VAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("STRING_VAR == ", STRING_VAR);
|
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,71 +158,83 @@ int main()
|
||||||
// Test various IF/ELSE combinations
|
// Test various IF/ELSE combinations
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_AND
|
#ifndef SHOULD_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
cmPassed("SHOULD_BE_DEFINED_AND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_OR
|
#ifndef SHOULD_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
cmPassed("SHOULD_BE_DEFINED_OR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_MATCHES
|
#ifndef SHOULD_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test FOREACH
|
// Test FOREACH
|
||||||
|
|
||||||
#ifndef FOREACH_VAR1
|
#ifndef FOREACH_VAR1
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 is not defined.");
|
"FOREACH_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FOREACH_VAR2
|
#ifndef FOREACH_VAR2
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 is not defined.");
|
"FOREACH_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,77 +242,77 @@ int main()
|
||||||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_PATH_NAME
|
#ifndef FILENAME_VAR_PATH_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME
|
#ifndef FILENAME_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME is not defined.");
|
"FILENAME_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_EXT
|
#ifndef FILENAME_VAR_EXT
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT is not defined.");
|
"FILENAME_VAR_EXT is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME_WE
|
#ifndef FILENAME_VAR_NAME_WE
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE is not defined.");
|
"FILENAME_VAR_NAME_WE is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_VAR_NAME
|
#ifndef PATH_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME is not defined.");
|
"PATH_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -308,47 +320,69 @@ int main()
|
||||||
// Test LOAD_CACHE
|
// Test LOAD_CACHE
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR1
|
#ifndef CACHE_TEST_VAR1
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 is not defined.");
|
"CACHE_TEST_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR2
|
#ifndef CACHE_TEST_VAR2
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 is not defined.");
|
"CACHE_TEST_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR3
|
#ifndef CACHE_TEST_VAR3
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 is not defined.");
|
"CACHE_TEST_VAR3 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||||
|
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||||
|
#else
|
||||||
|
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -369,14 +403,21 @@ int main()
|
||||||
|
|
||||||
TestDir(BINARY_DIR "/make_dir");
|
TestDir(BINARY_DIR "/make_dir");
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test OUTPUT_REQUIRED_FILES
|
||||||
|
// The files required by 'complex' have been output to a file.
|
||||||
|
// The contents of this file is not tested (absolute paths).
|
||||||
|
|
||||||
|
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
std::cout << "Passed: " << passed << "\n";
|
std::cout << "Passed: " << cm_passed << "\n";
|
||||||
if(failed)
|
if(cm_failed)
|
||||||
{
|
{
|
||||||
std::cout << "Failed: " << failed << "\n";
|
std::cout << "Failed: " << cm_failed << "\n";
|
||||||
return failed;
|
return cm_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
||||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||||
|
|
||||||
|
IF(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||||
|
ELSE(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||||
|
ENDIF(COMMAND "IF")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test FOREACH
|
# Test FOREACH
|
||||||
#
|
#
|
||||||
|
@ -58,5 +64,5 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
||||||
|
|
||||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||||
|
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||||
|
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||||
|
|
||||||
// Test internal CMake vars from C++ flags
|
// Test internal CMake vars from C++ flags
|
||||||
|
|
||||||
|
|
|
@ -21,3 +21,14 @@ CACHE_TEST_VAR2:FILEPATH=bar
|
||||||
|
|
||||||
//A var.
|
//A var.
|
||||||
CACHE_TEST_VAR3:BOOL=1
|
CACHE_TEST_VAR3:BOOL=1
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_EXCLUDED:BOOL=1
|
||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
# INTERNAL cache entries
|
||||||
|
########################
|
||||||
|
|
||||||
|
//A var.
|
||||||
|
CACHE_TEST_VAR_INTERNAL:INTERNAL=bar
|
||||||
|
|
|
@ -19,7 +19,11 @@ IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
||||||
|
|
||||||
LOAD_CACHE(${Complex_SOURCE_DIR})
|
LOAD_CACHE(${Complex_SOURCE_DIR}
|
||||||
|
EXCLUDE
|
||||||
|
CACHE_TEST_VAR_EXCLUDED
|
||||||
|
INCLUDE_INTERNALS
|
||||||
|
CACHE_TEST_VAR_INTERNAL)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure file
|
# Configure file
|
||||||
|
@ -31,13 +35,17 @@ CONFIGURE_FILE(
|
||||||
|
|
||||||
#
|
#
|
||||||
# Specify include and lib dirs
|
# Specify include and lib dirs
|
||||||
|
# (BEFORE is for coverage)
|
||||||
#
|
#
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${Complex_BINARY_DIR}
|
|
||||||
${Complex_SOURCE_DIR}/Library
|
${Complex_SOURCE_DIR}/Library
|
||||||
${Complex_SOURCE_DIR}/../../Source
|
${Complex_SOURCE_DIR}/../../Source
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(BEFORE
|
||||||
|
${Complex_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
|
||||||
|
|
||||||
LINK_DIRECTORIES(
|
LINK_DIRECTORIES(
|
||||||
|
@ -65,6 +73,7 @@ SUBDIR_DEPENDS(Executable Library)
|
||||||
# Exec program (TODO: test a result)
|
# Exec program (TODO: test a result)
|
||||||
# Increase coverage.
|
# Increase coverage.
|
||||||
#
|
#
|
||||||
|
MESSAGE("Trying to increase coverage...")
|
||||||
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
|
||||||
IF (NOT NO_EXEC_PROGRAM)
|
IF (NOT NO_EXEC_PROGRAM)
|
||||||
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}")
|
||||||
|
|
|
@ -19,6 +19,14 @@ FIND_LIBRARY(CMAKE_LIB
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Output the files required by 'complex' to a file.
|
||||||
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
|
# The contents of this file is not tested (absolute paths).
|
||||||
|
#
|
||||||
|
#OUTPUT_REQUIRED_FILES(${Complex_SOURCE_DIR}/Executable/complex.cxx
|
||||||
|
# ${Complex_BINARY_DIR}/Executable/complex-required.txt)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Extra coverage.Not used.
|
# Extra coverage.Not used.
|
||||||
#
|
#
|
||||||
|
@ -26,3 +34,4 @@ INSTALL_TARGETS(/tmp complex)
|
||||||
INSTALL_PROGRAMS(/tmp complex)
|
INSTALL_PROGRAMS(/tmp complex)
|
||||||
|
|
||||||
SOURCE_GROUP(A_GROUP ".cxx")
|
SOURCE_GROUP(A_GROUP ".cxx")
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,23 @@
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
int passed = 0;
|
int cm_passed = 0;
|
||||||
int failed = 0;
|
int cm_failed = 0;
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Failed(const char* Message, const char* m2= "")
|
void cmFailed(const char* Message, const char* m2= "")
|
||||||
{
|
{
|
||||||
std::cerr << "Failed: " << Message << m2 << "\n";
|
std::cerr << "Failed: " << Message << m2 << "\n";
|
||||||
failed++;
|
cm_failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
void Passed(const char* Message, const char* m2="")
|
void cmPassed(const char* Message, const char* m2="")
|
||||||
{
|
{
|
||||||
std::cout << "Passed: " << Message << m2 << "\n";
|
std::cout << "Passed: " << Message << m2 << "\n";
|
||||||
passed++;
|
cm_passed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
@ -30,17 +30,17 @@ void TestAndRemoveFile(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find file: ", filename);
|
cmFailed("Could not find file: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::RemoveFile(filename))
|
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);
|
cmFailed("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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find and remove file: ", filename);
|
cmPassed("Find and remove file: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,17 +51,17 @@ void TestDir(const char* filename)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename))
|
if (!cmSystemTools::FileExists(filename))
|
||||||
{
|
{
|
||||||
Failed("Could not find dir: ", filename);
|
cmFailed("Could not find dir: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileIsDirectory(filename))
|
if (!cmSystemTools::FileIsDirectory(filename))
|
||||||
{
|
{
|
||||||
Failed("Unable to check if file is a directory: ", filename);
|
cmFailed("Unable to check if file is a directory: ", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Find dir: ", filename);
|
cmPassed("Find dir: ", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,85 +72,85 @@ int main()
|
||||||
{
|
{
|
||||||
if(sharedFunction() != 1)
|
if(sharedFunction() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to sharedFunction from shared library failed.");
|
cmFailed("Call to sharedFunction from shared library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to sharedFunction from shared library worked.");
|
cmPassed("Call to sharedFunction from shared library worked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file1() != 1)
|
if(file1() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file1 function from library failed.");
|
cmFailed("Call to file1 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file1 function returned 1.");
|
cmPassed("Call to file1 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file2() != 1)
|
if(file2() != 1)
|
||||||
{
|
{
|
||||||
Failed("Call to file2 function from library failed.");
|
cmFailed("Call to file2 function from library failed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("Call to file2 function returned 1.");
|
cmPassed("Call to file2 function returned 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test ADD_DEFINITIONS
|
// Test ADD_DEFINITIONS
|
||||||
|
|
||||||
#ifndef CMAKE_IS_FUN
|
#ifndef CMAKE_IS_FUN
|
||||||
Failed("CMake is not fun, so it is broken and should be fixed.");
|
cmFailed("CMake is not fun, so it is broken and should be fixed.");
|
||||||
#else
|
#else
|
||||||
Passed("CMAKE_IS_FUN is defined.");
|
cmPassed("CMAKE_IS_FUN is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test SET, VARIABLE_REQUIRES
|
// Test SET, VARIABLE_REQUIRES
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED
|
#ifdef SHOULD_NOT_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED
|
#ifndef SHOULD_BE_DEFINED
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED is defined.");
|
cmPassed("SHOULD_BE_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR
|
#ifndef ONE_VAR
|
||||||
Failed("cmakedefine is broken, ONE_VAR is not defined.");
|
cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR is defined.");
|
cmPassed("ONE_VAR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ONE_VAR_IS_DEFINED
|
#ifndef ONE_VAR_IS_DEFINED
|
||||||
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
|
||||||
"ONE_VAR_IS_DEFINED is not defined.");
|
"ONE_VAR_IS_DEFINED is not defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ONE_VAR_IS_DEFINED is defined.");
|
cmPassed("ONE_VAR_IS_DEFINED is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZERO_VAR
|
#ifdef ZERO_VAR
|
||||||
Failed("cmakedefine is broken, ZERO_VAR is defined.");
|
cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("ZERO_VAR is not defined.");
|
cmPassed("ZERO_VAR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STRING_VAR
|
#ifndef STRING_VAR
|
||||||
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
if(strcmp(STRING_VAR, "CMake is great") != 0)
|
||||||
{
|
{
|
||||||
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
|
||||||
STRING_VAR);
|
STRING_VAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("STRING_VAR == ", STRING_VAR);
|
cmPassed("STRING_VAR == ", STRING_VAR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -158,71 +158,83 @@ int main()
|
||||||
// Test various IF/ELSE combinations
|
// Test various IF/ELSE combinations
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
#ifdef SHOULD_NOT_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_AND
|
#ifndef SHOULD_BE_DEFINED_AND
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_AND is defined.");
|
cmPassed("SHOULD_BE_DEFINED_AND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
#ifdef SHOULD_NOT_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_OR
|
#ifndef SHOULD_BE_DEFINED_OR
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_OR is defined.");
|
cmPassed("SHOULD_BE_DEFINED_OR is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
#ifdef SHOULD_NOT_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHOULD_BE_DEFINED_MATCHES
|
#ifndef SHOULD_BE_DEFINED_MATCHES
|
||||||
Failed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
|
||||||
#else
|
#else
|
||||||
Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SHOULD_NOT_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SHOULD_BE_DEFINED_COMMAND
|
||||||
|
cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
|
||||||
|
#else
|
||||||
|
cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Test FOREACH
|
// Test FOREACH
|
||||||
|
|
||||||
#ifndef FOREACH_VAR1
|
#ifndef FOREACH_VAR1
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 is not defined.");
|
"FOREACH_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
"FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FOREACH_VAR2
|
#ifndef FOREACH_VAR2
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 is not defined.");
|
"FOREACH_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
||||||
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
"FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,77 +242,77 @@ int main()
|
||||||
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_PATH_NAME
|
#ifndef FILENAME_VAR_PATH_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME is not defined.");
|
"FILENAME_VAR_PATH_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
if(strcmp(FILENAME_VAR_PATH_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
"FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME
|
#ifndef FILENAME_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME is not defined.");
|
"FILENAME_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
"FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_EXT
|
#ifndef FILENAME_VAR_EXT
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT is not defined.");
|
"FILENAME_VAR_EXT is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
"FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FILENAME_VAR_NAME_WE
|
#ifndef FILENAME_VAR_NAME_WE
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE is not defined.");
|
"FILENAME_VAR_NAME_WE is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
"FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_VAR_NAME
|
#ifndef PATH_VAR_NAME
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME is not defined.");
|
"PATH_VAR_NAME is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
if(strcmp(PATH_VAR_NAME, "Complex") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
|
||||||
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
"PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -308,47 +320,69 @@ int main()
|
||||||
// Test LOAD_CACHE
|
// Test LOAD_CACHE
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR1
|
#ifndef CACHE_TEST_VAR1
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 is not defined.");
|
"CACHE_TEST_VAR1 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
"CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR2
|
#ifndef CACHE_TEST_VAR2
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 is not defined.");
|
"CACHE_TEST_VAR2 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
"CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CACHE_TEST_VAR3
|
#ifndef CACHE_TEST_VAR3
|
||||||
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 is not defined.");
|
"CACHE_TEST_VAR3 is not defined.");
|
||||||
#else
|
#else
|
||||||
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
if(strcmp(CACHE_TEST_VAR3, "1") != 0)
|
||||||
{
|
{
|
||||||
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
"CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Passed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CACHE_TEST_VAR_EXCLUDED
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
|
||||||
|
"CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
|
||||||
|
#else
|
||||||
|
cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CACHE_TEST_VAR_INTERNAL
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL is not defined.");
|
||||||
|
#else
|
||||||
|
if(strcmp(CACHE_TEST_VAR_INTERNAL, "bar") != 0)
|
||||||
|
{
|
||||||
|
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
|
||||||
|
"CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -369,14 +403,21 @@ int main()
|
||||||
|
|
||||||
TestDir(BINARY_DIR "/make_dir");
|
TestDir(BINARY_DIR "/make_dir");
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Test OUTPUT_REQUIRED_FILES
|
||||||
|
// The files required by 'complex' have been output to a file.
|
||||||
|
// The contents of this file is not tested (absolute paths).
|
||||||
|
|
||||||
|
TestAndRemoveFile(BINARY_DIR "/Executable/complex-required.txt");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
|
||||||
std::cout << "Passed: " << passed << "\n";
|
std::cout << "Passed: " << cm_passed << "\n";
|
||||||
if(failed)
|
if(cm_failed)
|
||||||
{
|
{
|
||||||
std::cout << "Failed: " << failed << "\n";
|
std::cout << "Failed: " << cm_failed << "\n";
|
||||||
return failed;
|
return cm_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,4 +54,5 @@ ABSTRACT_FILES(
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ ELSE(STRING_VAR MATCHES "^CMake")
|
||||||
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
||||||
ENDIF(STRING_VAR MATCHES "^CMake")
|
ENDIF(STRING_VAR MATCHES "^CMake")
|
||||||
|
|
||||||
|
IF(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
||||||
|
ELSE(COMMAND "IF")
|
||||||
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
||||||
|
ENDIF(COMMAND "IF")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test FOREACH
|
# Test FOREACH
|
||||||
#
|
#
|
||||||
|
@ -58,5 +64,5 @@ GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
||||||
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
||||||
|
|
||||||
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
||||||
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
|
||||||
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
|
||||||
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
|
||||||
|
#cmakedefine CACHE_TEST_VAR_EXCLUDED
|
||||||
|
#define CACHE_TEST_VAR_INTERNAL "${CACHE_TEST_VAR_INTERNAL}"
|
||||||
|
|
||||||
// Test internal CMake vars from C++ flags
|
// Test internal CMake vars from C++ flags
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue