complex.cxx 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. #include "cmTestConfigure.h"
  2. #include "cmTestConfigureEscape.h"
  3. #include "cmTestGeneratedHeader.h"
  4. #include "cmVersion.h"
  5. #include "ExtraSources/file1.h"
  6. #include "file2.h"
  7. #include "sharedFile.h"
  8. extern "C" {
  9. #include "testConly.h"
  10. }
  11. #include "cmStandardIncludes.h"
  12. #include "cmSystemTools.h"
  13. #include "cmDynamicLoader.h"
  14. #include "cmSystemTools.h"
  15. #include "cmOrderLinkDirectories.h"
  16. #include "cmGeneratedFileStream.h"
  17. int cm_passed = 0;
  18. int cm_failed = 0;
  19. #ifndef CMAKE_IS_REALLY_FUN
  20. This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
  21. #endif
  22. // Here is a stupid function that tries to use std::string methods
  23. // so that the dec cxx compiler will instantiate the stuff that
  24. // we are using from the CMakeLib library....
  25. bool TestLibraryOrder(bool shouldFail)
  26. {
  27. std::string Adir = std::string(BINARY_DIR) + std::string("/A");
  28. std::string Bdir = std::string(BINARY_DIR) + std::string("/B");
  29. std::string Cdir = std::string(BINARY_DIR) + std::string("/C");
  30. if(!shouldFail)
  31. {
  32. std::string rm = Bdir;
  33. rm += "/libA.a";
  34. cmSystemTools::RemoveFile(rm.c_str());
  35. }
  36. cmTarget target;
  37. target.AddLinkDirectory(Adir.c_str());
  38. target.AddLinkDirectory(Bdir.c_str());
  39. target.AddLinkDirectory(Cdir.c_str());
  40. target.AddLinkDirectory("/lib/extra/stuff");
  41. Adir += "/libA.a";
  42. Bdir += "/libB.a";
  43. Cdir += "/libC.a";
  44. target.AddLinkLibrary(Adir.c_str(), cmTarget::GENERAL);
  45. target.AddLinkLibrary(Bdir.c_str(), cmTarget::GENERAL);
  46. target.AddLinkLibrary(Cdir.c_str(), cmTarget::GENERAL);
  47. target.AddLinkLibrary("-lm", cmTarget::GENERAL);
  48. std::vector<cmStdString> sortedpaths;
  49. std::vector<cmStdString> linkItems;
  50. cmOrderLinkDirectories orderLibs;
  51. orderLibs.DebugOn();
  52. orderLibs.AddLinkExtension(".so");
  53. orderLibs.AddLinkExtension(".a");
  54. orderLibs.SetLinkPrefix("lib");
  55. orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
  56. bool ret = orderLibs.DetermineLibraryPathOrder();
  57. orderLibs.GetLinkerInformation(sortedpaths, linkItems);
  58. std::cout << "Sorted Link Paths:\n";
  59. for(std::vector<cmStdString>::iterator i = sortedpaths.begin();
  60. i != sortedpaths.end(); ++i)
  61. {
  62. std::cout << *i << "\n";
  63. }
  64. std::cout << "Link Items: \n";
  65. for(std::vector<cmStdString>::iterator i = linkItems.begin();
  66. i != linkItems.end(); ++i)
  67. {
  68. std::cout << *i << "\n";
  69. }
  70. if(!(linkItems[0] == "A" &&
  71. linkItems[1] == "B" &&
  72. linkItems[2] == "C" &&
  73. linkItems[3] == "-lm" ))
  74. {
  75. std::cout << "fail because link items should be A B C -lm and the are not\n";
  76. return shouldFail;
  77. }
  78. // if this is not the fail test then the order should be f B C A
  79. if(!shouldFail)
  80. {
  81. char order[5];
  82. order[4] = 0;
  83. for(int i =0; i < 4; ++i)
  84. {
  85. order[i] = sortedpaths[i][sortedpaths[i].size()-1];
  86. }
  87. if(!(strcmp(order, "fBCA") == 0 || strcmp(order, "BCAf") == 0))
  88. {
  89. std::cout << "fail because order should be /lib/extra/stuff B C A and it is not\n";
  90. return false;
  91. }
  92. }
  93. return ret;
  94. }
  95. void ForceStringUse()
  96. {
  97. std::vector<std::string> v;
  98. std::vector<std::string> v2;
  99. v = v2;
  100. std::string cachetest = CACHE_TEST_VAR_INTERNAL;
  101. v.push_back(cachetest);
  102. v2 = v;
  103. std::string x(5,'x');
  104. char buff[5];
  105. x.copy(buff, 1, 0);
  106. x[0] = 'a';
  107. std::string::size_type pos = 0;
  108. x.replace(pos, pos, pos, 'x');
  109. std::string copy = cachetest;
  110. cachetest.find("bar");
  111. cachetest.rfind("bar");
  112. copy.append(cachetest);
  113. copy = cachetest.substr(0, cachetest.size());
  114. }
  115. // ======================================================================
  116. void cmFailed(const char* Message, const char* m2= "", const char* m3 = "")
  117. {
  118. std::cout << "FAILED: " << Message << m2 << m3 << "\n";
  119. cm_failed++;
  120. }
  121. // ======================================================================
  122. void cmPassed(const char* Message, const char* m2="")
  123. {
  124. std::cout << "Passed: " << Message << m2 << "\n";
  125. cm_passed++;
  126. }
  127. // ======================================================================
  128. void TestAndRemoveFile(const char* filename)
  129. {
  130. if (!cmSystemTools::FileExists(filename))
  131. {
  132. cmFailed("Could not find file: ", filename);
  133. }
  134. else
  135. {
  136. if (!cmSystemTools::RemoveFile(filename))
  137. {
  138. 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);
  139. }
  140. else
  141. {
  142. cmPassed("Find and remove file: ", filename);
  143. }
  144. }
  145. }
  146. // ======================================================================
  147. void TestDir(const char* filename)
  148. {
  149. if (!cmSystemTools::FileExists(filename))
  150. {
  151. cmFailed("Could not find dir: ", filename);
  152. }
  153. else
  154. {
  155. if (!cmSystemTools::FileIsDirectory(filename))
  156. {
  157. cmFailed("Unable to check if file is a directory: ", filename);
  158. }
  159. else
  160. {
  161. cmPassed("Find dir: ", filename);
  162. }
  163. }
  164. }
  165. // ======================================================================
  166. void TestCMGeneratedFileSTream()
  167. {
  168. cmGeneratedFileStream gm;
  169. std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1");
  170. std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2");
  171. std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3");
  172. std::string file4 = std::string(BINARY_DIR) + std::string("/generatedFile4");
  173. std::string file1tmp = file1 + ".tmp";
  174. std::string file2tmp = file2 + ".tmp";
  175. std::string file3tmp = file3 + ".tmp";
  176. std::string file4tmp = file4 + ".tmp";
  177. gm.Open(file1.c_str());
  178. gm << "This is generated file 1";
  179. gm.Close();
  180. gm.Open(file2.c_str());
  181. gm << "This is generated file 2";
  182. gm.Close();
  183. gm.Open(file3.c_str());
  184. gm << "This is generated file 3";
  185. gm.Close();
  186. gm.Open(file4.c_str());
  187. gm << "This is generated file 4";
  188. gm.Close();
  189. if ( cmSystemTools::FileExists(file1.c_str()) )
  190. {
  191. if ( cmSystemTools::FileExists(file2.c_str()) )
  192. {
  193. if ( cmSystemTools::FileExists(file3.c_str()) )
  194. {
  195. if ( cmSystemTools::FileExists(file4.c_str()) )
  196. {
  197. if ( cmSystemTools::FileExists(file1tmp.c_str()) )
  198. {
  199. cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str());
  200. }
  201. else if ( cmSystemTools::FileExists(file2tmp.c_str()) )
  202. {
  203. cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str());
  204. }
  205. else if ( cmSystemTools::FileExists(file3tmp.c_str()) )
  206. {
  207. cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str());
  208. }
  209. else if ( cmSystemTools::FileExists(file4tmp.c_str()) )
  210. {
  211. cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file4tmp.c_str());
  212. }
  213. else
  214. {
  215. cmPassed("cmGeneratedFileStream works.");
  216. }
  217. }
  218. else
  219. {
  220. cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file4.c_str());
  221. }
  222. }
  223. else
  224. {
  225. cmFailed("Something wrong with cmGeneratedFileStream. Found file: ", file3.c_str());
  226. }
  227. }
  228. else
  229. {
  230. cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str());
  231. }
  232. }
  233. else
  234. {
  235. cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str());
  236. }
  237. cmSystemTools::RemoveFile(file1.c_str());
  238. cmSystemTools::RemoveFile(file2.c_str());
  239. cmSystemTools::RemoveFile(file3.c_str());
  240. cmSystemTools::RemoveFile(file1tmp.c_str());
  241. cmSystemTools::RemoveFile(file2tmp.c_str());
  242. cmSystemTools::RemoveFile(file3tmp.c_str());
  243. }
  244. // defined in testcflags.c
  245. extern "C" int TestCFlags(char* m);
  246. // ======================================================================
  247. int main()
  248. {
  249. std::string lib = BINARY_DIR;
  250. lib += "/bin/";
  251. #ifdef CMAKE_INTDIR
  252. lib += CMAKE_INTDIR;
  253. lib += "/";
  254. #endif
  255. std::string exe = lib;
  256. // Test a single character executable to test a: in makefiles
  257. exe += "A";
  258. exe += cmSystemTools::GetExecutableExtension();
  259. int ret;
  260. std::string errorMessage;
  261. exe = cmSystemTools::ConvertToRunCommandPath(exe.c_str());
  262. if(cmSystemTools::RunSingleCommand(exe.c_str(), 0, &ret))
  263. {
  264. if(ret != 10)
  265. {
  266. errorMessage += exe;
  267. errorMessage += " did not return 10";
  268. }
  269. }
  270. else
  271. {
  272. errorMessage += exe;
  273. errorMessage += ": failed to run.";
  274. }
  275. if(errorMessage.size())
  276. {
  277. cmFailed(errorMessage.c_str());
  278. }
  279. else
  280. {
  281. cmPassed("run Single Character executable A returned 10 as expected.");
  282. }
  283. lib += cmDynamicLoader::LibPrefix();
  284. lib += "CMakeTestModule";
  285. lib += cmDynamicLoader::LibExtension();
  286. cmLibHandle handle = cmDynamicLoader::OpenLibrary(lib.c_str());
  287. if(!handle)
  288. {
  289. std::string err = "Can not open CMakeTestModule:\n";
  290. err += lib;
  291. cmFailed(err.c_str());
  292. }
  293. else
  294. {
  295. cmDynamicLoaderFunction fun =
  296. cmDynamicLoader::GetSymbolAddress(handle, "ModuleFunction");
  297. if(!fun)
  298. {
  299. fun = cmDynamicLoader::GetSymbolAddress(handle, "_ModuleFunction");
  300. }
  301. typedef int (*TEST_FUNCTION)();
  302. TEST_FUNCTION testFun = (TEST_FUNCTION)fun;
  303. if(!testFun)
  304. {
  305. cmFailed("Could not find symbol ModuleFunction in library ");
  306. }
  307. else
  308. {
  309. int ret = (*testFun)();
  310. if(!ret)
  311. {
  312. cmFailed("ModuleFunction call did not return valid return.");
  313. }
  314. cmPassed("Module loaded and ModuleFunction called correctly.");
  315. }
  316. }
  317. if(sharedFunction() != 1)
  318. {
  319. cmFailed("Call to sharedFunction from shared library failed.");
  320. }
  321. else
  322. {
  323. cmPassed("Call to sharedFunction from shared library worked.");
  324. }
  325. if(CsharedFunction() != 1)
  326. {
  327. cmFailed("Call to C sharedFunction from shared library failed.");
  328. }
  329. else
  330. {
  331. cmPassed("Call to C sharedFunction from shared library worked.");
  332. }
  333. if(file1() != 1)
  334. {
  335. cmFailed("Call to file1 function from library failed.");
  336. }
  337. else
  338. {
  339. cmPassed("Call to file1 function returned 1.");
  340. }
  341. if(file2() != 1)
  342. {
  343. cmFailed("Call to file2 function from library failed.");
  344. }
  345. else
  346. {
  347. cmPassed("Call to file2 function returned 1.");
  348. }
  349. #ifndef TEST_CXX_FLAGS
  350. cmFailed("CMake CMAKE_CXX_FLAGS is not being passed to the compiler!");
  351. #else
  352. cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler.");
  353. #endif
  354. std::string gen = CMAKE_GENERATOR;
  355. // visual studio is currently broken for c flags
  356. if(gen.find("Visual") == gen.npos)
  357. {
  358. #ifdef TEST_C_FLAGS
  359. cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
  360. #else
  361. cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
  362. #endif
  363. char msg[1024];
  364. if(TestCFlags(msg))
  365. {
  366. cmPassed(
  367. "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
  368. }
  369. else
  370. {
  371. cmFailed(msg);
  372. }
  373. }
  374. // ----------------------------------------------------------------------
  375. // Test ADD_DEFINITIONS
  376. #ifndef CMAKE_IS_FUN
  377. cmFailed("CMake is not fun, so it is broken and should be fixed.");
  378. #else
  379. cmPassed("CMAKE_IS_FUN is defined.");
  380. #endif
  381. #if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4)
  382. cmPassed("Variable args for MACROs are working.");
  383. #else
  384. cmFailed("Variable args for MACROs are failing.");
  385. #endif
  386. // ----------------------------------------------------------------------
  387. // Test SET, VARIABLE_REQUIRES
  388. #ifdef SHOULD_NOT_BE_DEFINED
  389. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
  390. #else
  391. cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
  392. #endif
  393. #ifndef SHOULD_BE_DEFINED
  394. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
  395. #else
  396. cmPassed("SHOULD_BE_DEFINED is defined.");
  397. #endif
  398. #ifndef ONE_VAR
  399. cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
  400. #else
  401. cmPassed("ONE_VAR is defined.");
  402. #endif
  403. #ifndef ONE_VAR_IS_DEFINED
  404. cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
  405. "ONE_VAR_IS_DEFINED is not defined.");
  406. #else
  407. cmPassed("ONE_VAR_IS_DEFINED is defined.");
  408. #endif
  409. #ifdef ZERO_VAR
  410. cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
  411. #else
  412. cmPassed("ZERO_VAR is not defined.");
  413. #endif
  414. #ifndef STRING_VAR
  415. cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
  416. #else
  417. if(strcmp(STRING_VAR, "CMake is great") != 0)
  418. {
  419. cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
  420. STRING_VAR);
  421. }
  422. else
  423. {
  424. cmPassed("STRING_VAR == ", STRING_VAR);
  425. }
  426. #endif
  427. // ----------------------------------------------------------------------
  428. // Test various IF/ELSE combinations
  429. #ifdef SHOULD_NOT_BE_DEFINED_NOT
  430. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
  431. #else
  432. cmPassed("SHOULD_NOT_BE_DEFINED_NOT is not defined.");
  433. #endif
  434. #ifndef SHOULD_BE_DEFINED_NOT
  435. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT is not defined.\n");
  436. #else
  437. cmPassed("SHOULD_BE_DEFINED_NOT is defined.");
  438. #endif
  439. #ifdef SHOULD_NOT_BE_DEFINED_NOT2
  440. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT2 is defined.");
  441. #else
  442. cmPassed("SHOULD_NOT_BE_DEFINED_NOT2 is not defined.");
  443. #endif
  444. #ifndef SHOULD_BE_DEFINED_NOT2
  445. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT2 is not defined.\n");
  446. #else
  447. cmPassed("SHOULD_BE_DEFINED_NOT2 is defined.");
  448. #endif
  449. #ifdef SHOULD_NOT_BE_DEFINED_AND
  450. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
  451. #else
  452. cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
  453. #endif
  454. #ifndef SHOULD_BE_DEFINED_AND
  455. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
  456. #else
  457. cmPassed("SHOULD_BE_DEFINED_AND is defined.");
  458. #endif
  459. #ifdef SHOULD_NOT_BE_DEFINED_AND2
  460. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND2 is defined.");
  461. #else
  462. cmPassed("SHOULD_NOT_BE_DEFINED_AND2 is not defined.");
  463. #endif
  464. #ifndef SHOULD_BE_DEFINED_AND2
  465. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND2 is not defined.\n");
  466. #else
  467. cmPassed("SHOULD_BE_DEFINED_AND2 is defined.");
  468. #endif
  469. #ifdef SHOULD_NOT_BE_DEFINED_OR
  470. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
  471. #else
  472. cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
  473. #endif
  474. #ifndef SHOULD_BE_DEFINED_OR
  475. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
  476. #else
  477. cmPassed("SHOULD_BE_DEFINED_OR is defined.");
  478. #endif
  479. #ifdef SHOULD_NOT_BE_DEFINED_OR2
  480. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR2 is defined.");
  481. #else
  482. cmPassed("SHOULD_NOT_BE_DEFINED_OR2 is not defined.");
  483. #endif
  484. #ifndef SHOULD_BE_DEFINED_OR2
  485. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR2 is not defined.\n");
  486. #else
  487. cmPassed("SHOULD_BE_DEFINED_OR2 is defined.");
  488. #endif
  489. #ifdef SHOULD_NOT_BE_DEFINED_MATCHES
  490. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
  491. #else
  492. cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
  493. #endif
  494. #ifndef SHOULD_BE_DEFINED_MATCHES
  495. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
  496. #else
  497. cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
  498. #endif
  499. #ifdef SHOULD_NOT_BE_DEFINED_MATCHES2
  500. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES2 is defined.");
  501. #else
  502. cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES2 is not defined.");
  503. #endif
  504. #ifndef SHOULD_BE_DEFINED_MATCHES2
  505. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
  506. #else
  507. cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined.");
  508. #endif
  509. #ifdef SHOULD_NOT_BE_DEFINED_COMMAND
  510. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
  511. #else
  512. cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
  513. #endif
  514. #ifndef SHOULD_BE_DEFINED_COMMAND
  515. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
  516. #else
  517. cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
  518. #endif
  519. #ifdef SHOULD_NOT_BE_DEFINED_COMMAND2
  520. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND2 is defined.");
  521. #else
  522. cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND2 is not defined.");
  523. #endif
  524. #ifndef SHOULD_BE_DEFINED_COMMAND2
  525. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
  526. #else
  527. cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined.");
  528. #endif
  529. #ifdef SHOULD_NOT_BE_DEFINED_EXISTS
  530. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS is defined.");
  531. #else
  532. cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS is not defined.");
  533. #endif
  534. #ifndef SHOULD_BE_DEFINED_EXISTS
  535. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS is not defined.\n");
  536. #else
  537. cmPassed("SHOULD_BE_DEFINED_EXISTS is defined.");
  538. #endif
  539. #ifdef SHOULD_NOT_BE_DEFINED_EXISTS2
  540. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS2 is defined.");
  541. #else
  542. cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS2 is not defined.");
  543. #endif
  544. #ifndef SHOULD_BE_DEFINED_EXISTS2
  545. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS2 is not defined.\n");
  546. #else
  547. cmPassed("SHOULD_BE_DEFINED_EXISTS2 is defined.");
  548. #endif
  549. #ifdef SHOULD_NOT_BE_DEFINED_LESS
  550. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS is defined.");
  551. #else
  552. cmPassed("SHOULD_NOT_BE_DEFINED_LESS is not defined.");
  553. #endif
  554. #ifndef SHOULD_BE_DEFINED_LESS
  555. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.\n");
  556. #else
  557. cmPassed("SHOULD_BE_DEFINED_LESS is defined.");
  558. #endif
  559. #ifdef SHOULD_NOT_BE_DEFINED_LESS2
  560. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS2 is defined.");
  561. #else
  562. cmPassed("SHOULD_NOT_BE_DEFINED_LESS2 is not defined.");
  563. #endif
  564. #ifndef SHOULD_BE_DEFINED_LESS2
  565. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.\n");
  566. #else
  567. cmPassed("SHOULD_BE_DEFINED_LESS2 is defined.");
  568. #endif
  569. #ifdef SHOULD_NOT_BE_DEFINED_GREATER
  570. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER is defined.");
  571. #else
  572. cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined.");
  573. #endif
  574. #ifdef SHOULD_NOT_BE_DEFINED_EQUAL
  575. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
  576. #else
  577. cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
  578. #endif
  579. #ifndef SHOULD_BE_DEFINED_EQUAL
  580. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n");
  581. #else
  582. cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
  583. #endif
  584. #ifndef SHOULD_BE_DEFINED_GREATER
  585. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n");
  586. #else
  587. cmPassed("SHOULD_BE_DEFINED_GREATER is defined.");
  588. #endif
  589. #ifdef SHOULD_NOT_BE_DEFINED_GREATER2
  590. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER2 is defined.");
  591. #else
  592. cmPassed("SHOULD_NOT_BE_DEFINED_GREATER2 is not defined.");
  593. #endif
  594. #ifndef SHOULD_BE_DEFINED_GREATER2
  595. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
  596. #else
  597. cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
  598. #endif
  599. #ifdef SHOULD_NOT_BE_DEFINED_STRLESS
  600. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined.");
  601. #else
  602. cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS is not defined.");
  603. #endif
  604. #ifndef SHOULD_BE_DEFINED_STRLESS
  605. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n");
  606. #else
  607. cmPassed("SHOULD_BE_DEFINED_STRLESS is defined.");
  608. #endif
  609. #ifdef SHOULD_NOT_BE_DEFINED_STRLESS2
  610. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS2 is defined.");
  611. #else
  612. cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS2 is not defined.");
  613. #endif
  614. #ifndef SHOULD_BE_DEFINED_STRLESS2
  615. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
  616. #else
  617. cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
  618. #endif
  619. #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER
  620. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
  621. #else
  622. cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined.");
  623. #endif
  624. #ifndef SHOULD_BE_DEFINED_STRGREATER
  625. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
  626. #else
  627. cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
  628. #endif
  629. #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2
  630. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
  631. #else
  632. cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined.");
  633. #endif
  634. #ifndef SHOULD_BE_DEFINED_STRGREATER2
  635. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
  636. #else
  637. cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
  638. #endif
  639. // ----------------------------------------------------------------------
  640. // Test FOREACH
  641. #ifndef FOREACH_VAR1
  642. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  643. "FOREACH_VAR1 is not defined.");
  644. #else
  645. if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
  646. {
  647. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  648. "FOREACH_VAR1 == ", FOREACH_VAR1);
  649. }
  650. else
  651. {
  652. cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
  653. }
  654. #endif
  655. #ifndef FOREACH_VAR2
  656. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  657. "FOREACH_VAR2 is not defined.");
  658. #else
  659. if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
  660. {
  661. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  662. "FOREACH_VAR2 == ", FOREACH_VAR2);
  663. }
  664. else
  665. {
  666. cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
  667. }
  668. #endif
  669. #ifndef FOREACH_CONCAT
  670. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  671. "FOREACH_CONCAT is not defined.");
  672. #else
  673. if(strcmp(FOREACH_CONCAT, "abcdefg") != 0)
  674. {
  675. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  676. "FOREACH_CONCAT == ", FOREACH_CONCAT);
  677. }
  678. else
  679. {
  680. cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT);
  681. }
  682. #endif
  683. // ----------------------------------------------------------------------
  684. // Test WHILE
  685. if(WHILE_VALUE != 1000)
  686. {
  687. cmFailed("WHILE command is not working");
  688. }
  689. else
  690. {
  691. cmPassed("WHILE command is working");
  692. }
  693. // ----------------------------------------------------------------------
  694. // Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
  695. #ifndef FILENAME_VAR_PATH_NAME
  696. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  697. "FILENAME_VAR_PATH_NAME is not defined.");
  698. #else
  699. if((strcmp(FILENAME_VAR_PATH_NAME, "Complex") == 0) ||
  700. (strcmp(FILENAME_VAR_PATH_NAME, "ComplexOneConfig") == 0) ||
  701. (strcmp(FILENAME_VAR_PATH_NAME, "ComplexRelativePaths") == 0))
  702. {
  703. cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
  704. }
  705. else
  706. {
  707. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  708. "FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
  709. }
  710. #endif
  711. #ifndef FILENAME_VAR_NAME
  712. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  713. "FILENAME_VAR_NAME is not defined.");
  714. #else
  715. if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
  716. {
  717. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  718. "FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
  719. }
  720. else
  721. {
  722. cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
  723. }
  724. #endif
  725. #ifndef FILENAME_VAR_EXT
  726. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  727. "FILENAME_VAR_EXT is not defined.");
  728. #else
  729. if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
  730. {
  731. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  732. "FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
  733. }
  734. else
  735. {
  736. cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
  737. }
  738. #endif
  739. #ifndef FILENAME_VAR_NAME_WE
  740. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  741. "FILENAME_VAR_NAME_WE is not defined.");
  742. #else
  743. if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
  744. {
  745. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  746. "FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
  747. }
  748. else
  749. {
  750. cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
  751. }
  752. #endif
  753. #ifndef PATH_VAR_NAME
  754. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  755. "PATH_VAR_NAME is not defined.");
  756. #else
  757. if((strcmp(PATH_VAR_NAME, "Complex") == 0) ||
  758. (strcmp(PATH_VAR_NAME, "ComplexOneConfig") == 0) ||
  759. (strcmp(PATH_VAR_NAME, "ComplexRelativePaths") == 0))
  760. {
  761. cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
  762. }
  763. else
  764. {
  765. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  766. "PATH_VAR_NAME == ", PATH_VAR_NAME);
  767. }
  768. #endif
  769. // ----------------------------------------------------------------------
  770. // Test LOAD_CACHE
  771. #ifndef CACHE_TEST_VAR1
  772. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  773. "CACHE_TEST_VAR1 is not defined.");
  774. #else
  775. if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
  776. {
  777. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  778. "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
  779. }
  780. else
  781. {
  782. cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
  783. }
  784. #endif
  785. #ifndef CACHE_TEST_VAR2
  786. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  787. "CACHE_TEST_VAR2 is not defined.");
  788. #else
  789. if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
  790. {
  791. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  792. "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
  793. }
  794. else
  795. {
  796. cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
  797. }
  798. #endif
  799. #ifndef CACHE_TEST_VAR3
  800. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  801. "CACHE_TEST_VAR3 is not defined.");
  802. #else
  803. if(strcmp(CACHE_TEST_VAR3, "1") != 0)
  804. {
  805. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  806. "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
  807. }
  808. else
  809. {
  810. cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
  811. }
  812. #endif
  813. #ifdef CACHE_TEST_VAR_EXCLUDED
  814. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
  815. "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
  816. #else
  817. cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
  818. #endif
  819. #ifndef CACHE_TEST_VAR_INTERNAL
  820. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  821. "CACHE_TEST_VAR_INTERNAL is not defined.");
  822. #else
  823. std::string cachetest = CACHE_TEST_VAR_INTERNAL;
  824. if(cachetest != "bar")
  825. {
  826. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  827. "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
  828. }
  829. else
  830. {
  831. cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
  832. }
  833. #endif
  834. // ----------------------------------------------------------------------
  835. // Some pre-build/pre-link/post-build custom-commands have been
  836. // attached to the lib (see Library/).
  837. // Each runs ${CREATE_FILE_EXE} which will create a file.
  838. // It also copies that file again using cmake -E.
  839. // Similar rules have been added to this executable.
  840. //
  841. // WARNING: if you run 'complex' manually, this *will* fail, because
  842. // the file was removed the last time 'complex' was run, and it is
  843. // only created during a build.
  844. TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt");
  845. TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt");
  846. TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
  847. TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt");
  848. TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt");
  849. TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt");
  850. TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt");
  851. TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt");
  852. // ----------------------------------------------------------------------
  853. // A custom target has been created (see Library/).
  854. // It runs ${CREATE_FILE_EXE} which will create a file.
  855. //
  856. // WARNING: if you run 'complex' manually, this *will* fail, because
  857. // the file was removed the last time 'complex' was run, and it is
  858. // only created during a build.
  859. TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
  860. // ----------------------------------------------------------------------
  861. // A directory has been created.
  862. TestDir(BINARY_DIR "/make_dir");
  863. // ----------------------------------------------------------------------
  864. // Test OUTPUT_REQUIRED_FILES
  865. // The files required by 'complex' have been output to a file.
  866. // The contents of this file is not tested (absolute paths).
  867. //
  868. // WARNING: if you run 'complex' manually, this *will* fail, because
  869. // the file was removed the last time 'complex' was run, and it is
  870. // only created during a build.
  871. TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt");
  872. // ----------------------------------------------------------------------
  873. // Test FIND_LIBRARY
  874. #ifndef FIND_DUMMY_LIB
  875. cmFailed("the CONFIGURE_FILE command is broken, "
  876. "FIND_DUMMY_LIB is not defined.");
  877. #else
  878. if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL)
  879. {
  880. cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, "
  881. "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
  882. }
  883. else
  884. {
  885. cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
  886. }
  887. #endif
  888. // ----------------------------------------------------------------------
  889. // Test SET_SOURCE_FILES_PROPERTIES
  890. #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
  891. cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
  892. #else
  893. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
  894. #endif
  895. #ifndef FILE_HAS_ABSTRACT
  896. cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag");
  897. #else
  898. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag");
  899. #endif
  900. #ifndef FILE_HAS_WRAP_EXCLUDE
  901. cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag");
  902. #else
  903. cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag");
  904. #endif
  905. #ifndef FILE_COMPILE_FLAGS
  906. cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined.");
  907. #else
  908. if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0)
  909. {
  910. cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ",
  911. FILE_COMPILE_FLAGS);
  912. }
  913. else
  914. {
  915. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS);
  916. }
  917. #endif
  918. // ----------------------------------------------------------------------
  919. // Test registry (win32)
  920. #if defined(_WIN32) && !defined(__CYGWIN__)
  921. #ifndef REGISTRY_TEST_PATH
  922. cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
  923. #else
  924. std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
  925. if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
  926. {
  927. cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
  928. REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir");
  929. }
  930. else
  931. {
  932. cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
  933. }
  934. #endif
  935. #endif // defined(_WIN32) && !defined(__CYGWIN__)
  936. if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0)
  937. {
  938. cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3");
  939. }
  940. else
  941. {
  942. cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3");
  943. }
  944. // ----------------------------------------------------------------------
  945. // Test REMOVE command
  946. if (strcmp("a;b;d",REMOVE_STRING) == 0)
  947. {
  948. cmPassed("REMOVE is working");
  949. }
  950. else
  951. {
  952. cmFailed("REMOVE is not working");
  953. }
  954. // ----------------------------------------------------------------------
  955. // Test SEPARATE_ARGUMENTS
  956. if(strcmp("a;b;c", TEST_SEP) == 0)
  957. {
  958. cmPassed("SEPARATE_ARGUMENTS is working");
  959. }
  960. else
  961. {
  962. cmFailed("SEPARATE_ARGUMENTS is not working");
  963. }
  964. // ----------------------------------------------------------------------
  965. // Test Escape Quotes
  966. if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0)
  967. {
  968. cmPassed("ESCAPE_QUOTES is working");
  969. }
  970. else
  971. {
  972. cmFailed("ESCAPE_QUOTES is not working");
  973. }
  974. // ----------------------------------------------------------------------
  975. // Test cmSystemTools::UpperCase
  976. std::string str = "abc";
  977. std::string strupper = "ABC";
  978. if(cmSystemTools::UpperCase(str) == strupper)
  979. {
  980. cmPassed("cmSystemTools::UpperCase is working");
  981. }
  982. else
  983. {
  984. cmFailed("cmSystemTools::UpperCase is working");
  985. }
  986. // ----------------------------------------------------------------------
  987. // Test if IF command inside a FOREACH works.
  988. #if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
  989. cmPassed("IF inside a FOREACH block works");
  990. #else
  991. cmFailed("IF inside a FOREACH block is broken");
  992. #endif
  993. #if defined(GENERATED_HEADER_INCLUDED)
  994. cmPassed("Generated header included by non-generated source works.");
  995. #else
  996. cmFailed("Generated header included by non-generated source failed.");
  997. #endif
  998. #ifdef FORCE_TEST
  999. cmFailed("CMake SET CACHE FORCE");
  1000. #else
  1001. cmPassed("CMake SET CACHE FORCE");
  1002. #endif
  1003. // first run with shouldFail = true, this will
  1004. // run with A B C as set by the CMakeList.txt file.
  1005. if(!TestLibraryOrder(true))
  1006. {
  1007. cmPassed("CMake cmOrderLinkDirectories failed when it should.");
  1008. }
  1009. else
  1010. {
  1011. cmFailed("CMake cmOrderLinkDirectories failed to fail when given an impossible set of paths.");
  1012. }
  1013. // next run with shouldPass = true, this will
  1014. // run with B/libA.a removed and should create the order
  1015. // B C A
  1016. if(TestLibraryOrder(false))
  1017. {
  1018. cmPassed("CMake cmOrderLinkDirectories worked.");
  1019. }
  1020. else
  1021. {
  1022. cmFailed("CMake cmOrderLinkDirectories failed.");
  1023. }
  1024. // Test the generated file stream.
  1025. TestCMGeneratedFileSTream();
  1026. // ----------------------------------------------------------------------
  1027. // Summary
  1028. std::cout << "Passed: " << cm_passed << "\n";
  1029. if(cm_failed)
  1030. {
  1031. std::cout << "Failed: " << cm_failed << "\n";
  1032. return cm_failed;
  1033. }
  1034. return 0;
  1035. }