complex.cxx 34 KB

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