2001-08-23 21:57:45 +04:00
# include "cmTestConfigure.h"
# include "ExtraSources/file1.h"
# include "file2.h"
# include "sharedFile.h"
# include "cmStandardIncludes.h"
2002-01-19 03:21:43 +03:00
# include "cmSystemTools.h"
2001-08-23 21:57:45 +04:00
2002-01-20 08:12:27 +03:00
int cm_passed = 0 ;
int cm_failed = 0 ;
2001-08-23 21:57:45 +04:00
2002-01-20 05:24:55 +03:00
// ======================================================================
2002-01-20 08:12:27 +03:00
void cmFailed ( const char * Message , const char * m2 = " " )
2001-08-23 21:57:45 +04:00
{
std : : cerr < < " Failed: " < < Message < < m2 < < " \n " ;
2002-01-20 08:12:27 +03:00
cm_failed + + ;
2001-08-23 21:57:45 +04:00
}
2002-01-20 05:24:55 +03:00
// ======================================================================
2002-01-20 08:12:27 +03:00
void cmPassed ( const char * Message , const char * m2 = " " )
2001-08-23 21:57:45 +04:00
{
std : : cout < < " Passed: " < < Message < < m2 < < " \n " ;
2002-01-20 08:12:27 +03:00
cm_passed + + ;
2001-08-23 21:57:45 +04:00
}
2002-01-20 05:24:55 +03:00
// ======================================================================
2002-01-18 20:03:32 +03:00
void TestAndRemoveFile ( const char * filename )
{
2002-01-19 03:21:43 +03:00
if ( ! cmSystemTools : : FileExists ( filename ) )
2002-01-18 20:03:32 +03:00
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Could not find file: " , filename ) ;
2002-01-18 20:03:32 +03:00
}
else
{
2002-01-19 03:21:43 +03:00
if ( ! cmSystemTools : : RemoveFile ( filename ) )
2002-01-18 20:03:32 +03:00
{
2002-01-20 08:12:27 +03:00
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 ) ;
2002-01-18 20:03:32 +03:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " Find and remove file: " , filename ) ;
2002-01-18 20:03:32 +03:00
}
}
}
2002-01-20 05:24:55 +03:00
// ======================================================================
2002-01-19 03:21:43 +03:00
void TestDir ( const char * filename )
{
if ( ! cmSystemTools : : FileExists ( filename ) )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Could not find dir: " , filename ) ;
2002-01-19 03:21:43 +03:00
}
else
{
if ( ! cmSystemTools : : FileIsDirectory ( filename ) )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Unable to check if file is a directory: " , filename ) ;
2002-01-19 03:21:43 +03:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " Find dir: " , filename ) ;
2002-01-19 03:21:43 +03:00
}
}
}
2002-01-20 05:24:55 +03:00
// ======================================================================
2002-01-19 03:21:43 +03:00
2001-08-24 23:54:06 +04:00
int main ( )
2001-08-23 21:57:45 +04:00
{
if ( sharedFunction ( ) ! = 1 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Call to sharedFunction from shared library failed. " ) ;
2001-08-23 21:57:45 +04:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " Call to sharedFunction from shared library worked. " ) ;
2001-08-23 21:57:45 +04:00
}
if ( file1 ( ) ! = 1 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Call to file1 function from library failed. " ) ;
2001-08-23 21:57:45 +04:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " Call to file1 function returned 1. " ) ;
2001-08-23 21:57:45 +04:00
}
2002-01-17 23:49:08 +03:00
2001-08-23 21:57:45 +04:00
if ( file2 ( ) ! = 1 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " Call to file2 function from library failed. " ) ;
2001-08-23 21:57:45 +04:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " Call to file2 function returned 1. " ) ;
2001-08-23 21:57:45 +04:00
}
2002-01-17 23:49:08 +03:00
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
2001-08-23 21:57:45 +04:00
# ifndef CMAKE_IS_FUN
2002-01-20 08:12:27 +03:00
cmFailed ( " CMake is not fun, so it is broken and should be fixed. " ) ;
2001-08-23 21:57:45 +04:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " CMAKE_IS_FUN is defined. " ) ;
2001-08-23 21:57:45 +04:00
# endif
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Test SET, VARIABLE_REQUIRES
2001-08-23 21:57:45 +04:00
# ifdef SHOULD_NOT_BE_DEFINED
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined. " ) ;
2001-08-23 21:57:45 +04:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_NOT_BE_DEFINED is not defined. " ) ;
2001-08-23 21:57:45 +04:00
# endif
# ifndef SHOULD_BE_DEFINED
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED is not defined. \n " ) ;
2001-08-23 21:57:45 +04:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_BE_DEFINED is defined. " ) ;
2001-08-23 21:57:45 +04:00
# endif
2002-01-20 05:24:55 +03:00
# ifndef ONE_VAR
2002-01-20 08:12:27 +03:00
cmFailed ( " cmakedefine is broken, ONE_VAR is not defined. " ) ;
2002-01-20 05:24:55 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " ONE_VAR is defined. " ) ;
2002-01-20 05:24:55 +03:00
# endif
# ifndef ONE_VAR_IS_DEFINED
2002-01-20 08:12:27 +03:00
cmFailed ( " cmakedefine, SET or VARIABLE_REQUIRES is broken, "
2002-01-20 05:24:55 +03:00
" ONE_VAR_IS_DEFINED is not defined. " ) ;
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " ONE_VAR_IS_DEFINED is defined. " ) ;
2002-01-20 05:24:55 +03:00
# endif
# ifdef ZERO_VAR
2002-01-20 08:12:27 +03:00
cmFailed ( " cmakedefine is broken, ZERO_VAR is defined. " ) ;
2002-01-20 05:24:55 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " ZERO_VAR is not defined. " ) ;
2002-01-20 05:24:55 +03:00
# endif
# ifndef STRING_VAR
2002-01-20 08:12:27 +03:00
cmFailed ( " the CONFIGURE_FILE command is broken, STRING_VAR is not defined. " ) ;
2002-01-20 05:24:55 +03:00
# else
if ( strcmp ( STRING_VAR , " CMake is great " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the SET or CONFIGURE_FILE command is broken. STRING_VAR == " ,
2002-01-20 05:24:55 +03:00
STRING_VAR ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " STRING_VAR == " , STRING_VAR ) ;
2002-01-20 05:24:55 +03:00
}
# endif
// ----------------------------------------------------------------------
// Test various IF/ELSE combinations
2002-01-20 09:58:57 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_NOT
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_NOT is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_NOT
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_NOT is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_NOT is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_NOT2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_NOT2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_NOT2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_NOT2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_NOT2 is defined. " ) ;
# endif
2002-01-19 04:32:06 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_AND
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined. " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_NOT_BE_DEFINED_AND is not defined. " ) ;
2002-01-19 04:32:06 +03:00
# endif
# ifndef SHOULD_BE_DEFINED_AND
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined. \n " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_BE_DEFINED_AND is defined. " ) ;
2002-01-19 04:32:06 +03:00
# endif
2002-01-20 09:58:57 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_AND2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_AND2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_AND2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_AND2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_AND2 is defined. " ) ;
# endif
2002-01-19 04:32:06 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_OR
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined. " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_NOT_BE_DEFINED_OR is not defined. " ) ;
2002-01-19 04:32:06 +03:00
# endif
# ifndef SHOULD_BE_DEFINED_OR
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined. \n " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_BE_DEFINED_OR is defined. " ) ;
2002-01-19 04:32:06 +03:00
# endif
2002-01-20 09:58:57 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_OR2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_OR2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_OR2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_OR2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_OR2 is defined. " ) ;
# endif
2002-01-19 04:32:06 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_MATCHES
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined. " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_NOT_BE_DEFINED_MATCHES is not defined. " ) ;
2002-01-19 04:32:06 +03:00
# endif
# ifndef SHOULD_BE_DEFINED_MATCHES
2002-01-20 08:12:27 +03:00
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined. \n " ) ;
2002-01-19 04:32:06 +03:00
# else
2002-01-20 08:12:27 +03:00
cmPassed ( " SHOULD_BE_DEFINED_MATCHES is defined. " ) ;
# endif
2002-01-20 09:58:57 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_MATCHES2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_MATCHES2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_MATCHES2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_MATCHES2 is defined. " ) ;
# endif
2002-01-20 08:12:27 +03:00
# 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. " ) ;
2002-01-19 04:32:06 +03:00
# endif
2002-01-20 09:58:57 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_COMMAND2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_COMMAND2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_COMMAND2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_COMMAND2 is defined. " ) ;
# endif
2002-01-21 18:22:51 +03:00
# ifdef SHOULD_NOT_BE_DEFINED_EXISTS
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_EXISTS is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_EXISTS
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_EXISTS is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_EXISTS is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_EXISTS2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_EXISTS2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_EXISTS2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_EXISTS2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_EXISTS2 is defined. " ) ;
# endif
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Test FOREACH
2002-01-17 23:49:08 +03:00
2002-01-18 20:03:32 +03:00
# ifndef FOREACH_VAR1
2002-01-20 08:12:27 +03:00
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
2002-01-18 20:03:32 +03:00
" FOREACH_VAR1 is not defined. " ) ;
# else
if ( strcmp ( FOREACH_VAR1 , " VALUE1 " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
2002-01-18 20:03:32 +03:00
" FOREACH_VAR1 == " , FOREACH_VAR1 ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FOREACH_VAR1 == " , FOREACH_VAR1 ) ;
2002-01-18 20:03:32 +03:00
}
# endif
2002-01-17 23:49:08 +03:00
2002-01-18 20:03:32 +03:00
# ifndef FOREACH_VAR2
2002-01-20 08:12:27 +03:00
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
2002-01-18 20:03:32 +03:00
" FOREACH_VAR2 is not defined. " ) ;
# else
if ( strcmp ( FOREACH_VAR2 , " VALUE2 " ) ! = 0 )
2002-01-17 23:49:08 +03:00
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
2002-01-18 20:03:32 +03:00
" FOREACH_VAR2 == " , FOREACH_VAR2 ) ;
2002-01-17 23:49:08 +03:00
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FOREACH_VAR2 == " , FOREACH_VAR2 ) ;
2002-01-18 20:03:32 +03:00
}
# endif
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
2002-01-18 20:03:32 +03:00
# ifndef FILENAME_VAR_PATH_NAME
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_PATH_NAME is not defined. " ) ;
# else
if ( strcmp ( FILENAME_VAR_PATH_NAME , " Complex " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_PATH_NAME == " , FILENAME_VAR_PATH_NAME ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FILENAME_VAR_PATH_NAME == " , FILENAME_VAR_PATH_NAME ) ;
2002-01-17 23:49:08 +03:00
}
2002-01-18 20:03:32 +03:00
# endif
# ifndef FILENAME_VAR_NAME
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_NAME is not defined. " ) ;
# else
2002-01-19 04:32:06 +03:00
if ( strcmp ( FILENAME_VAR_NAME , " VarTests.cmake " ) ! = 0 )
2002-01-18 20:03:32 +03:00
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_NAME == " , FILENAME_VAR_NAME ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FILENAME_VAR_NAME == " , FILENAME_VAR_NAME ) ;
2002-01-18 20:03:32 +03:00
}
# endif
# ifndef FILENAME_VAR_EXT
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_EXT is not defined. " ) ;
# else
2002-01-19 04:32:06 +03:00
if ( strcmp ( FILENAME_VAR_EXT , " .cmake " ) ! = 0 )
2002-01-18 20:03:32 +03:00
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_EXT == " , FILENAME_VAR_EXT ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FILENAME_VAR_EXT == " , FILENAME_VAR_EXT ) ;
2002-01-18 20:03:32 +03:00
}
# endif
# ifndef FILENAME_VAR_NAME_WE
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_NAME_WE is not defined. " ) ;
# else
if ( strcmp ( FILENAME_VAR_NAME_WE , " VarTests " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" FILENAME_VAR_NAME_WE == " , FILENAME_VAR_NAME_WE ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " FILENAME_VAR_NAME_WE == " , FILENAME_VAR_NAME_WE ) ;
2002-01-18 20:03:32 +03:00
}
# endif
# ifndef PATH_VAR_NAME
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" PATH_VAR_NAME is not defined. " ) ;
# else
if ( strcmp ( PATH_VAR_NAME , " Complex " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
2002-01-18 20:03:32 +03:00
" PATH_VAR_NAME == " , PATH_VAR_NAME ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " PATH_VAR_NAME == " , PATH_VAR_NAME ) ;
2002-01-18 20:03:32 +03:00
}
# endif
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Test LOAD_CACHE
2002-01-19 03:21:43 +03:00
# ifndef CACHE_TEST_VAR1
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR1 is not defined. " ) ;
# else
if ( strcmp ( CACHE_TEST_VAR1 , " foo " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR1 == " , CACHE_TEST_VAR1 ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " CACHE_TEST_VAR1 == " , CACHE_TEST_VAR1 ) ;
2002-01-19 03:21:43 +03:00
}
# endif
# ifndef CACHE_TEST_VAR2
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR2 is not defined. " ) ;
# else
if ( strcmp ( CACHE_TEST_VAR2 , " bar " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR2 == " , CACHE_TEST_VAR2 ) ;
}
else
{
2002-01-20 08:12:27 +03:00
cmPassed ( " CACHE_TEST_VAR2 == " , CACHE_TEST_VAR2 ) ;
2002-01-19 03:21:43 +03:00
}
# endif
# ifndef CACHE_TEST_VAR3
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR3 is not defined. " ) ;
# else
if ( strcmp ( CACHE_TEST_VAR3 , " 1 " ) ! = 0 )
{
2002-01-20 08:12:27 +03:00
cmFailed ( " the LOAD_CACHE or CONFIGURE_FILE command is broken, "
2002-01-19 03:21:43 +03:00
" CACHE_TEST_VAR3 == " , CACHE_TEST_VAR3 ) ;
}
else
{
2002-01-20 08:12:27 +03:00
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
2002-03-07 20:13:45 +03:00
std : : string cachetest = CACHE_TEST_VAR_INTERNAL ;
std : : string copy = cachetest ;
cachetest . find ( " bar " ) ;
cachetest . rfind ( " bar " ) ;
copy = cachetest . substr ( 0 , cachetest . size ( ) ) ;
if ( cachetest ! = " bar " )
2002-01-20 08:12:27 +03:00
{
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 ) ;
2002-01-19 03:21:43 +03:00
}
# endif
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
2002-01-19 03:21:43 +03:00
// A post-build custom-command has been attached to the lib (see Library/).
2002-01-20 05:24:55 +03:00
// It runs ${CREATE_FILE_EXE} which will create a file.
2002-01-21 23:30:37 +03:00
//
// WARNING: if you run 'complex' manually, this *will* fail, because
// the file was removed the last time 'complex' was run, and it is
// only created during a build.
2002-01-18 20:03:32 +03:00
2002-01-19 03:21:43 +03:00
TestAndRemoveFile ( BINARY_DIR " /Library/postbuild.txt " ) ;
2002-01-18 20:03:32 +03:00
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
2002-01-19 03:21:43 +03:00
// A custom target has been created (see Library/).
2002-01-20 05:24:55 +03:00
// It runs ${CREATE_FILE_EXE} which will create a file.
2002-01-21 23:30:37 +03:00
//
// WARNING: if you run 'complex' manually, this *will* fail, because
// the file was removed the last time 'complex' was run, and it is
// only created during a build.
2002-01-19 03:21:43 +03:00
TestAndRemoveFile ( BINARY_DIR " /Library/custom_target1.txt " ) ;
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
2002-01-19 03:21:43 +03:00
// A directory has been created.
2002-01-18 20:03:32 +03:00
2002-01-19 03:21:43 +03:00
TestDir ( BINARY_DIR " /make_dir " ) ;
2002-01-17 23:49:08 +03:00
2002-01-20 08:12:27 +03:00
// ----------------------------------------------------------------------
// 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).
2002-01-21 23:30:37 +03:00
//
// WARNING: if you run 'complex' manually, this *will* fail, because
// the file was removed the last time 'complex' was run, and it is
// only created during a build.
2002-01-20 08:12:27 +03:00
2002-01-22 23:57:40 +03:00
TestAndRemoveFile ( BINARY_DIR " /Executable/Temp/complex-required.txt " ) ;
2002-01-20 08:12:27 +03:00
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
// Summary
2002-01-20 08:12:27 +03:00
std : : cout < < " Passed: " < < cm_passed < < " \n " ;
if ( cm_failed )
2001-08-23 21:57:45 +04:00
{
2002-01-20 08:12:27 +03:00
std : : cout < < " Failed: " < < cm_failed < < " \n " ;
return cm_failed ;
2001-08-23 21:57:45 +04:00
}
2002-01-17 23:49:08 +03:00
2001-08-23 21:57:45 +04:00
return 0 ;
}