complex.cxx 34 KB

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