complex.cxx 33 KB

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