complex.cxx 34 KB

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