complex.cxx 35 KB

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