complex.cxx 36 KB

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