complex.cxx 37 KB

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