complex.cxx 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  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. #ifdef TEST_C_FLAGS
  354. cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
  355. #else
  356. cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
  357. #endif
  358. char msg[1024];
  359. if(TestCFlags(msg))
  360. {
  361. cmPassed(
  362. "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
  363. }
  364. else
  365. {
  366. cmFailed(msg);
  367. }
  368. // ----------------------------------------------------------------------
  369. // Test ADD_DEFINITIONS
  370. #ifndef CMAKE_IS_FUN
  371. cmFailed("CMake is not fun, so it is broken and should be fixed.");
  372. #else
  373. cmPassed("CMAKE_IS_FUN is defined.");
  374. #endif
  375. #if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4)
  376. cmPassed("Variable args for MACROs are working.");
  377. #else
  378. cmFailed("Variable args for MACROs are failing.");
  379. #endif
  380. // ----------------------------------------------------------------------
  381. // Test SET, VARIABLE_REQUIRES
  382. #ifdef SHOULD_NOT_BE_DEFINED
  383. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
  384. #else
  385. cmPassed("SHOULD_NOT_BE_DEFINED is not defined.");
  386. #endif
  387. #ifndef SHOULD_BE_DEFINED
  388. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED is not defined.\n");
  389. #else
  390. cmPassed("SHOULD_BE_DEFINED is defined.");
  391. #endif
  392. #ifndef ONE_VAR
  393. cmFailed("cmakedefine is broken, ONE_VAR is not defined.");
  394. #else
  395. cmPassed("ONE_VAR is defined.");
  396. #endif
  397. #ifndef ONE_VAR_IS_DEFINED
  398. cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
  399. "ONE_VAR_IS_DEFINED is not defined.");
  400. #else
  401. cmPassed("ONE_VAR_IS_DEFINED is defined.");
  402. #endif
  403. #ifdef ZERO_VAR
  404. cmFailed("cmakedefine is broken, ZERO_VAR is defined.");
  405. #else
  406. cmPassed("ZERO_VAR is not defined.");
  407. #endif
  408. #ifndef STRING_VAR
  409. cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
  410. #else
  411. if(strcmp(STRING_VAR, "CMake is great") != 0)
  412. {
  413. cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
  414. STRING_VAR);
  415. }
  416. else
  417. {
  418. cmPassed("STRING_VAR == ", STRING_VAR);
  419. }
  420. #endif
  421. // ----------------------------------------------------------------------
  422. // Test various IF/ELSE combinations
  423. #ifdef SHOULD_NOT_BE_DEFINED_NOT
  424. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
  425. #else
  426. cmPassed("SHOULD_NOT_BE_DEFINED_NOT is not defined.");
  427. #endif
  428. #ifndef SHOULD_BE_DEFINED_NOT
  429. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT is not defined.\n");
  430. #else
  431. cmPassed("SHOULD_BE_DEFINED_NOT is defined.");
  432. #endif
  433. #ifdef SHOULD_NOT_BE_DEFINED_NOT2
  434. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT2 is defined.");
  435. #else
  436. cmPassed("SHOULD_NOT_BE_DEFINED_NOT2 is not defined.");
  437. #endif
  438. #ifndef SHOULD_BE_DEFINED_NOT2
  439. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_NOT2 is not defined.\n");
  440. #else
  441. cmPassed("SHOULD_BE_DEFINED_NOT2 is defined.");
  442. #endif
  443. #ifdef SHOULD_NOT_BE_DEFINED_AND
  444. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
  445. #else
  446. cmPassed("SHOULD_NOT_BE_DEFINED_AND is not defined.");
  447. #endif
  448. #ifndef SHOULD_BE_DEFINED_AND
  449. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND is not defined.\n");
  450. #else
  451. cmPassed("SHOULD_BE_DEFINED_AND is defined.");
  452. #endif
  453. #ifdef SHOULD_NOT_BE_DEFINED_AND2
  454. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND2 is defined.");
  455. #else
  456. cmPassed("SHOULD_NOT_BE_DEFINED_AND2 is not defined.");
  457. #endif
  458. #ifndef SHOULD_BE_DEFINED_AND2
  459. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_AND2 is not defined.\n");
  460. #else
  461. cmPassed("SHOULD_BE_DEFINED_AND2 is defined.");
  462. #endif
  463. #ifdef SHOULD_NOT_BE_DEFINED_OR
  464. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR is defined.");
  465. #else
  466. cmPassed("SHOULD_NOT_BE_DEFINED_OR is not defined.");
  467. #endif
  468. #ifndef SHOULD_BE_DEFINED_OR
  469. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR is not defined.\n");
  470. #else
  471. cmPassed("SHOULD_BE_DEFINED_OR is defined.");
  472. #endif
  473. #ifdef SHOULD_NOT_BE_DEFINED_OR2
  474. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_OR2 is defined.");
  475. #else
  476. cmPassed("SHOULD_NOT_BE_DEFINED_OR2 is not defined.");
  477. #endif
  478. #ifndef SHOULD_BE_DEFINED_OR2
  479. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_OR2 is not defined.\n");
  480. #else
  481. cmPassed("SHOULD_BE_DEFINED_OR2 is defined.");
  482. #endif
  483. #ifdef SHOULD_NOT_BE_DEFINED_MATCHES
  484. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES is defined.");
  485. #else
  486. cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES is not defined.");
  487. #endif
  488. #ifndef SHOULD_BE_DEFINED_MATCHES
  489. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES is not defined.\n");
  490. #else
  491. cmPassed("SHOULD_BE_DEFINED_MATCHES is defined.");
  492. #endif
  493. #ifdef SHOULD_NOT_BE_DEFINED_MATCHES2
  494. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_MATCHES2 is defined.");
  495. #else
  496. cmPassed("SHOULD_NOT_BE_DEFINED_MATCHES2 is not defined.");
  497. #endif
  498. #ifndef SHOULD_BE_DEFINED_MATCHES2
  499. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
  500. #else
  501. cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined.");
  502. #endif
  503. #ifdef SHOULD_NOT_BE_DEFINED_COMMAND
  504. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND is defined.");
  505. #else
  506. cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND is not defined.");
  507. #endif
  508. #ifndef SHOULD_BE_DEFINED_COMMAND
  509. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND is not defined.\n");
  510. #else
  511. cmPassed("SHOULD_BE_DEFINED_COMMAND is defined.");
  512. #endif
  513. #ifdef SHOULD_NOT_BE_DEFINED_COMMAND2
  514. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_COMMAND2 is defined.");
  515. #else
  516. cmPassed("SHOULD_NOT_BE_DEFINED_COMMAND2 is not defined.");
  517. #endif
  518. #ifndef SHOULD_BE_DEFINED_COMMAND2
  519. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
  520. #else
  521. cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined.");
  522. #endif
  523. #ifdef SHOULD_NOT_BE_DEFINED_EXISTS
  524. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS is defined.");
  525. #else
  526. cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS is not defined.");
  527. #endif
  528. #ifndef SHOULD_BE_DEFINED_EXISTS
  529. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS is not defined.\n");
  530. #else
  531. cmPassed("SHOULD_BE_DEFINED_EXISTS is defined.");
  532. #endif
  533. #ifdef SHOULD_NOT_BE_DEFINED_EXISTS2
  534. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EXISTS2 is defined.");
  535. #else
  536. cmPassed("SHOULD_NOT_BE_DEFINED_EXISTS2 is not defined.");
  537. #endif
  538. #ifndef SHOULD_BE_DEFINED_EXISTS2
  539. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EXISTS2 is not defined.\n");
  540. #else
  541. cmPassed("SHOULD_BE_DEFINED_EXISTS2 is defined.");
  542. #endif
  543. #ifdef SHOULD_NOT_BE_DEFINED_LESS
  544. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS is defined.");
  545. #else
  546. cmPassed("SHOULD_NOT_BE_DEFINED_LESS is not defined.");
  547. #endif
  548. #ifndef SHOULD_BE_DEFINED_LESS
  549. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS is not defined.\n");
  550. #else
  551. cmPassed("SHOULD_BE_DEFINED_LESS is defined.");
  552. #endif
  553. #ifdef SHOULD_NOT_BE_DEFINED_LESS2
  554. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_LESS2 is defined.");
  555. #else
  556. cmPassed("SHOULD_NOT_BE_DEFINED_LESS2 is not defined.");
  557. #endif
  558. #ifndef SHOULD_BE_DEFINED_LESS2
  559. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_LESS2 is not defined.\n");
  560. #else
  561. cmPassed("SHOULD_BE_DEFINED_LESS2 is defined.");
  562. #endif
  563. #ifdef SHOULD_NOT_BE_DEFINED_GREATER
  564. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER is defined.");
  565. #else
  566. cmPassed("SHOULD_NOT_BE_DEFINED_GREATER is not defined.");
  567. #endif
  568. #ifdef SHOULD_NOT_BE_DEFINED_EQUAL
  569. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_EQUAL is defined.");
  570. #else
  571. cmPassed("SHOULD_NOT_BE_DEFINED_EQUAL is not defined.");
  572. #endif
  573. #ifndef SHOULD_BE_DEFINED_EQUAL
  574. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_EQUAL is not defined.\n");
  575. #else
  576. cmPassed("SHOULD_BE_DEFINED_EQUAL is defined.");
  577. #endif
  578. #ifndef SHOULD_BE_DEFINED_GREATER
  579. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER is not defined.\n");
  580. #else
  581. cmPassed("SHOULD_BE_DEFINED_GREATER is defined.");
  582. #endif
  583. #ifdef SHOULD_NOT_BE_DEFINED_GREATER2
  584. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_GREATER2 is defined.");
  585. #else
  586. cmPassed("SHOULD_NOT_BE_DEFINED_GREATER2 is not defined.");
  587. #endif
  588. #ifndef SHOULD_BE_DEFINED_GREATER2
  589. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
  590. #else
  591. cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
  592. #endif
  593. #ifdef SHOULD_NOT_BE_DEFINED_STRLESS
  594. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS is defined.");
  595. #else
  596. cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS is not defined.");
  597. #endif
  598. #ifndef SHOULD_BE_DEFINED_STRLESS
  599. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS is not defined.\n");
  600. #else
  601. cmPassed("SHOULD_BE_DEFINED_STRLESS is defined.");
  602. #endif
  603. #ifdef SHOULD_NOT_BE_DEFINED_STRLESS2
  604. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRLESS2 is defined.");
  605. #else
  606. cmPassed("SHOULD_NOT_BE_DEFINED_STRLESS2 is not defined.");
  607. #endif
  608. #ifndef SHOULD_BE_DEFINED_STRLESS2
  609. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
  610. #else
  611. cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
  612. #endif
  613. #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER
  614. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
  615. #else
  616. cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined.");
  617. #endif
  618. #ifndef SHOULD_BE_DEFINED_STRGREATER
  619. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
  620. #else
  621. cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
  622. #endif
  623. #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2
  624. cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
  625. #else
  626. cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined.");
  627. #endif
  628. #ifndef SHOULD_BE_DEFINED_STRGREATER2
  629. cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
  630. #else
  631. cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
  632. #endif
  633. // ----------------------------------------------------------------------
  634. // Test FOREACH
  635. #ifndef FOREACH_VAR1
  636. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  637. "FOREACH_VAR1 is not defined.");
  638. #else
  639. if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
  640. {
  641. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  642. "FOREACH_VAR1 == ", FOREACH_VAR1);
  643. }
  644. else
  645. {
  646. cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
  647. }
  648. #endif
  649. #ifndef FOREACH_VAR2
  650. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  651. "FOREACH_VAR2 is not defined.");
  652. #else
  653. if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
  654. {
  655. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  656. "FOREACH_VAR2 == ", FOREACH_VAR2);
  657. }
  658. else
  659. {
  660. cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
  661. }
  662. #endif
  663. #ifndef FOREACH_CONCAT
  664. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  665. "FOREACH_CONCAT is not defined.");
  666. #else
  667. if(strcmp(FOREACH_CONCAT, "abcdefg") != 0)
  668. {
  669. cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
  670. "FOREACH_CONCAT == ", FOREACH_CONCAT);
  671. }
  672. else
  673. {
  674. cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT);
  675. }
  676. #endif
  677. // ----------------------------------------------------------------------
  678. // Test WHILE
  679. if(WHILE_VALUE != 1000)
  680. {
  681. cmFailed("WHILE command is not working");
  682. }
  683. else
  684. {
  685. cmPassed("WHILE command is working");
  686. }
  687. // ----------------------------------------------------------------------
  688. // Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
  689. #ifndef FILENAME_VAR_PATH_NAME
  690. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  691. "FILENAME_VAR_PATH_NAME is not defined.");
  692. #else
  693. if((strcmp(FILENAME_VAR_PATH_NAME, "Complex") == 0) ||
  694. (strcmp(FILENAME_VAR_PATH_NAME, "ComplexOneConfig") == 0) ||
  695. (strcmp(FILENAME_VAR_PATH_NAME, "ComplexRelativePaths") == 0))
  696. {
  697. cmPassed("FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
  698. }
  699. else
  700. {
  701. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  702. "FILENAME_VAR_PATH_NAME == ", FILENAME_VAR_PATH_NAME);
  703. }
  704. #endif
  705. #ifndef FILENAME_VAR_NAME
  706. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  707. "FILENAME_VAR_NAME is not defined.");
  708. #else
  709. if(strcmp(FILENAME_VAR_NAME, "VarTests.cmake") != 0)
  710. {
  711. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  712. "FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
  713. }
  714. else
  715. {
  716. cmPassed("FILENAME_VAR_NAME == ", FILENAME_VAR_NAME);
  717. }
  718. #endif
  719. #ifndef FILENAME_VAR_EXT
  720. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  721. "FILENAME_VAR_EXT is not defined.");
  722. #else
  723. if(strcmp(FILENAME_VAR_EXT, ".cmake") != 0)
  724. {
  725. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  726. "FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
  727. }
  728. else
  729. {
  730. cmPassed("FILENAME_VAR_EXT == ", FILENAME_VAR_EXT);
  731. }
  732. #endif
  733. #ifndef FILENAME_VAR_NAME_WE
  734. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  735. "FILENAME_VAR_NAME_WE is not defined.");
  736. #else
  737. if(strcmp(FILENAME_VAR_NAME_WE, "VarTests") != 0)
  738. {
  739. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  740. "FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
  741. }
  742. else
  743. {
  744. cmPassed("FILENAME_VAR_NAME_WE == ", FILENAME_VAR_NAME_WE);
  745. }
  746. #endif
  747. #ifndef PATH_VAR_NAME
  748. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  749. "PATH_VAR_NAME is not defined.");
  750. #else
  751. if((strcmp(PATH_VAR_NAME, "Complex") == 0) ||
  752. (strcmp(PATH_VAR_NAME, "ComplexOneConfig") == 0) ||
  753. (strcmp(PATH_VAR_NAME, "ComplexRelativePaths") == 0))
  754. {
  755. cmPassed("PATH_VAR_NAME == ", PATH_VAR_NAME);
  756. }
  757. else
  758. {
  759. cmFailed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
  760. "PATH_VAR_NAME == ", PATH_VAR_NAME);
  761. }
  762. #endif
  763. // ----------------------------------------------------------------------
  764. // Test LOAD_CACHE
  765. #ifndef CACHE_TEST_VAR1
  766. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  767. "CACHE_TEST_VAR1 is not defined.");
  768. #else
  769. if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
  770. {
  771. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  772. "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
  773. }
  774. else
  775. {
  776. cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
  777. }
  778. #endif
  779. #ifndef CACHE_TEST_VAR2
  780. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  781. "CACHE_TEST_VAR2 is not defined.");
  782. #else
  783. if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
  784. {
  785. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  786. "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
  787. }
  788. else
  789. {
  790. cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
  791. }
  792. #endif
  793. #ifndef CACHE_TEST_VAR3
  794. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  795. "CACHE_TEST_VAR3 is not defined.");
  796. #else
  797. if(strcmp(CACHE_TEST_VAR3, "1") != 0)
  798. {
  799. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  800. "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
  801. }
  802. else
  803. {
  804. cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
  805. }
  806. #endif
  807. #ifdef CACHE_TEST_VAR_EXCLUDED
  808. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
  809. "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
  810. #else
  811. cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
  812. #endif
  813. #ifndef CACHE_TEST_VAR_INTERNAL
  814. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  815. "CACHE_TEST_VAR_INTERNAL is not defined.");
  816. #else
  817. std::string cachetest = CACHE_TEST_VAR_INTERNAL;
  818. if(cachetest != "bar")
  819. {
  820. cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
  821. "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
  822. }
  823. else
  824. {
  825. cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
  826. }
  827. #endif
  828. // ----------------------------------------------------------------------
  829. // Some pre-build/pre-link/post-build custom-commands have been
  830. // attached to the lib (see Library/).
  831. // Each runs ${CREATE_FILE_EXE} which will create a file.
  832. // It also copies that file again using cmake -E.
  833. // Similar rules have been added to this executable.
  834. //
  835. // WARNING: if you run 'complex' manually, this *will* fail, because
  836. // the file was removed the last time 'complex' was run, and it is
  837. // only created during a build.
  838. TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt");
  839. TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt");
  840. TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
  841. TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt");
  842. TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt");
  843. TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt");
  844. TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt");
  845. TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt");
  846. // ----------------------------------------------------------------------
  847. // A custom target has been created (see Library/).
  848. // It runs ${CREATE_FILE_EXE} which will create a file.
  849. //
  850. // WARNING: if you run 'complex' manually, this *will* fail, because
  851. // the file was removed the last time 'complex' was run, and it is
  852. // only created during a build.
  853. TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
  854. // ----------------------------------------------------------------------
  855. // A directory has been created.
  856. TestDir(BINARY_DIR "/make_dir");
  857. // ----------------------------------------------------------------------
  858. // Test OUTPUT_REQUIRED_FILES
  859. // The files required by 'complex' have been output to a file.
  860. // The contents of this file is not tested (absolute paths).
  861. //
  862. // WARNING: if you run 'complex' manually, this *will* fail, because
  863. // the file was removed the last time 'complex' was run, and it is
  864. // only created during a build.
  865. TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt");
  866. // ----------------------------------------------------------------------
  867. // Test FIND_LIBRARY
  868. #ifndef FIND_DUMMY_LIB
  869. cmFailed("the CONFIGURE_FILE command is broken, "
  870. "FIND_DUMMY_LIB is not defined.");
  871. #else
  872. if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL)
  873. {
  874. cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, "
  875. "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
  876. }
  877. else
  878. {
  879. cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
  880. }
  881. #endif
  882. // ----------------------------------------------------------------------
  883. // Test SET_SOURCE_FILES_PROPERTIES
  884. #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
  885. cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
  886. #else
  887. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
  888. #endif
  889. #ifndef FILE_HAS_ABSTRACT
  890. cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag");
  891. #else
  892. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag");
  893. #endif
  894. #ifndef FILE_HAS_WRAP_EXCLUDE
  895. cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag");
  896. #else
  897. cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag");
  898. #endif
  899. #ifndef FILE_COMPILE_FLAGS
  900. cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined.");
  901. #else
  902. if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0)
  903. {
  904. cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ",
  905. FILE_COMPILE_FLAGS);
  906. }
  907. else
  908. {
  909. cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS);
  910. }
  911. #endif
  912. // ----------------------------------------------------------------------
  913. // Test registry (win32)
  914. #if defined(_WIN32) && !defined(__CYGWIN__)
  915. #ifndef REGISTRY_TEST_PATH
  916. cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
  917. #else
  918. std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
  919. if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
  920. {
  921. cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
  922. REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir");
  923. }
  924. else
  925. {
  926. cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
  927. }
  928. #endif
  929. #endif // defined(_WIN32) && !defined(__CYGWIN__)
  930. if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0)
  931. {
  932. cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3");
  933. }
  934. else
  935. {
  936. cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3");
  937. }
  938. // ----------------------------------------------------------------------
  939. // Test REMOVE command
  940. if (strcmp("a;b;d",REMOVE_STRING) == 0)
  941. {
  942. cmPassed("REMOVE is working");
  943. }
  944. else
  945. {
  946. cmFailed("REMOVE is not working");
  947. }
  948. // ----------------------------------------------------------------------
  949. // Test SEPARATE_ARGUMENTS
  950. if(strcmp("a;b;c", TEST_SEP) == 0)
  951. {
  952. cmPassed("SEPARATE_ARGUMENTS is working");
  953. }
  954. else
  955. {
  956. cmFailed("SEPARATE_ARGUMENTS is not working");
  957. }
  958. // ----------------------------------------------------------------------
  959. // Test Escape Quotes
  960. if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0)
  961. {
  962. cmPassed("ESCAPE_QUOTES is working");
  963. }
  964. else
  965. {
  966. cmFailed("ESCAPE_QUOTES is not working");
  967. }
  968. // ----------------------------------------------------------------------
  969. // Test cmSystemTools::UpperCase
  970. std::string str = "abc";
  971. std::string strupper = "ABC";
  972. if(cmSystemTools::UpperCase(str) == strupper)
  973. {
  974. cmPassed("cmSystemTools::UpperCase is working");
  975. }
  976. else
  977. {
  978. cmFailed("cmSystemTools::UpperCase is working");
  979. }
  980. // ----------------------------------------------------------------------
  981. // Test if IF command inside a FOREACH works.
  982. #if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
  983. cmPassed("IF inside a FOREACH block works");
  984. #else
  985. cmFailed("IF inside a FOREACH block is broken");
  986. #endif
  987. #if defined(GENERATED_HEADER_INCLUDED)
  988. cmPassed("Generated header included by non-generated source works.");
  989. #else
  990. cmFailed("Generated header included by non-generated source failed.");
  991. #endif
  992. #ifdef FORCE_TEST
  993. cmFailed("CMake SET CACHE FORCE");
  994. #else
  995. cmPassed("CMake SET CACHE FORCE");
  996. #endif
  997. // first run with shouldFail = true, this will
  998. // run with A B C as set by the CMakeList.txt file.
  999. if(!TestLibraryOrder(true))
  1000. {
  1001. cmPassed("CMake cmOrderLinkDirectories failed when it should.");
  1002. }
  1003. else
  1004. {
  1005. cmFailed("CMake cmOrderLinkDirectories failed to fail when given an impossible set of paths.");
  1006. }
  1007. // next run with shouldPass = true, this will
  1008. // run with B/libA.a removed and should create the order
  1009. // B C A
  1010. if(TestLibraryOrder(false))
  1011. {
  1012. cmPassed("CMake cmOrderLinkDirectories worked.");
  1013. }
  1014. else
  1015. {
  1016. cmFailed("CMake cmOrderLinkDirectories failed.");
  1017. }
  1018. // Test the generated file stream.
  1019. TestCMGeneratedFileSTream();
  1020. // ----------------------------------------------------------------------
  1021. // Summary
  1022. std::cout << "Passed: " << cm_passed << "\n";
  1023. if(cm_failed)
  1024. {
  1025. std::cout << "Failed: " << cm_failed << "\n";
  1026. return cm_failed;
  1027. }
  1028. return 0;
  1029. }