2001-08-23 21:57:45 +04:00
# include "cmTestConfigure.h"
2002-05-23 21:04:00 +04:00
# include "cmTestConfigureEscape.h"
2002-12-14 01:35:00 +03:00
# include "cmTestGeneratedHeader.h"
2002-04-22 19:51:26 +04:00
# include "cmVersion.h"
2001-08-23 21:57:45 +04:00
# include "ExtraSources/file1.h"
# include "file2.h"
# include "sharedFile.h"
2002-04-08 21:36:18 +04:00
extern " C " {
# include "testConly.h"
}
2006-01-17 18:21:45 +03:00
# ifndef CMAKE_TEST_DIFFERENT_GENERATOR
2001-08-23 21:57:45 +04:00
# include "cmStandardIncludes.h"
2002-01-19 03:21:43 +03:00
# include "cmSystemTools.h"
2003-01-16 01:31:22 +03:00
# include "cmDynamicLoader.h"
2005-03-03 01:49:11 +03:00
# include "cmSystemTools.h"
# include "cmOrderLinkDirectories.h"
2005-07-14 17:30:50 +04:00
# include "cmGeneratedFileStream.h"
2006-01-17 18:21:45 +03:00
# else
# include <vector>
# include <string>
# include <iostream>
# include <string.h>
# endif
2001-08-23 21:57:45 +04:00
2002-01-20 08:12:27 +03:00
int cm_passed = 0 ;
int cm_failed = 0 ;
2006-01-17 18:21:45 +03:00
// ======================================================================
void cmFailed ( const char * Message , const char * m2 = " " , const char * m3 = " " )
{
std : : cout < < " FAILED: " < < Message < < m2 < < m3 < < " \n " ;
cm_failed + + ;
}
// ======================================================================
void cmPassed ( const char * Message , const char * m2 = " " )
{
std : : cout < < " Passed: " < < Message < < m2 < < " \n " ;
cm_passed + + ;
}
2001-08-23 21:57:45 +04:00
2004-04-15 21:59:29 +04:00
# ifndef CMAKE_IS_REALLY_FUN
This is a problem . Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
# endif
2006-01-17 18:21:45 +03:00
# ifndef CMAKE_TEST_DIFFERENT_GENERATOR
2002-03-08 19:01:10 +03:00
// Here is a stupid function that tries to use std::string methods
// so that the dec cxx compiler will instantiate the stuff that
// we are using from the CMakeLib library....
2005-03-03 01:49:11 +03:00
bool TestLibraryOrder ( bool shouldFail )
{
std : : string Adir = std : : string ( BINARY_DIR ) + std : : string ( " /A " ) ;
std : : string Bdir = std : : string ( BINARY_DIR ) + std : : string ( " /B " ) ;
std : : string Cdir = std : : string ( BINARY_DIR ) + std : : string ( " /C " ) ;
if ( ! shouldFail )
{
std : : string rm = Bdir ;
rm + = " /libA.a " ;
cmSystemTools : : RemoveFile ( rm . c_str ( ) ) ;
}
2006-01-14 02:18:32 +03:00
std : : vector < std : : string > linkLibraries ;
std : : vector < std : : string > linkDirectories ;
linkDirectories . push_back ( Adir ) ;
linkDirectories . push_back ( Bdir ) ;
linkDirectories . push_back ( Cdir ) ;
linkDirectories . push_back ( " /lib/extra/stuff " ) ;
2005-03-03 01:49:11 +03:00
Adir + = " /libA.a " ;
Bdir + = " /libB.a " ;
Cdir + = " /libC.a " ;
2006-01-14 02:18:32 +03:00
linkLibraries . push_back ( Adir ) ;
linkLibraries . push_back ( Bdir ) ;
linkLibraries . push_back ( Cdir ) ;
linkLibraries . push_back ( " -lm " ) ;
2005-03-03 01:49:11 +03:00
std : : vector < cmStdString > sortedpaths ;
std : : vector < cmStdString > linkItems ;
cmOrderLinkDirectories orderLibs ;
2005-03-04 02:46:52 +03:00
orderLibs . DebugOn ( ) ;
2005-03-03 01:49:11 +03:00
orderLibs . AddLinkExtension ( " .so " ) ;
orderLibs . AddLinkExtension ( " .a " ) ;
2005-08-10 20:55:41 +04:00
orderLibs . SetLinkPrefix ( " lib " ) ;
2006-01-14 02:18:32 +03:00
orderLibs . SetLinkInformation ( " test " , linkLibraries , linkDirectories ) ;
2005-03-03 01:49:11 +03:00
bool ret = orderLibs . DetermineLibraryPathOrder ( ) ;
orderLibs . GetLinkerInformation ( sortedpaths , linkItems ) ;
2005-03-04 02:16:00 +03:00
std : : cout < < " Sorted Link Paths: \n " ;
2005-03-03 01:49:11 +03:00
for ( std : : vector < cmStdString > : : iterator i = sortedpaths . begin ( ) ;
i ! = sortedpaths . end ( ) ; + + i )
{
2005-03-04 02:16:00 +03:00
std : : cout < < * i < < " \n " ;
2005-03-03 01:49:11 +03:00
}
2005-03-04 02:16:00 +03:00
std : : cout < < " Link Items: \n " ;
2005-03-03 01:49:11 +03:00
for ( std : : vector < cmStdString > : : iterator i = linkItems . begin ( ) ;
i ! = linkItems . end ( ) ; + + i )
{
2005-03-04 02:16:00 +03:00
std : : cout < < * i < < " \n " ;
2005-03-03 01:49:11 +03:00
}
if ( ! ( linkItems [ 0 ] = = " A " & &
linkItems [ 1 ] = = " B " & &
linkItems [ 2 ] = = " C " & &
linkItems [ 3 ] = = " -lm " ) )
{
2005-03-04 02:16:00 +03:00
std : : cout < < " fail because link items should be A B C -lm and the are not \n " ;
2005-03-03 01:49:11 +03:00
return shouldFail ;
}
// if this is not the fail test then the order should be f B C A
if ( ! shouldFail )
{
2005-03-04 02:16:00 +03:00
char order [ 5 ] ;
order [ 4 ] = 0 ;
for ( int i = 0 ; i < 4 ; + + i )
2005-03-03 01:49:11 +03:00
{
2005-03-04 02:16:00 +03:00
order [ i ] = sortedpaths [ i ] [ sortedpaths [ i ] . size ( ) - 1 ] ;
}
if ( ! ( strcmp ( order , " fBCA " ) = = 0 | | strcmp ( order , " BCAf " ) = = 0 ) )
{
std : : cout < < " fail because order should be /lib/extra/stuff B C A and it is not \n " ;
2005-03-03 01:49:11 +03:00
return false ;
}
}
return ret ;
}
2002-03-08 19:01:10 +03: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
2005-07-14 17:30:50 +04:00
void TestCMGeneratedFileSTream ( )
{
cmGeneratedFileStream gm ;
std : : string file1 = std : : string ( BINARY_DIR ) + std : : string ( " /generatedFile1 " ) ;
std : : string file2 = std : : string ( BINARY_DIR ) + std : : string ( " /generatedFile2 " ) ;
std : : string file3 = std : : string ( BINARY_DIR ) + std : : string ( " /generatedFile3 " ) ;
2005-07-14 17:44:49 +04:00
std : : string file4 = std : : string ( BINARY_DIR ) + std : : string ( " /generatedFile4 " ) ;
2005-07-14 17:30:50 +04:00
std : : string file1tmp = file1 + " .tmp " ;
std : : string file2tmp = file2 + " .tmp " ;
std : : string file3tmp = file3 + " .tmp " ;
2005-07-14 17:44:49 +04:00
std : : string file4tmp = file4 + " .tmp " ;
2005-07-14 17:30:50 +04:00
gm . Open ( file1 . c_str ( ) ) ;
gm < < " This is generated file 1 " ;
gm . Close ( ) ;
gm . Open ( file2 . c_str ( ) ) ;
gm < < " This is generated file 2 " ;
gm . Close ( ) ;
gm . Open ( file3 . c_str ( ) ) ;
gm < < " This is generated file 3 " ;
gm . Close ( ) ;
2005-07-14 17:44:49 +04:00
gm . Open ( file4 . c_str ( ) ) ;
gm < < " This is generated file 4 " ;
gm . Close ( ) ;
2005-07-14 17:30:50 +04:00
if ( cmSystemTools : : FileExists ( file1 . c_str ( ) ) )
{
if ( cmSystemTools : : FileExists ( file2 . c_str ( ) ) )
{
if ( cmSystemTools : : FileExists ( file3 . c_str ( ) ) )
{
2005-07-14 17:44:49 +04:00
if ( cmSystemTools : : FileExists ( file4 . c_str ( ) ) )
2005-07-14 17:30:50 +04:00
{
2005-07-14 17:44:49 +04:00
if ( cmSystemTools : : FileExists ( file1tmp . c_str ( ) ) )
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Temporary file is still here: " , file1tmp . c_str ( ) ) ;
}
else if ( cmSystemTools : : FileExists ( file2tmp . c_str ( ) ) )
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Temporary file is still here: " , file2tmp . c_str ( ) ) ;
}
else if ( cmSystemTools : : FileExists ( file3tmp . c_str ( ) ) )
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Temporary file is still here: " , file3tmp . c_str ( ) ) ;
}
else if ( cmSystemTools : : FileExists ( file4tmp . c_str ( ) ) )
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Temporary file is still here: " , file4tmp . c_str ( ) ) ;
}
else
{
cmPassed ( " cmGeneratedFileStream works. " ) ;
}
2005-07-14 17:30:50 +04:00
}
else
{
2005-07-14 17:44:49 +04:00
cmFailed ( " Something wrong with cmGeneratedFileStream. Cannot find file: " , file4 . c_str ( ) ) ;
2005-07-14 17:30:50 +04:00
}
}
else
{
2005-07-14 17:44:49 +04:00
cmFailed ( " Something wrong with cmGeneratedFileStream. Found file: " , file3 . c_str ( ) ) ;
2005-07-14 17:30:50 +04:00
}
}
else
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Cannot find file: " , file2 . c_str ( ) ) ;
}
}
else
{
cmFailed ( " Something wrong with cmGeneratedFileStream. Cannot find file: " , file1 . c_str ( ) ) ;
}
cmSystemTools : : RemoveFile ( file1 . c_str ( ) ) ;
cmSystemTools : : RemoveFile ( file2 . c_str ( ) ) ;
cmSystemTools : : RemoveFile ( file3 . c_str ( ) ) ;
cmSystemTools : : RemoveFile ( file1tmp . c_str ( ) ) ;
cmSystemTools : : RemoveFile ( file2tmp . c_str ( ) ) ;
cmSystemTools : : RemoveFile ( file3tmp . c_str ( ) ) ;
}
2006-01-17 18:21:45 +03:00
# endif
void ForceStringUse ( )
{
std : : vector < std : : string > v ;
std : : vector < std : : string > v2 ;
v = v2 ;
std : : string cachetest = CACHE_TEST_VAR_INTERNAL ;
v . push_back ( cachetest ) ;
v2 = v ;
std : : string x ( 5 , ' x ' ) ;
char buff [ 5 ] ;
x . copy ( buff , 1 , 0 ) ;
x [ 0 ] = ' a ' ;
std : : string : : size_type pos = 0 ;
x . replace ( pos , pos , pos , ' x ' ) ;
std : : string copy = cachetest ;
cachetest . find ( " bar " ) ;
cachetest . rfind ( " bar " ) ;
copy . append ( cachetest ) ;
copy = cachetest . substr ( 0 , cachetest . size ( ) ) ;
}
2005-07-29 19:56:31 +04:00
// defined in testcflags.c
extern " C " int TestCFlags ( char * m ) ;
2006-01-25 16:38:06 +03:00
extern " C " int TestTargetCompileFlags ( char * m ) ;
2005-07-14 17:30:50 +04:00
// ======================================================================
2001-08-24 23:54:06 +04:00
int main ( )
2001-08-23 21:57:45 +04:00
{
2003-01-16 01:31:22 +03:00
std : : string lib = BINARY_DIR ;
lib + = " /bin/ " ;
2003-01-16 16:28:45 +03:00
# ifdef CMAKE_INTDIR
lib + = CMAKE_INTDIR ;
lib + = " / " ;
# endif
2004-10-25 20:15:37 +04:00
std : : string exe = lib ;
2003-01-16 16:28:45 +03:00
2006-01-17 18:21:45 +03:00
# ifndef CMAKE_TEST_DIFFERENT_GENERATOR
2004-10-25 20:15:37 +04:00
// Test a single character executable to test a: in makefiles
exe + = " A " ;
exe + = cmSystemTools : : GetExecutableExtension ( ) ;
int ret ;
2004-10-25 21:16:05 +04:00
std : : string errorMessage ;
exe = cmSystemTools : : ConvertToRunCommandPath ( exe . c_str ( ) ) ;
2004-10-25 20:15:37 +04:00
if ( cmSystemTools : : RunSingleCommand ( exe . c_str ( ) , 0 , & ret ) )
{
if ( ret ! = 10 )
{
errorMessage + = exe ;
errorMessage + = " did not return 10 " ;
}
}
else
{
errorMessage + = exe ;
errorMessage + = " : failed to run. " ;
}
if ( errorMessage . size ( ) )
{
cmFailed ( errorMessage . c_str ( ) ) ;
}
else
{
cmPassed ( " run Single Character executable A returned 10 as expected. " ) ;
}
2003-01-16 01:31:22 +03:00
lib + = cmDynamicLoader : : LibPrefix ( ) ;
lib + = " CMakeTestModule " ;
lib + = cmDynamicLoader : : LibExtension ( ) ;
cmLibHandle handle = cmDynamicLoader : : OpenLibrary ( lib . c_str ( ) ) ;
if ( ! handle )
{
2004-08-26 22:55:55 +04:00
std : : string err = " Can not open CMakeTestModule: \n " ;
2003-08-28 00:42:01 +04:00
err + = lib ;
2004-08-26 22:55:55 +04:00
cmFailed ( err . c_str ( ) ) ;
2003-01-16 01:31:22 +03:00
}
else
{
cmDynamicLoaderFunction fun =
2003-01-16 23:47:04 +03:00
cmDynamicLoader : : GetSymbolAddress ( handle , " ModuleFunction " ) ;
if ( ! fun )
{
fun = cmDynamicLoader : : GetSymbolAddress ( handle , " _ModuleFunction " ) ;
}
2003-01-16 01:31:22 +03:00
typedef int ( * TEST_FUNCTION ) ( ) ;
TEST_FUNCTION testFun = ( TEST_FUNCTION ) fun ;
2003-01-16 23:47:04 +03:00
if ( ! testFun )
{
cmFailed ( " Could not find symbol ModuleFunction in library " ) ;
}
else
2003-01-16 01:31:22 +03:00
{
2003-01-16 23:47:04 +03:00
int ret = ( * testFun ) ( ) ;
if ( ! ret )
{
cmFailed ( " ModuleFunction call did not return valid return. " ) ;
}
cmPassed ( " Module loaded and ModuleFunction called correctly. " ) ;
2003-01-16 01:31:22 +03:00
}
}
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
}
2002-04-08 21:36:18 +04:00
if ( CsharedFunction ( ) ! = 1 )
{
cmFailed ( " Call to C sharedFunction from shared library failed. " ) ;
}
else
{
cmPassed ( " Call to C sharedFunction from shared library worked. " ) ;
}
2001-08-23 21:57:45 +04:00
2006-01-17 18:21:45 +03:00
// ----------------------------------------------------------------------
// Test cmSystemTools::UpperCase
std : : string str = " abc " ;
std : : string strupper = " ABC " ;
if ( cmSystemTools : : UpperCase ( str ) = = strupper )
{
cmPassed ( " cmSystemTools::UpperCase is working " ) ;
}
else
{
cmFailed ( " cmSystemTools::UpperCase is working " ) ;
}
# endif
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
}
2006-01-25 16:38:06 +03:00
# ifndef COMPLEX_TARGET_FLAG
cmFailed ( " COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES " ) ;
# else
cmPassed ( " COMPILE_FLAGS did work with SET_TARGET_PROPERTIES " ) ;
# endif
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-04-09 20:02:48 +04:00
# ifndef TEST_CXX_FLAGS
cmFailed ( " CMake CMAKE_CXX_FLAGS is not being passed to the compiler! " ) ;
# else
cmPassed ( " CMake CMAKE_CXX_FLAGS is being passed to the compiler. " ) ;
2002-04-09 20:24:44 +04:00
# endif
2005-07-29 22:02:51 +04:00
std : : string gen = CMAKE_GENERATOR ;
// visual studio is currently broken for c flags
2006-01-25 16:38:06 +03:00
char msg [ 1024 ] ;
2005-07-29 22:02:51 +04:00
if ( gen . find ( " Visual " ) = = gen . npos )
{
2005-07-29 19:56:31 +04:00
# ifdef TEST_C_FLAGS
2005-07-29 22:02:51 +04:00
cmFailed ( " CMake CMAKE_C_FLAGS are being passed to c++ files the compiler! " ) ;
2005-07-29 19:56:31 +04:00
# else
2005-07-29 22:02:51 +04:00
cmPassed ( " CMake CMAKE_C_FLAGS are not being passed to c++ files. " ) ;
2005-07-29 19:56:31 +04:00
# endif
2005-07-29 22:02:51 +04:00
if ( TestCFlags ( msg ) )
{
cmPassed (
" CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not. " ) ;
}
else
{
cmFailed ( msg ) ;
}
2005-07-29 19:56:31 +04:00
}
2006-01-25 16:38:06 +03:00
if ( TestTargetCompileFlags ( msg ) )
{
cmPassed ( msg ) ;
}
else
{
cmFailed ( msg ) ;
}
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
2004-04-26 19:12:19 +04:00
# if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4)
cmPassed ( " Variable args for MACROs are working. " ) ;
# else
cmFailed ( " Variable args for MACROs are failing. " ) ;
# 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-05-27 18:29:04 +04:00
# ifdef SHOULD_NOT_BE_DEFINED_LESS
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_LESS is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_LESS
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_LESS is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_LESS2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_LESS2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_LESS2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_LESS2 is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_GREATER
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_GREATER is not defined. " ) ;
# endif
2004-04-28 18:09:50 +04:00
# ifdef SHOULD_NOT_BE_DEFINED_EQUAL
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_EQUAL is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_EQUAL
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_EQUAL is defined. " ) ;
# endif
2002-05-27 18:29:04 +04:00
# ifndef SHOULD_BE_DEFINED_GREATER
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_GREATER is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_GREATER2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_GREATER2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_GREATER2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_GREATER2 is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_STRLESS
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_STRLESS is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_STRLESS
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_STRLESS is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_STRLESS2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_STRLESS2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_STRLESS2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_STRLESS2 is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_STRGREATER
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_STRGREATER is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_STRGREATER
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_STRGREATER is defined. " ) ;
# endif
# ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2
cmFailed ( " IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined. " ) ;
# else
cmPassed ( " SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined. " ) ;
# endif
# ifndef SHOULD_BE_DEFINED_STRGREATER2
cmFailed ( " IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined. \n " ) ;
# else
cmPassed ( " SHOULD_BE_DEFINED_STRGREATER2 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-03-27 21:54:31 +03:00
# ifndef FOREACH_CONCAT
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
" FOREACH_CONCAT is not defined. " ) ;
# else
if ( strcmp ( FOREACH_CONCAT , " abcdefg " ) ! = 0 )
{
cmFailed ( " the FOREACH, SET or CONFIGURE_FILE command is broken, "
" FOREACH_CONCAT == " , FOREACH_CONCAT ) ;
}
else
{
cmPassed ( " FOREACH_CONCAT == " , FOREACH_CONCAT ) ;
}
# endif
2005-06-30 21:39:38 +04:00
// ----------------------------------------------------------------------
// Test WHILE
if ( WHILE_VALUE ! = 1000 )
{
cmFailed ( " WHILE command is not working " ) ;
}
else
{
cmPassed ( " WHILE command is working " ) ;
}
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
2004-05-04 22:24:25 +04:00
if ( ( strcmp ( FILENAME_VAR_PATH_NAME , " Complex " ) = = 0 ) | |
( strcmp ( FILENAME_VAR_PATH_NAME , " ComplexOneConfig " ) = = 0 ) | |
( strcmp ( FILENAME_VAR_PATH_NAME , " ComplexRelativePaths " ) = = 0 ) )
2002-01-18 20:03:32 +03:00
{
2004-05-04 22:24:25 +04:00
cmPassed ( " FILENAME_VAR_PATH_NAME == " , FILENAME_VAR_PATH_NAME ) ;
2002-01-18 20:03:32 +03:00
}
else
{
2004-05-04 22:24:25 +04:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
" 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
2004-05-04 22:24:25 +04:00
if ( ( strcmp ( PATH_VAR_NAME , " Complex " ) = = 0 ) | |
( strcmp ( PATH_VAR_NAME , " ComplexOneConfig " ) = = 0 ) | |
( strcmp ( PATH_VAR_NAME , " ComplexRelativePaths " ) = = 0 ) )
2002-01-18 20:03:32 +03:00
{
2004-05-04 22:24:25 +04:00
cmPassed ( " PATH_VAR_NAME == " , PATH_VAR_NAME ) ;
2002-01-18 20:03:32 +03:00
}
else
{
2004-05-04 22:24:25 +04:00
cmFailed ( " the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
" 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 ;
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
2006-01-17 18:21:45 +03:00
# ifndef CMAKE_TEST_DIFFERENT_GENERATOR
2002-01-20 05:24:55 +03:00
// ----------------------------------------------------------------------
2005-02-25 17:31:55 +03:00
// Some pre-build/pre-link/post-build custom-commands have been
// attached to the lib (see Library/).
// Each runs ${CREATE_FILE_EXE} which will create a file.
// It also copies that file again using cmake -E.
// Similar rules have been added to this executable.
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
2005-02-25 17:31:55 +03:00
TestAndRemoveFile ( BINARY_DIR " /Library/prebuild.txt " ) ;
TestAndRemoveFile ( BINARY_DIR " /Library/prelink.txt " ) ;
2002-01-19 03:21:43 +03:00
TestAndRemoveFile ( BINARY_DIR " /Library/postbuild.txt " ) ;
2002-04-11 01:33:10 +04:00
TestAndRemoveFile ( BINARY_DIR " /Library/postbuild2.txt " ) ;
2005-02-25 17:31:55 +03:00
TestAndRemoveFile ( BINARY_DIR " /Executable/prebuild.txt " ) ;
TestAndRemoveFile ( BINARY_DIR " /Executable/prelink.txt " ) ;
TestAndRemoveFile ( BINARY_DIR " /Executable/postbuild.txt " ) ;
TestAndRemoveFile ( BINARY_DIR " /Executable/postbuild2.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 " ) ;
2006-01-17 18:21:45 +03:00
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 " ) ;
2006-01-17 18:21:45 +03:00
# endif
2002-01-20 08:12:27 +03:00
2002-03-29 23:02:18 +03:00
// ----------------------------------------------------------------------
// Test FIND_LIBRARY
# ifndef FIND_DUMMY_LIB
cmFailed ( " the CONFIGURE_FILE command is broken, "
" FIND_DUMMY_LIB is not defined. " ) ;
# else
if ( strstr ( FIND_DUMMY_LIB , " dummylib " ) = = NULL )
{
cmFailed ( " the FIND_LIBRARY or CONFIGURE_FILE command is broken, "
" FIND_DUMMY_LIB == " , FIND_DUMMY_LIB ) ;
}
else
{
cmPassed ( " FIND_DUMMY_LIB == " , FIND_DUMMY_LIB ) ;
}
# endif
// ----------------------------------------------------------------------
// Test SET_SOURCE_FILES_PROPERTIES
# ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
cmFailed ( " SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag " ) ;
# else
cmPassed ( " SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag " ) ;
# endif
# ifndef FILE_HAS_ABSTRACT
cmFailed ( " SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag " ) ;
# else
cmPassed ( " SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag " ) ;
# endif
# ifndef FILE_HAS_WRAP_EXCLUDE
cmFailed ( " FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag " ) ;
# else
cmPassed ( " FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag " ) ;
# endif
# ifndef FILE_COMPILE_FLAGS
cmFailed ( " the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined. " ) ;
# else
if ( strcmp ( FILE_COMPILE_FLAGS , " -foo -bar " ) ! = 0 )
{
cmFailed ( " the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == " ,
FILE_COMPILE_FLAGS ) ;
}
else
{
cmPassed ( " SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == " , FILE_COMPILE_FLAGS ) ;
}
# endif
2002-04-01 23:58:21 +04:00
// ----------------------------------------------------------------------
// Test registry (win32)
# if defined(_WIN32) && !defined(__CYGWIN__)
# ifndef REGISTRY_TEST_PATH
cmFailed ( " the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined. " ) ;
# else
2003-01-17 18:28:41 +03:00
std : : cout < < " REGISTRY_TEST_PATH == " < < REGISTRY_TEST_PATH < < " \n " ;
2002-04-12 01:02:10 +04:00
if ( stricmp ( REGISTRY_TEST_PATH , BINARY_DIR " /registry_dir " ) ! = 0 )
2002-04-01 23:58:21 +04:00
{
cmFailed ( " the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == " ,
2003-01-17 18:28:41 +03:00
REGISTRY_TEST_PATH , " is not " BINARY_DIR " /registry_dir " ) ;
2002-04-01 23:58:21 +04:00
}
else
{
cmPassed ( " REGISTRY_TEST_PATH == " , REGISTRY_TEST_PATH ) ;
}
# endif
# endif // defined(_WIN32) && !defined(__CYGWIN__)
2002-04-18 00:16:06 +04:00
if ( strcmp ( CMAKE_MINIMUM_REQUIRED_VERSION , " 1.3 " ) = = 0 )
{
cmPassed ( " CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3 " ) ;
}
else
{
cmFailed ( " CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3 " ) ;
}
2002-04-22 19:51:26 +04:00
// ----------------------------------------------------------------------
// Test REMOVE command
2003-03-21 19:33:30 +03:00
if ( strcmp ( " a;b;d " , REMOVE_STRING ) = = 0 )
2002-04-22 19:51:26 +04:00
{
cmPassed ( " REMOVE is working " ) ;
}
else
{
cmFailed ( " REMOVE is not working " ) ;
}
2002-04-30 22:01:07 +04:00
// ----------------------------------------------------------------------
// Test SEPARATE_ARGUMENTS
if ( strcmp ( " a;b;c " , TEST_SEP ) = = 0 )
{
cmPassed ( " SEPARATE_ARGUMENTS is working " ) ;
}
else
{
cmFailed ( " SEPARATE_ARGUMENTS is not working " ) ;
}
2002-05-23 21:04:00 +04:00
// ----------------------------------------------------------------------
// Test Escape Quotes
if ( strcmp ( " \" hello world \" " , STRING_WITH_QUOTES ) = = 0 )
{
cmPassed ( " ESCAPE_QUOTES is working " ) ;
}
else
{
cmFailed ( " ESCAPE_QUOTES is not working " ) ;
}
2002-05-23 21:23:35 +04:00
2002-07-17 01:42:56 +04:00
// ----------------------------------------------------------------------
// Test if IF command inside a FOREACH works.
# if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
cmPassed ( " IF inside a FOREACH block works " ) ;
# else
cmFailed ( " IF inside a FOREACH block is broken " ) ;
# endif
2002-12-14 01:35:00 +03:00
# if defined(GENERATED_HEADER_INCLUDED)
cmPassed ( " Generated header included by non-generated source works. " ) ;
# else
cmFailed ( " Generated header included by non-generated source failed. " ) ;
# endif
2006-01-04 00:40:51 +03:00
if ( SHOULD_BE_ZERO = = 0 )
{
cmPassed ( " cmakedefine01 is working for 0 " ) ;
}
else
{
cmFailed ( " cmakedefine01 is not working for 0 " ) ;
}
if ( SHOULD_BE_ONE = = 1 )
{
cmPassed ( " cmakedefine01 is working for 1 " ) ;
}
else
{
cmFailed ( " cmakedefine01 is not working for 1 " ) ;
}
2002-10-09 23:54:34 +04:00
# ifdef FORCE_TEST
cmFailed ( " CMake SET CACHE FORCE " ) ;
# else
cmPassed ( " CMake SET CACHE FORCE " ) ;
# endif
2005-03-04 02:16:00 +03:00
2006-01-17 18:21:45 +03:00
# ifndef CMAKE_TEST_DIFFERENT_GENERATOR
2005-03-04 02:16:00 +03:00
// first run with shouldFail = true, this will
// run with A B C as set by the CMakeList.txt file.
if ( ! TestLibraryOrder ( true ) )
{
cmPassed ( " CMake cmOrderLinkDirectories failed when it should. " ) ;
}
else
{
2005-03-11 21:12:02 +03:00
cmFailed ( " CMake cmOrderLinkDirectories failed to fail when given an impossible set of paths. " ) ;
2005-03-04 02:16:00 +03:00
}
// next run with shouldPass = true, this will
// run with B/libA.a removed and should create the order
// B C A
if ( TestLibraryOrder ( false ) )
{
cmPassed ( " CMake cmOrderLinkDirectories worked. " ) ;
}
else
{
cmFailed ( " CMake cmOrderLinkDirectories failed. " ) ;
}
2005-07-14 17:30:50 +04:00
// Test the generated file stream.
TestCMGeneratedFileSTream ( ) ;
2006-01-17 18:21:45 +03:00
# endif
2005-03-04 02:16:00 +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
}
return 0 ;
}