complex.cxx 36 KB

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