cmGlobalGenerator.cxx 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmGlobalGenerator.h"
  14. #include "cmLocalGenerator.h"
  15. #include "cmake.h"
  16. #include "cmMakefile.h"
  17. #include <stdlib.h> // required for atof
  18. #if defined(_WIN32) && !defined(__CYGWIN__)
  19. #include <windows.h>
  20. #endif
  21. #include <assert.h>
  22. int cmGlobalGenerator::s_TryCompileTimeout = 0;
  23. cmGlobalGenerator::cmGlobalGenerator()
  24. {
  25. // by default use the native paths
  26. m_ForceUnixPaths = false;
  27. }
  28. cmGlobalGenerator::~cmGlobalGenerator()
  29. {
  30. // Delete any existing cmLocalGenerators
  31. unsigned int i;
  32. for (i = 0; i < m_LocalGenerators.size(); ++i)
  33. {
  34. delete m_LocalGenerators[i];
  35. }
  36. m_LocalGenerators.clear();
  37. }
  38. // Find the make program for the generator, required for try compiles
  39. void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
  40. {
  41. if(m_FindMakeProgramFile.size() == 0)
  42. {
  43. cmSystemTools::Error(
  44. "Generator implementation error, "
  45. "all generators must specify m_FindMakeProgramFile");
  46. }
  47. if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
  48. || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
  49. {
  50. std::string setMakeProgram = mf->GetModulesFile(m_FindMakeProgramFile.c_str());
  51. if(setMakeProgram.size())
  52. {
  53. mf->ReadListFile(0, setMakeProgram.c_str());
  54. }
  55. }
  56. if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
  57. || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
  58. {
  59. cmOStringStream err;
  60. err << "CMake was unable to find a build program corresponding to \""
  61. << this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
  62. << "probably need to select a different build tool.";
  63. cmSystemTools::Error(err.str().c_str());
  64. cmSystemTools::SetFatalErrorOccured();
  65. return;
  66. }
  67. std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
  68. // if there are spaces in the make program use short path
  69. // but do not short path the actual program name, as
  70. // this can cause trouble with VSExpress
  71. if(makeProgram.find(' ') != makeProgram.npos)
  72. {
  73. std::string dir;
  74. std::string file;
  75. cmSystemTools::SplitProgramPath(makeProgram.c_str(),
  76. dir, file);
  77. std::string saveFile = file;
  78. cmSystemTools::GetShortPath(makeProgram.c_str(), makeProgram);
  79. cmSystemTools::SplitProgramPath(makeProgram.c_str(),
  80. dir, file);
  81. makeProgram = dir;
  82. makeProgram += "/";
  83. makeProgram += saveFile;
  84. this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
  85. "make program",
  86. cmCacheManager::FILEPATH);
  87. }
  88. }
  89. // enable the given language
  90. //
  91. // The following files are loaded in this order:
  92. //
  93. // First figure out what OS we are running on:
  94. //
  95. // CMakeSystem.cmake // configured file created by CMakeDetermineSystem.cmake
  96. // CMakeDetermineSystem.cmake // figure out os info and create CMakeSystem.cmake IFF CMAKE_SYSTEM_NAME not set
  97. // CMakeSystem.cmake // configured file created by CMakeDetermineSystem.cmake IFF CMAKE_SYSTEM_LOADED
  98. // TODO: CMakeDetermineSystem.cmake and CMakeSystem.cmake should be in the same if
  99. // Next try and enable all languages found in the languages vector
  100. //
  101. // FOREACH LANG in languages
  102. // CMake(LANG)Compiler.cmake // configured file create by CMakeDetermine(LANG)Compiler.cmake
  103. // CMakeDetermine(LANG)Compiler.cmake // Finds compiler for LANG and creates CMake(LANG)Compiler.cmake
  104. // CMake(LANG)Compiler.cmake // configured file create by CMakeDetermine(LANG)Compiler.cmake
  105. //
  106. // CMakeSystemSpecificInformation.cmake // inludes Platform/${CMAKE_SYSTEM_NAME}.cmake may use compiler stuff
  107. // FOREACH LANG in languages
  108. // CMake(LANG)Information.cmake // loads Platform/${CMAKE_SYSTEM_NAME}-${COMPILER}.cmake
  109. // CMakeTest(LANG)Compiler.cmake // Make sure the compiler works with a try compile if CMakeDetermine(LANG) was loaded
  110. //
  111. // Now load a few files that can override values set in any of the above
  112. // CMake(PROJECTNAME)Compatibility.cmake // load any backwards compatibility stuff for current project
  113. // ${CMAKE_USER_MAKE_RULES_OVERRIDE} // allow users a chance to override system variables
  114. //
  115. //
  116. void
  117. cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
  118. cmMakefile *mf)
  119. {
  120. if(languages.size() == 0)
  121. {
  122. cmSystemTools::Error("EnableLanguage must have a lang specified!");
  123. cmSystemTools::SetFatalErrorOccured();
  124. return;
  125. }
  126. mf->AddDefinition("RUN_CONFIGURE", true);
  127. std::string rootBin = mf->GetHomeOutputDirectory();
  128. rootBin += "/CMakeFiles";
  129. // If the configuration files path has been set,
  130. // then we are in a try compile and need to copy the enable language
  131. // files from the parent cmake bin dir, into the try compile bin dir
  132. if(m_ConfiguredFilesPath.size())
  133. {
  134. std::string src = m_ConfiguredFilesPath;
  135. src += "/CMakeSystem.cmake";
  136. std::string dst = rootBin;
  137. dst += "/CMakeSystem.cmake";
  138. cmSystemTools::CopyFileIfDifferent(src.c_str(), dst.c_str());
  139. for(std::vector<std::string>::const_iterator l = languages.begin();
  140. l != languages.end(); ++l)
  141. {
  142. if(*l == "NONE")
  143. {
  144. this->SetLanguageEnabled("NONE", mf);
  145. continue;
  146. }
  147. const char* lang = l->c_str();
  148. std::string src2 = m_ConfiguredFilesPath;
  149. src2 += "/CMake";
  150. src2 += lang;
  151. src2 += "Compiler.cmake";
  152. std::string dst2 = rootBin;
  153. dst2 += "/CMake";
  154. dst2 += lang;
  155. dst2 += "Compiler.cmake";
  156. cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str());
  157. src2 = m_ConfiguredFilesPath;
  158. src2 += "/CMake";
  159. src2 += lang;
  160. src2 += "Platform.cmake";
  161. dst2 = rootBin;
  162. dst2 += "/CMake";
  163. dst2 += lang;
  164. dst2 += "Platform.cmake";
  165. cmSystemTools::CopyFileIfDifferent(src2.c_str(), dst2.c_str());
  166. }
  167. rootBin = m_ConfiguredFilesPath;
  168. }
  169. // find and make sure CMAKE_MAKE_PROGRAM is defined
  170. this->FindMakeProgram(mf);
  171. // try and load the CMakeSystem.cmake if it is there
  172. std::string fpath = rootBin;
  173. if(!mf->GetDefinition("CMAKE_SYSTEM_LOADED"))
  174. {
  175. fpath += "/CMakeSystem.cmake";
  176. if(cmSystemTools::FileExists(fpath.c_str()))
  177. {
  178. mf->ReadListFile(0,fpath.c_str());
  179. }
  180. }
  181. // Load the CMakeDetermineSystem.cmake file and find out
  182. // what platform we are running on
  183. if (!mf->GetDefinition("CMAKE_SYSTEM_NAME"))
  184. {
  185. #if defined(_WIN32) && !defined(__CYGWIN__)
  186. /* Windows version number data. */
  187. OSVERSIONINFO osvi;
  188. ZeroMemory(&osvi, sizeof(osvi));
  189. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  190. GetVersionEx (&osvi);
  191. cmOStringStream windowsVersionString;
  192. windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion;
  193. windowsVersionString.str();
  194. mf->AddDefinition("CMAKE_SYSTEM_VERSION", windowsVersionString.str().c_str());
  195. #endif
  196. // Read the DetermineSystem file
  197. std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake");
  198. mf->ReadListFile(0, systemFile.c_str());
  199. // load the CMakeSystem.cmake from the binary directory
  200. // this file is configured by the CMakeDetermineSystem.cmake file
  201. fpath = rootBin;
  202. fpath += "/CMakeSystem.cmake";
  203. mf->ReadListFile(0,fpath.c_str());
  204. }
  205. std::map<cmStdString, bool> needTestLanguage;
  206. // foreach language
  207. // load the CMakeDetermine(LANG)Compiler.cmake file to find
  208. // the compiler
  209. for(std::vector<std::string>::const_iterator l = languages.begin();
  210. l != languages.end(); ++l)
  211. {
  212. const char* lang = l->c_str();
  213. if(*l == "NONE")
  214. {
  215. this->SetLanguageEnabled("NONE", mf);
  216. continue;
  217. }
  218. bool determineLanguageCalled = false;
  219. std::string loadedLang = "CMAKE_";
  220. loadedLang += lang;
  221. loadedLang += "_COMPILER_LOADED";
  222. // If the existing build tree was already configured with this
  223. // version of CMake then try to load the configured file first
  224. // to avoid duplicate compiler tests.
  225. unsigned int cacheMajor = mf->GetCacheMajorVersion();
  226. unsigned int cacheMinor = mf->GetCacheMinorVersion();
  227. unsigned int selfMajor = cmMakefile::GetMajorVersion();
  228. unsigned int selfMinor = cmMakefile::GetMinorVersion();
  229. if((m_CMakeInstance->GetIsInTryCompile() ||
  230. (selfMajor == cacheMajor && selfMinor == cacheMinor))
  231. && !mf->GetDefinition(loadedLang.c_str()))
  232. {
  233. fpath = rootBin;
  234. fpath += "/CMake";
  235. fpath += lang;
  236. fpath += "Compiler.cmake";
  237. if(cmSystemTools::FileExists(fpath.c_str()))
  238. {
  239. if(!mf->ReadListFile(0,fpath.c_str()))
  240. {
  241. cmSystemTools::Error("Could not find cmake module file:", fpath.c_str());
  242. }
  243. // if this file was found then the language was already determined to be working
  244. needTestLanguage[lang] = false;
  245. this->SetLanguageEnabled(lang, mf); // this can only be called after loading CMake(LANG)Compiler.cmake
  246. }
  247. }
  248. if(!this->GetLanguageEnabled(lang) )
  249. {
  250. if (m_CMakeInstance->GetIsInTryCompile())
  251. {
  252. cmSystemTools::Error("This should not have happen. "
  253. "If you see this message, you are probably using a "
  254. "broken CMakeLists.txt file or a problematic release of "
  255. "CMake");
  256. }
  257. // if the CMake(LANG)Compiler.cmake file was not found then
  258. // load CMakeDetermine(LANG)Compiler.cmake
  259. std::string determineCompiler = "CMakeDetermine";
  260. determineCompiler += lang;
  261. determineCompiler += "Compiler.cmake";
  262. std::string determineFile =
  263. mf->GetModulesFile(determineCompiler.c_str());
  264. if(!mf->ReadListFile(0,determineFile.c_str()))
  265. {
  266. cmSystemTools::Error("Could not find cmake module file:",
  267. determineFile.c_str());
  268. }
  269. needTestLanguage[lang] = true;
  270. determineLanguageCalled = true;
  271. // Some generators like visual studio should not use the env variables
  272. // So the global generator can specify that in this variable
  273. if(!mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV"))
  274. {
  275. // put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER into the
  276. // environment, in case user scripts want to run configure, or sub cmakes
  277. std::string compilerName = "CMAKE_";
  278. compilerName += lang;
  279. compilerName += "_COMPILER";
  280. std::string compilerEnv = "CMAKE_";
  281. compilerEnv += lang;
  282. compilerEnv += "_COMPILER_ENV_VAR";
  283. std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str());
  284. std::string envVarValue = mf->GetRequiredDefinition(compilerName.c_str());
  285. std::string env = envVar;
  286. env += "=";
  287. env += envVarValue;
  288. cmSystemTools::PutEnv(env.c_str());
  289. }
  290. } // end if(!this->GetLanguageEnabled(lang) )
  291. // if determineLanguage was called then load the file it
  292. // configures CMake(LANG)Compiler.cmake
  293. if(determineLanguageCalled)
  294. {
  295. fpath = rootBin;
  296. fpath += "/CMake";
  297. fpath += lang;
  298. fpath += "Compiler.cmake";
  299. if(!mf->ReadListFile(0,fpath.c_str()))
  300. {
  301. cmSystemTools::Error("Could not find cmake module file:", fpath.c_str());
  302. }
  303. this->SetLanguageEnabled(lang, mf); // this can only be called after loading CMake(LANG)Compiler.cmake
  304. // the language must be enabled for try compile to work, but
  305. // we do not know if it is a working compiler yet so set the test language flag
  306. needTestLanguage[lang] = true;
  307. }
  308. } // end loop over languages
  309. // **** Load the system specific information if not yet loaded
  310. if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
  311. {
  312. fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake");
  313. if(!mf->ReadListFile(0,fpath.c_str()))
  314. {
  315. cmSystemTools::Error("Could not find cmake module file:", fpath.c_str());
  316. }
  317. }
  318. // loop over languages again loading CMake(LANG)Information.cmake
  319. //
  320. for(std::vector<std::string>::const_iterator l = languages.begin();
  321. l != languages.end(); ++l)
  322. {
  323. const char* lang = l->c_str();
  324. if(*l == "NONE")
  325. {
  326. this->SetLanguageEnabled("NONE", mf);
  327. continue;
  328. }
  329. std::string langLoadedVar = "CMAKE_";
  330. langLoadedVar += lang;
  331. langLoadedVar += "_INFORMATION_LOADED";
  332. if (!mf->GetDefinition(langLoadedVar.c_str()))
  333. {
  334. fpath = "CMake";
  335. fpath += lang;
  336. fpath += "Information.cmake";
  337. fpath = mf->GetModulesFile(fpath.c_str());
  338. if(!mf->ReadListFile(0,fpath.c_str()))
  339. {
  340. cmSystemTools::Error("Could not find cmake module file:", fpath.c_str());
  341. }
  342. }
  343. // Test the compiler for the language just setup
  344. // At this point we should have enough info for a try compile
  345. // which is used in the backward stuff
  346. // If the language is untested then test it now with a try compile.
  347. if(needTestLanguage[lang])
  348. {
  349. if (!m_CMakeInstance->GetIsInTryCompile())
  350. {
  351. std::string testLang = "CMakeTest";
  352. testLang += lang;
  353. testLang += "Compiler.cmake";
  354. std::string ifpath = mf->GetModulesFile(testLang.c_str());
  355. if(!mf->ReadListFile(0,ifpath.c_str()))
  356. {
  357. cmSystemTools::Error("Could not find cmake module file:",
  358. ifpath.c_str());
  359. }
  360. std::string compilerWorks = "CMAKE_";
  361. compilerWorks += lang;
  362. compilerWorks += "_COMPILER_WORKS";
  363. // if the compiler did not work, then remove the CMake(LANG)Compiler.cmake file
  364. // so that it will get tested the next time cmake is run
  365. if(!mf->IsOn(compilerWorks.c_str()))
  366. {
  367. fpath = rootBin;
  368. fpath += "/CMake";
  369. fpath += lang;
  370. fpath += "Compiler.cmake";
  371. cmSystemTools::RemoveFile(fpath.c_str());
  372. }
  373. else
  374. {
  375. // load backwards compatibility stuff for C and CXX
  376. // for old versions of CMake ListFiles C and CXX had some
  377. // backwards compatibility files they have to load
  378. // These files have a bunch of try compiles in them so
  379. // should only be done
  380. const char* versionValue
  381. = mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
  382. if (atof(versionValue) <= 1.4)
  383. {
  384. if(strcmp(lang, "C") == 0)
  385. {
  386. ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake");
  387. mf->ReadListFile(0,ifpath.c_str());
  388. }
  389. if(strcmp(lang, "CXX") == 0)
  390. {
  391. ifpath = mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake");
  392. mf->ReadListFile(0,ifpath.c_str());
  393. }
  394. }
  395. }
  396. } // end if in try compile
  397. } // end need test language
  398. } // end for each language
  399. // Now load files that can override any settings on the platform or
  400. // for the project
  401. // First load the project compatibility file if it is in cmake
  402. std::string projectCompatibility = mf->GetDefinition("CMAKE_ROOT");
  403. projectCompatibility += "/Modules/";
  404. projectCompatibility += mf->GetDefinition("PROJECT_NAME");
  405. projectCompatibility += "Compatibility.cmake";
  406. if(cmSystemTools::FileExists(projectCompatibility.c_str()))
  407. {
  408. mf->ReadListFile(0,projectCompatibility.c_str());
  409. }
  410. // next load the file pointed to by CMAKE_USER_MAKE_RULES_OVERRIDE
  411. std::string userMakeRules =
  412. mf->GetSafeDefinition("CMAKE_USER_MAKE_RULES_OVERRIDE");
  413. if(userMakeRules.size())
  414. {
  415. mf->ReadListFile(0,userMakeRules.c_str());
  416. }
  417. }
  418. const char* cmGlobalGenerator::GetLanguageOutputExtensionForLanguage(const char* lang)
  419. {
  420. if(!lang)
  421. {
  422. return "";
  423. }
  424. if(m_LanguageToOutputExtension.count(lang) > 0)
  425. {
  426. return m_LanguageToOutputExtension[lang].c_str();
  427. }
  428. return "";
  429. }
  430. const char* cmGlobalGenerator::GetLanguageOutputExtensionFromExtension(const char* ext)
  431. {
  432. if(!ext)
  433. {
  434. return "";
  435. }
  436. const char* lang = this->GetLanguageFromExtension(ext);
  437. if(!lang || *lang == 0)
  438. {
  439. // if no language is found then check to see if it is already an
  440. // ouput extension for some language. In that case it should be ignored
  441. // and in this map, so it will not be compiled but will just be used.
  442. if(m_OutputExtensions.count(ext))
  443. {
  444. return ext;
  445. }
  446. }
  447. return this->GetLanguageOutputExtensionForLanguage(lang);
  448. }
  449. const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext)
  450. {
  451. // if there is an extension and it starts with . then
  452. // move past the . because the extensions are not stored with a .
  453. // in the map
  454. if(ext && *ext == '.')
  455. {
  456. ++ext;
  457. }
  458. if(m_ExtensionToLanguage.count(ext) > 0)
  459. {
  460. return m_ExtensionToLanguage[ext].c_str();
  461. }
  462. return 0;
  463. }
  464. void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
  465. {
  466. if(m_LanguageEnabled.count(l) > 0)
  467. {
  468. return;
  469. }
  470. std::string outputExtensionVar = std::string("CMAKE_") +
  471. std::string(l) + std::string("_OUTPUT_EXTENSION");
  472. const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str());
  473. if(outputExtension)
  474. {
  475. m_LanguageToOutputExtension[l] = outputExtension;
  476. m_OutputExtensions[outputExtension] = outputExtension;
  477. if(outputExtension[0] == '.')
  478. {
  479. m_OutputExtensions[outputExtension+1] = outputExtension+1;
  480. }
  481. }
  482. std::string linkerPrefVar = std::string("CMAKE_") +
  483. std::string(l) + std::string("_LINKER_PREFERENCE");
  484. const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
  485. if(!linkerPref)
  486. {
  487. linkerPref = "None";
  488. }
  489. m_LanguageToLinkerPreference[l] = linkerPref;
  490. std::string extensionsVar = std::string("CMAKE_") +
  491. std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS");
  492. std::string ignoreExtensionsVar = std::string("CMAKE_") +
  493. std::string(l) + std::string("_IGNORE_EXTENSIONS");
  494. std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str());
  495. std::string exts = mf->GetSafeDefinition(extensionsVar.c_str());
  496. std::vector<std::string> extensionList;
  497. cmSystemTools::ExpandListArgument(exts, extensionList);
  498. for(std::vector<std::string>::iterator i = extensionList.begin();
  499. i != extensionList.end(); ++i)
  500. {
  501. m_ExtensionToLanguage[*i] = l;
  502. }
  503. cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
  504. for(std::vector<std::string>::iterator i = extensionList.begin();
  505. i != extensionList.end(); ++i)
  506. {
  507. m_IgnoreExtensions[*i] = true;
  508. }
  509. m_LanguageEnabled[l] = true;
  510. }
  511. bool cmGlobalGenerator::IgnoreFile(const char* l)
  512. {
  513. if(this->GetLanguageFromExtension(l))
  514. {
  515. return false;
  516. }
  517. return (m_IgnoreExtensions.count(l) > 0);
  518. }
  519. bool cmGlobalGenerator::GetLanguageEnabled(const char* l)
  520. {
  521. return (m_LanguageEnabled.count(l) > 0);
  522. }
  523. void cmGlobalGenerator::ClearEnabledLanguages()
  524. {
  525. m_LanguageEnabled.clear();
  526. }
  527. void cmGlobalGenerator::Configure()
  528. {
  529. // Delete any existing cmLocalGenerators
  530. unsigned int i;
  531. for (i = 0; i < m_LocalGenerators.size(); ++i)
  532. {
  533. delete m_LocalGenerators[i];
  534. }
  535. m_LocalGenerators.clear();
  536. // Setup relative path generation.
  537. this->ConfigureRelativePaths();
  538. // start with this directory
  539. cmLocalGenerator *lg = this->CreateLocalGenerator();
  540. m_LocalGenerators.push_back(lg);
  541. // set the Start directories
  542. lg->GetMakefile()->SetStartDirectory
  543. (m_CMakeInstance->GetStartDirectory());
  544. lg->GetMakefile()->SetStartOutputDirectory
  545. (m_CMakeInstance->GetStartOutputDirectory());
  546. lg->GetMakefile()->MakeStartDirectoriesCurrent();
  547. // now do it
  548. lg->Configure();
  549. // update the cache entry for the number of local generators, this is used
  550. // for progress
  551. char num[100];
  552. sprintf(num,"%d",static_cast<int>(m_LocalGenerators.size()));
  553. this->GetCMakeInstance()->AddCacheEntry
  554. ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num,
  555. "number of local generators", cmCacheManager::INTERNAL);
  556. std::set<cmStdString> notFoundMap;
  557. // after it is all done do a ConfigureFinalPass
  558. cmCacheManager* manager = 0;
  559. for (i = 0; i < m_LocalGenerators.size(); ++i)
  560. {
  561. manager = m_LocalGenerators[i]->GetMakefile()->GetCacheManager();
  562. m_LocalGenerators[i]->ConfigureFinalPass();
  563. cmTargets & targets =
  564. m_LocalGenerators[i]->GetMakefile()->GetTargets();
  565. for (cmTargets::iterator l = targets.begin();
  566. l != targets.end(); l++)
  567. {
  568. cmTarget::LinkLibraries libs = l->second.GetLinkLibraries();
  569. for(cmTarget::LinkLibraries::iterator lib = libs.begin();
  570. lib != libs.end(); ++lib)
  571. {
  572. if(lib->first.size() > 9 &&
  573. cmSystemTools::IsNOTFOUND(lib->first.c_str()))
  574. {
  575. std::string varName = lib->first.substr(0, lib->first.size()-9);
  576. notFoundMap.insert(varName);
  577. }
  578. }
  579. std::vector<std::string>& incs =
  580. m_LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
  581. for( std::vector<std::string>::iterator lib = incs.begin();
  582. lib != incs.end(); ++lib)
  583. {
  584. if(lib->size() > 9 &&
  585. cmSystemTools::IsNOTFOUND(lib->c_str()))
  586. {
  587. std::string varName = lib->substr(0, lib->size()-9);
  588. notFoundMap.insert(varName);
  589. }
  590. }
  591. m_CMakeInstance->UpdateProgress("Configuring",
  592. 0.9f+0.1f*(i+1.0f)/m_LocalGenerators.size());
  593. m_LocalGenerators[i]->GetMakefile()->CheckInfiniteLoops();
  594. }
  595. }
  596. if(notFoundMap.size())
  597. {
  598. std::string notFoundVars;
  599. for(std::set<cmStdString>::iterator ii = notFoundMap.begin();
  600. ii != notFoundMap.end(); ++ii)
  601. {
  602. notFoundVars += *ii;
  603. if(manager)
  604. {
  605. cmCacheManager::CacheIterator it =
  606. manager->GetCacheIterator(ii->c_str());
  607. if(it.GetPropertyAsBool("ADVANCED"))
  608. {
  609. notFoundVars += " (ADVANCED)";
  610. }
  611. }
  612. notFoundVars += "\n";
  613. }
  614. cmSystemTools::Error("This project requires some variables to be set,\n"
  615. "and cmake can not find them.\n"
  616. "Please set the following variables:\n",
  617. notFoundVars.c_str());
  618. }
  619. // at this point m_LocalGenerators has been filled,
  620. // so create the map from project name to vector of local generators
  621. this->FillProjectMap();
  622. if ( !m_CMakeInstance->GetScriptMode() )
  623. {
  624. m_CMakeInstance->UpdateProgress("Configuring done", -1);
  625. }
  626. }
  627. void cmGlobalGenerator::Generate()
  628. {
  629. // For each existing cmLocalGenerator
  630. unsigned int i;
  631. for (i = 0; i < m_LocalGenerators.size(); ++i)
  632. {
  633. m_LocalGenerators[i]->Generate();
  634. m_LocalGenerators[i]->GenerateInstallRules();
  635. m_LocalGenerators[i]->GenerateTestFiles();
  636. m_CMakeInstance->UpdateProgress("Generating",
  637. (i+1.0f)/m_LocalGenerators.size());
  638. }
  639. m_CMakeInstance->UpdateProgress("Generating done", -1);
  640. }
  641. int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
  642. const char *projectName,
  643. const char *target,
  644. std::string *output, cmMakefile *mf)
  645. {
  646. std::string makeCommand =
  647. m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
  648. if(makeCommand.size() == 0)
  649. {
  650. cmSystemTools::Error(
  651. "Generator cannot find the appropriate make command.");
  652. return 1;
  653. }
  654. std::string newTarget;
  655. if (target && strlen(target))
  656. {
  657. newTarget += target;
  658. #if 0
  659. #if defined(_WIN32) || defined(__CYGWIN__)
  660. std::string tmp = target;
  661. // if the target does not already end in . something
  662. // then assume .exe
  663. if(tmp.size() < 4 || tmp[tmp.size()-4] != '.')
  664. {
  665. newTarget += ".exe";
  666. }
  667. #endif // WIN32
  668. #endif
  669. }
  670. const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
  671. return this->Build(srcdir,bindir,projectName,
  672. newTarget.c_str(),
  673. output,makeCommand.c_str(),config,false);
  674. }
  675. std::string cmGlobalGenerator::GenerateBuildCommand(const char* makeProgram,
  676. const char *projectName, const char* additionalOptions, const char *targetName,
  677. const char* config, bool ignoreErrors)
  678. {
  679. // Project name and config are not used yet.
  680. (void)projectName;
  681. (void)config;
  682. std::string makeCommand = cmSystemTools::ConvertToUnixOutputPath(makeProgram);
  683. // Since we have full control over the invocation of nmake, let us
  684. // make it quiet.
  685. if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
  686. {
  687. makeCommand += " /NOLOGO ";
  688. }
  689. if ( ignoreErrors )
  690. {
  691. makeCommand += " -i";
  692. }
  693. if ( additionalOptions )
  694. {
  695. makeCommand += " ";
  696. makeCommand += additionalOptions;
  697. }
  698. if ( targetName )
  699. {
  700. makeCommand += " ";
  701. makeCommand += targetName;
  702. }
  703. return makeCommand;
  704. }
  705. int cmGlobalGenerator::Build(
  706. const char *, const char *bindir,
  707. const char *projectName, const char *target,
  708. std::string *output,
  709. const char *makeCommandCSTR,
  710. const char *config,
  711. bool clean)
  712. {
  713. *output += "\nTesting TryCompileWithoutMakefile\n";
  714. /**
  715. * Run an executable command and put the stdout in output.
  716. */
  717. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  718. cmSystemTools::ChangeDirectory(bindir);
  719. int retVal;
  720. int timeout = cmGlobalGenerator::s_TryCompileTimeout;
  721. bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
  722. cmSystemTools::SetRunCommandHideConsole(true);
  723. // should we do a clean first?
  724. if (clean)
  725. {
  726. std::string cleanCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName,
  727. 0, "clean", config, false);
  728. if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), output,
  729. &retVal, 0, false, timeout))
  730. {
  731. cmSystemTools::SetRunCommandHideConsole(hideconsole);
  732. cmSystemTools::Error("Generator: execution of make clean failed.");
  733. if (output)
  734. {
  735. *output += "\nGenerator: execution of make clean failed.\n";
  736. }
  737. // return to the original directory
  738. cmSystemTools::ChangeDirectory(cwd.c_str());
  739. return 1;
  740. }
  741. }
  742. // now build
  743. std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName,
  744. 0, target, config, false);
  745. if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output,
  746. &retVal, 0, false, timeout))
  747. {
  748. cmSystemTools::SetRunCommandHideConsole(hideconsole);
  749. cmSystemTools::Error("Generator: execution of make failed. Make command was: ",
  750. makeCommand.c_str());
  751. if (output)
  752. {
  753. *output += "\nGenerator: execution of make failed. Make command was: " +
  754. makeCommand + "\n";
  755. }
  756. // return to the original directory
  757. cmSystemTools::ChangeDirectory(cwd.c_str());
  758. return 1;
  759. }
  760. cmSystemTools::SetRunCommandHideConsole(hideconsole);
  761. // The SGI MipsPro 7.3 compiler does not return an error code when
  762. // the source has a #error in it! This is a work-around for such
  763. // compilers.
  764. if((retVal == 0) && (output->find("#error") != std::string::npos))
  765. {
  766. retVal = 1;
  767. }
  768. cmSystemTools::ChangeDirectory(cwd.c_str());
  769. return retVal;
  770. }
  771. void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
  772. {
  773. m_LocalGenerators.push_back(lg);
  774. // update progress
  775. // estimate how many lg there will be
  776. const char *numGenC =
  777. m_CMakeInstance->GetCacheManager()->GetCacheValue
  778. ("CMAKE_NUMBER_OF_LOCAL_GENERATORS");
  779. if (!numGenC)
  780. {
  781. return;
  782. }
  783. int numGen = atoi(numGenC);
  784. float prog = 0.9f*m_LocalGenerators.size()/numGen;
  785. if (prog > 0.9f)
  786. {
  787. prog = 0.9f;
  788. }
  789. m_CMakeInstance->UpdateProgress("Configuring", prog);
  790. }
  791. cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
  792. {
  793. cmLocalGenerator *lg = new cmLocalGenerator;
  794. lg->SetGlobalGenerator(this);
  795. return lg;
  796. }
  797. void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
  798. {
  799. std::string cfp = gen->GetCMakeInstance()->GetHomeOutputDirectory();
  800. cfp += "/CMakeFiles";
  801. this->SetConfiguredFilesPath(cfp.c_str());
  802. const char* make =
  803. gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
  804. this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
  805. "make program",
  806. cmCacheManager::FILEPATH);
  807. // copy the enabled languages
  808. this->m_LanguageEnabled = gen->m_LanguageEnabled;
  809. this->m_ExtensionToLanguage = gen->m_ExtensionToLanguage;
  810. this->m_IgnoreExtensions = gen->m_IgnoreExtensions;
  811. this->m_LanguageToOutputExtension = gen->m_LanguageToOutputExtension;
  812. this->m_LanguageToLinkerPreference = gen->m_LanguageToLinkerPreference;
  813. this->m_OutputExtensions = gen->m_OutputExtensions;
  814. }
  815. //----------------------------------------------------------------------------
  816. void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const
  817. {
  818. entry.name = this->GetName();
  819. entry.brief = "";
  820. entry.full = "";
  821. }
  822. bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
  823. cmLocalGenerator* gen)
  824. {
  825. cmLocalGenerator* cur = gen->GetParent();
  826. while(cur && cur != root)
  827. {
  828. if(cur->GetExcludeAll())
  829. {
  830. return true;
  831. }
  832. cur = cur->GetParent();
  833. }
  834. return false;
  835. }
  836. void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang)
  837. {
  838. for(std::map<cmStdString, bool>::iterator i = m_LanguageEnabled.begin();
  839. i != m_LanguageEnabled.end(); ++i)
  840. {
  841. lang.push_back(i->first);
  842. }
  843. }
  844. const char* cmGlobalGenerator::GetLinkerPreference(const char* lang)
  845. {
  846. if(m_LanguageToLinkerPreference.count(lang))
  847. {
  848. return m_LanguageToLinkerPreference[lang].c_str();
  849. }
  850. return "None";
  851. }
  852. void cmGlobalGenerator::FillProjectMap()
  853. {
  854. m_ProjectMap.clear(); // make sure we start with a clean map
  855. unsigned int i;
  856. for(i = 0; i < m_LocalGenerators.size(); ++i)
  857. {
  858. // for each local generator add all projects
  859. cmLocalGenerator *lg = m_LocalGenerators[i];
  860. std::string name;
  861. do
  862. {
  863. if (name != lg->GetMakefile()->GetProjectName())
  864. {
  865. name = lg->GetMakefile()->GetProjectName();
  866. m_ProjectMap[name].push_back(m_LocalGenerators[i]);
  867. }
  868. lg = lg->GetParent();
  869. }
  870. while (lg);
  871. }
  872. }
  873. ///! Find a local generator by its startdirectory
  874. cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir)
  875. {
  876. std::vector<cmLocalGenerator*>* gens = &m_LocalGenerators;
  877. for(unsigned int i = 0; i < gens->size(); ++i)
  878. {
  879. std::string sd = (*gens)[i]->GetMakefile()->GetStartDirectory();
  880. if (sd == start_dir)
  881. {
  882. return (*gens)[i];
  883. }
  884. }
  885. return 0;
  886. }
  887. cmTarget* cmGlobalGenerator::FindTarget(const char* project,
  888. const char* name)
  889. {
  890. std::vector<cmLocalGenerator*>* gens = &m_LocalGenerators;
  891. if(project)
  892. {
  893. gens = &m_ProjectMap[project];
  894. }
  895. for(unsigned int i = 0; i < gens->size(); ++i)
  896. {
  897. cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name);
  898. if(ret)
  899. {
  900. return ret;
  901. }
  902. }
  903. return 0;
  904. }
  905. //----------------------------------------------------------------------------
  906. void cmGlobalGenerator::ConfigureRelativePaths()
  907. {
  908. // The current working directory on Windows cannot be a network
  909. // path. Therefore relative paths cannot work when the build tree
  910. // is a network path.
  911. std::string source = m_CMakeInstance->GetHomeDirectory();
  912. std::string binary = m_CMakeInstance->GetHomeOutputDirectory();
  913. if(binary.size() < 2 || binary.substr(0, 2) != "//")
  914. {
  915. m_RelativePathTopSource = source;
  916. m_RelativePathTopBinary = binary;
  917. }
  918. else
  919. {
  920. m_RelativePathTopSource = "";
  921. m_RelativePathTopBinary = "";
  922. }
  923. }
  924. //----------------------------------------------------------------------------
  925. std::string
  926. cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
  927. const char* in_remote)
  928. {
  929. // The path should never be quoted.
  930. assert(in_remote[0] != '\"');
  931. // The local path should never have a trailing slash.
  932. assert(local.size() > 0 && !(local[local.size()-1] == ""));
  933. // If the path is already relative then just return the path.
  934. if(!cmSystemTools::FileIsFullPath(in_remote))
  935. {
  936. return in_remote;
  937. }
  938. // Skip conversion if the path is not in the source or binary tree.
  939. std::string original = in_remote;
  940. if((original.size() < m_RelativePathTopSource.size() ||
  941. !cmSystemTools::ComparePath(
  942. original.substr(0, m_RelativePathTopSource.size()).c_str(),
  943. m_RelativePathTopSource.c_str())) &&
  944. (original.size() < m_RelativePathTopBinary.size() ||
  945. !cmSystemTools::ComparePath(
  946. original.substr(0, m_RelativePathTopBinary.size()).c_str(),
  947. m_RelativePathTopBinary.c_str())))
  948. {
  949. return in_remote;
  950. }
  951. // Identify the longest shared path component between the remote
  952. // path and the local path.
  953. std::vector<std::string> remote;
  954. cmSystemTools::SplitPath(in_remote, remote);
  955. unsigned int common=0;
  956. while(common < remote.size() &&
  957. common < local.size() &&
  958. cmSystemTools::ComparePath(remote[common].c_str(),
  959. local[common].c_str()))
  960. {
  961. ++common;
  962. }
  963. // If no part of the path is in common then return the full path.
  964. if(common == 0)
  965. {
  966. return in_remote;
  967. }
  968. // If the entire path is in common then just return a ".".
  969. if(common == remote.size() &&
  970. common == local.size())
  971. {
  972. return ".";
  973. }
  974. // If the entire path is in common except for a trailing slash then
  975. // just return a "./".
  976. if(common+1 == remote.size() &&
  977. remote[common].size() == 0 &&
  978. common == local.size())
  979. {
  980. return "./";
  981. }
  982. // Construct the relative path.
  983. std::string relative;
  984. // First add enough ../ to get up to the level of the shared portion
  985. // of the path. Leave off the trailing slash. Note that the last
  986. // component of local will never be empty because local should never
  987. // have a trailing slash.
  988. for(unsigned int i=common; i < local.size(); ++i)
  989. {
  990. relative += "..";
  991. if(i < local.size()-1)
  992. {
  993. relative += "/";
  994. }
  995. }
  996. // Now add the portion of the destination path that is not included
  997. // in the shared portion of the path. Add a slash the first time
  998. // only if there was already something in the path. If there was a
  999. // trailing slash in the input then the last iteration of the loop
  1000. // will add a slash followed by an empty string which will preserve
  1001. // the trailing slash in the output.
  1002. for(unsigned int i=common; i < remote.size(); ++i)
  1003. {
  1004. if(relative.size() > 0)
  1005. {
  1006. relative += "/";
  1007. }
  1008. relative += remote[i];
  1009. }
  1010. // Finally return the path.
  1011. return relative;
  1012. }
  1013. inline std::string removeQuotes(const std::string& s)
  1014. {
  1015. if(s[0] == '\"' && s[s.size()-1] == '\"')
  1016. {
  1017. return s.substr(1, s.size()-2);
  1018. }
  1019. return s;
  1020. }
  1021. void cmGlobalGenerator::SetupTests()
  1022. {
  1023. std::string ctest =
  1024. m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
  1025. ctest = removeQuotes(ctest);
  1026. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  1027. ctest += "/";
  1028. ctest += "ctest";
  1029. ctest += cmSystemTools::GetExecutableExtension();
  1030. if(!cmSystemTools::FileExists(ctest.c_str()))
  1031. {
  1032. ctest =
  1033. m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
  1034. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  1035. ctest += "/Debug/";
  1036. ctest += "ctest";
  1037. ctest += cmSystemTools::GetExecutableExtension();
  1038. }
  1039. if(!cmSystemTools::FileExists(ctest.c_str()))
  1040. {
  1041. ctest =
  1042. m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
  1043. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  1044. ctest += "/Release/";
  1045. ctest += "ctest";
  1046. ctest += cmSystemTools::GetExecutableExtension();
  1047. }
  1048. // if we found ctest
  1049. if (cmSystemTools::FileExists(ctest.c_str()))
  1050. {
  1051. // Create a full path filename for output Testfile
  1052. std::string fname;
  1053. fname = m_CMakeInstance->GetStartOutputDirectory();
  1054. fname += "/";
  1055. if ( m_LocalGenerators[0]->GetMakefile()->IsSet("CTEST_NEW_FORMAT") )
  1056. {
  1057. fname += "CTestTestfile.txt";
  1058. }
  1059. else
  1060. {
  1061. fname += "DartTestfile.txt";
  1062. }
  1063. // Add run_test only if any tests are foun
  1064. long total_tests = 0;
  1065. unsigned int i;
  1066. for (i = 0; i < m_LocalGenerators.size(); ++i)
  1067. {
  1068. total_tests += m_LocalGenerators[i]->GetMakefile()->GetTests()->size();
  1069. }
  1070. // If the file doesn't exist, then ENABLE_TESTING hasn't been run
  1071. if (total_tests > 0)
  1072. {
  1073. const char* no_output = 0;
  1074. const char* no_working_dir = 0;
  1075. std::vector<std::string> no_depends;
  1076. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  1077. for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
  1078. {
  1079. std::vector<cmLocalGenerator*>& gen = it->second;
  1080. // add the RUN_TESTS to the first local generator of each project
  1081. if(gen.size())
  1082. {
  1083. cmMakefile* mf = gen[0]->GetMakefile();
  1084. if(const char* outDir = mf->GetDefinition("CMAKE_CFG_INTDIR"))
  1085. {
  1086. mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
  1087. no_working_dir,
  1088. ctest.c_str(), "-C", outDir);
  1089. }
  1090. }
  1091. }
  1092. }
  1093. }
  1094. }
  1095. //----------------------------------------------------------------------------
  1096. void cmGlobalGenerator::AppendDirectoryForConfig(const char*, std::string&)
  1097. {
  1098. // Subclasses that support multiple configurations should implement
  1099. // this method to append the subdirectory for the given build
  1100. // configuration.
  1101. }