complex.cxx 37 KB

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