complex.cxx 36 KB

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