The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1175 lines
54KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "jucer_ProjectExport_CodeBlocks.h"
  21. #include "jucer_ProjectExport_Make.h"
  22. #include "jucer_ProjectExport_Xcode.h"
  23. //==============================================================================
  24. class CLionProjectExporter : public ProjectExporter
  25. {
  26. protected:
  27. //==============================================================================
  28. class CLionBuildConfiguration : public BuildConfiguration
  29. {
  30. public:
  31. CLionBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  32. : BuildConfiguration (p, settings, e)
  33. {
  34. }
  35. void createConfigProperties (PropertyListBuilder&) override {}
  36. String getModuleLibraryArchName() const override { return {}; }
  37. };
  38. BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override
  39. {
  40. return *new CLionBuildConfiguration (project, tree, *this);
  41. }
  42. public:
  43. //==============================================================================
  44. static const char* getName() { return "CLion (beta)"; }
  45. static const char* getValueTreeTypeName() { return "CLION"; }
  46. static CLionProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  47. {
  48. if (settings.hasType (getValueTreeTypeName()))
  49. return new CLionProjectExporter (project, settings);
  50. return nullptr;
  51. }
  52. static bool isExporterSupported (const ProjectExporter& exporter)
  53. {
  54. return exporter.isMakefile()
  55. || (exporter.isXcode() && ! exporter.isiOS())
  56. || (exporter.isCodeBlocks() && exporter.isWindows());
  57. }
  58. //==============================================================================
  59. CLionProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t)
  60. {
  61. name = getName();
  62. targetLocationValue.setDefault (getDefaultBuildsRootFolder() + getTargetFolderForExporter (getValueTreeTypeName()));
  63. }
  64. //==============================================================================
  65. bool usesMMFiles() const override { return false; }
  66. bool canCopeWithDuplicateFiles() override { return false; }
  67. bool supportsUserDefinedConfigurations() const override { return false; }
  68. bool isXcode() const override { return false; }
  69. bool isVisualStudio() const override { return false; }
  70. bool isCodeBlocks() const override { return false; }
  71. bool isMakefile() const override { return false; }
  72. bool isAndroidStudio() const override { return false; }
  73. bool isCLion() const override { return true; }
  74. bool isAndroid() const override { return false; }
  75. bool isWindows() const override { return false; }
  76. bool isLinux() const override { return false; }
  77. bool isOSX() const override { return false; }
  78. bool isiOS() const override { return false; }
  79. bool supportsTargetType (ProjectType::Target::Type) const override { return true; }
  80. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override {}
  81. //==============================================================================
  82. bool canLaunchProject() override
  83. {
  84. #if JUCE_MAC
  85. static Identifier exporterName ("XCODE_MAC");
  86. #elif JUCE_WINDOWS
  87. static Identifier exporterName ("CODEBLOCKS_WINDOWS");
  88. #elif JUCE_LINUX
  89. static Identifier exporterName ("LINUX_MAKE");
  90. #else
  91. static Identifier exporterName;
  92. #endif
  93. if (getProject().getExporters().getChildWithName (exporterName).isValid())
  94. return getCLionExecutableOrApp().exists();
  95. return false;
  96. }
  97. bool launchProject() override
  98. {
  99. return getCLionExecutableOrApp().startAsProcess (getTargetFolder().getFullPathName().quoted());
  100. }
  101. String getDescription() override
  102. {
  103. String description;
  104. description << "The " << getName() << " exporter produces a single CMakeLists.txt file with "
  105. << "multiple platform dependent sections, where the configuration for each section "
  106. << "is inherited from other exporters added to this project." << newLine
  107. << newLine
  108. << "The exporters which provide the CLion configuration for the corresponding platform are:" << newLine
  109. << newLine;
  110. for (auto& exporterName : getExporterNames())
  111. {
  112. std::unique_ptr<ProjectExporter> exporter (createNewExporter (getProject(), exporterName));
  113. if (isExporterSupported (*exporter))
  114. description << exporter->getName() << newLine;
  115. }
  116. description << newLine
  117. << "Add these exporters to the project to enable CLion builds." << newLine
  118. << newLine
  119. << "Not all features of all the exporters are currently supported. Notable omissions are AUv3 "
  120. << "plug-ins, embedding resources and fat binaries on MacOS. On Windows the CLion exporter "
  121. << "requires a GCC-based compiler like MinGW.";
  122. return description;
  123. }
  124. void createExporterProperties (PropertyListBuilder& properties) override
  125. {
  126. for (Project::ExporterIterator exporter (getProject()); exporter.next();)
  127. if (isExporterSupported (*exporter))
  128. properties.add (new BooleanPropertyComponent (getExporterEnabledValue (*exporter), "Import settings from exporter", exporter->getName()),
  129. "If this is enabled then settings from the corresponding exporter will "
  130. "be used in the generated CMakeLists.txt");
  131. }
  132. void createDefaultConfigs() override {}
  133. void create (const OwnedArray<LibraryModule>&) const override
  134. {
  135. MemoryOutputStream out;
  136. out.setNewLineString ("\n");
  137. out << "# Automatically generated CMakeLists, created by the Projucer" << newLine
  138. << "# Do not edit this file! Your changes will be overwritten when you re-save the Projucer project!" << newLine
  139. << newLine;
  140. out << "cmake_minimum_required (VERSION 3.4.1)" << newLine
  141. << newLine;
  142. out << "if (NOT CMAKE_BUILD_TYPE)" << newLine
  143. << " set (CMAKE_BUILD_TYPE \"Debug\" CACHE STRING \"Choose the type of build.\" FORCE)" << newLine
  144. << "endif (NOT CMAKE_BUILD_TYPE)" << newLine
  145. << newLine;
  146. // We'll append to this later.
  147. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("CMakeLists.txt"), out);
  148. // CMake has stopped adding PkgInfo files to bundles, so we need to do it manually
  149. MemoryOutputStream pkgInfoOut;
  150. pkgInfoOut << "BNDL????";
  151. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("PkgInfo"), out);
  152. }
  153. void writeCMakeListsExporterSection (ProjectExporter* exporter) const
  154. {
  155. if (! (isExporterSupported (*exporter) && isExporterEnabled (*exporter)))
  156. return;
  157. MemoryBlock existingContent;
  158. getTargetFolder().getChildFile ("CMakeLists.txt").loadFileAsData (existingContent);
  159. MemoryOutputStream out (existingContent, true);
  160. out.setNewLineString ("\n");
  161. out << "###############################################################################" << newLine
  162. << "# " << exporter->getName() << newLine
  163. << "###############################################################################" << newLine
  164. << newLine;
  165. if (auto* makefileExporter = dynamic_cast<MakefileProjectExporter*> (exporter))
  166. {
  167. out << "if (UNIX AND NOT APPLE)" << newLine << newLine;
  168. writeCMakeListsMakefileSection (out, *makefileExporter);
  169. }
  170. else if (auto* xcodeExporter = dynamic_cast<XcodeProjectExporter*> (exporter))
  171. {
  172. out << "if (APPLE)" << newLine << newLine;
  173. writeCMakeListsXcodeSection (out, *xcodeExporter);
  174. }
  175. else if (auto* codeBlocksExporter = dynamic_cast<CodeBlocksProjectExporter*> (exporter))
  176. {
  177. out << "if (WIN32)" << newLine << newLine;
  178. writeCMakeListsCodeBlocksSection (out, *codeBlocksExporter);
  179. }
  180. out << "endif()" << newLine << newLine;
  181. overwriteFileIfDifferentOrThrow (getTargetFolder().getChildFile ("CMakeLists.txt"), out);
  182. }
  183. private:
  184. //==============================================================================
  185. static File getCLionExecutableOrApp()
  186. {
  187. File clionExeOrApp (getAppSettings()
  188. .getStoredPath (Ids::clionExePath, TargetOS::getThisOS()).get()
  189. .toString()
  190. .replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()));
  191. #if JUCE_MAC
  192. if (clionExeOrApp.getFullPathName().endsWith ("/Contents/MacOS/clion"))
  193. clionExeOrApp = clionExeOrApp.getParentDirectory()
  194. .getParentDirectory()
  195. .getParentDirectory();
  196. #endif
  197. return clionExeOrApp;
  198. }
  199. //==============================================================================
  200. Identifier getExporterEnabledId (const ProjectExporter& exporter) const
  201. {
  202. jassert (isExporterSupported (exporter));
  203. if (exporter.isMakefile()) return Ids::clionMakefileEnabled;
  204. else if (exporter.isXcode()) return Ids::clionXcodeEnabled;
  205. else if (exporter.isCodeBlocks()) return Ids::clionCodeBlocksEnabled;
  206. jassertfalse;
  207. return {};
  208. }
  209. bool isExporterEnabled (const ProjectExporter& exporter) const
  210. {
  211. auto setting = settings[getExporterEnabledId (exporter)];
  212. return setting.isVoid() || setting;
  213. }
  214. Value getExporterEnabledValue (const ProjectExporter& exporter)
  215. {
  216. auto enabledID = getExporterEnabledId (exporter);
  217. getSetting (enabledID) = isExporterEnabled (exporter);
  218. return getSetting (enabledID);
  219. }
  220. //==============================================================================
  221. static bool isWindowsAbsolutePath (const String& path)
  222. {
  223. return path.length() > 1 && path[1] == ':';
  224. }
  225. static bool isUnixAbsolutePath (const String& path)
  226. {
  227. return path.isNotEmpty() && (path[0] == '/' || path[0] == '~' || path.startsWith ("$ENV{HOME}"));
  228. }
  229. //==============================================================================
  230. static String setCMakeVariable (const String& variableName, const String& value)
  231. {
  232. return "set (" + variableName + " \"" + value + "\")";
  233. }
  234. static String addToCMakeVariable (const String& variableName, const String& value)
  235. {
  236. return setCMakeVariable (variableName, "${" + variableName + "} " + value);
  237. }
  238. static String getTargetVarName (ProjectType::Target& target)
  239. {
  240. return String (target.getName()).toUpperCase().replaceCharacter (L' ', L'_');
  241. }
  242. template <class Target, class Exporter>
  243. void getFileInfoList (Target& target, Exporter& exporter, const Project::Item& projectItem, std::vector<std::tuple<String, bool, String>>& fileInfoList) const
  244. {
  245. auto targetType = (getProject().getProjectType().isAudioPlugin() ? target.type : Target::Type::SharedCodeTarget);
  246. if (projectItem.isGroup())
  247. {
  248. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  249. getFileInfoList (target, exporter, projectItem.getChild(i), fileInfoList);
  250. }
  251. else if (projectItem.shouldBeAddedToTargetProject() && getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType )
  252. {
  253. auto path = RelativePath (projectItem.getFile(), exporter.getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle();
  254. fileInfoList.push_back (std::make_tuple (path, projectItem.shouldBeCompiled(),
  255. exporter.compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString()));
  256. }
  257. }
  258. template <class Exporter>
  259. void writeCMakeTargets (OutputStream& out, Exporter& exporter) const
  260. {
  261. for (auto* target : exporter.targets)
  262. {
  263. if (target->type == ProjectType::Target::Type::AggregateTarget
  264. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  265. continue;
  266. String functionName;
  267. StringArray properties;
  268. switch (target->getTargetFileType())
  269. {
  270. case ProjectType::Target::TargetFileType::executable:
  271. functionName = "add_executable";
  272. if (exporter.isCodeBlocks() && exporter.isWindows()
  273. && target->type != ProjectType::Target::Type::ConsoleApp)
  274. properties.add ("WIN32");
  275. break;
  276. case ProjectType::Target::TargetFileType::staticLibrary:
  277. case ProjectType::Target::TargetFileType::sharedLibraryOrDLL:
  278. case ProjectType::Target::TargetFileType::pluginBundle:
  279. functionName = "add_library";
  280. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::staticLibrary)
  281. properties.add ("STATIC");
  282. else if (target->getTargetFileType() == ProjectType::Target::TargetFileType::sharedLibraryOrDLL)
  283. properties.add ("SHARED");
  284. else
  285. properties.add ("MODULE");
  286. break;
  287. default:
  288. continue;
  289. }
  290. out << functionName << " (" << getTargetVarName (*target);
  291. if (! properties.isEmpty())
  292. out << " " << properties.joinIntoString (" ");
  293. out << newLine;
  294. std::vector<std::tuple<String, bool, String>> fileInfoList;
  295. for (auto& group : exporter.getAllGroups())
  296. getFileInfoList (*target, exporter, group, fileInfoList);
  297. for (auto& fileInfo : fileInfoList)
  298. out << " " << std::get<0> (fileInfo).quoted() << newLine;
  299. auto isCMakeBundle = exporter.isXcode() && target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle;
  300. auto pkgInfoPath = String ("PkgInfo").quoted();
  301. if (isCMakeBundle)
  302. out << " " << pkgInfoPath << newLine;
  303. auto xcodeIcnsFilePath = [&] () -> String
  304. {
  305. if (exporter.isXcode() && target->getTargetFileType() == ProjectType::Target::TargetFileType::executable)
  306. {
  307. auto xcodeIcnsFile = getTargetFolder().getParentDirectory()
  308. .getChildFile ("MacOSX")
  309. .getChildFile ("Icon.icns");
  310. if (xcodeIcnsFile.existsAsFile())
  311. return xcodeIcnsFile.getRelativePathFrom (getTargetFolder()).quoted();
  312. }
  313. return {};
  314. }();
  315. if (xcodeIcnsFilePath.isNotEmpty())
  316. out << " " << xcodeIcnsFilePath << newLine;
  317. if (exporter.isCodeBlocks() && target->getTargetFileType() == ProjectType::Target::TargetFileType::executable)
  318. {
  319. auto windowsRcFile = getTargetFolder().getParentDirectory()
  320. .getChildFile ("CodeBlocksWindows")
  321. .getChildFile ("resources.rc");
  322. if (windowsRcFile.existsAsFile())
  323. out << " " << windowsRcFile.getRelativePathFrom (getTargetFolder()).quoted() << newLine;
  324. }
  325. out << ")" << newLine << newLine;
  326. if (isCMakeBundle)
  327. out << "set_source_files_properties (" << pkgInfoPath << " PROPERTIES MACOSX_PACKAGE_LOCATION .)" << newLine;
  328. if (xcodeIcnsFilePath.isNotEmpty())
  329. out << "set_source_files_properties (" << xcodeIcnsFilePath << " PROPERTIES MACOSX_PACKAGE_LOCATION \"Resources\")" << newLine;
  330. for (auto& fileInfo : fileInfoList)
  331. {
  332. if (std::get<1> (fileInfo))
  333. {
  334. auto extraCompilerFlags = std::get<2> (fileInfo);
  335. if (extraCompilerFlags.isNotEmpty())
  336. out << "set_source_files_properties(" << std::get<0> (fileInfo).quoted() << " PROPERTIES COMPILE_FLAGS " << extraCompilerFlags << " )" << newLine;
  337. }
  338. else
  339. {
  340. out << "set_source_files_properties (" << std::get<0> (fileInfo).quoted() << " PROPERTIES HEADER_FILE_ONLY TRUE)" << newLine;
  341. }
  342. }
  343. out << newLine;
  344. }
  345. }
  346. //==============================================================================
  347. void writeCMakeListsMakefileSection (OutputStream& out, MakefileProjectExporter& exporter) const
  348. {
  349. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine
  350. << newLine;
  351. out << "find_package (PkgConfig REQUIRED)" << newLine;
  352. StringArray cmakePkgconfigPackages;
  353. for (auto& package : exporter.getPackages())
  354. {
  355. cmakePkgconfigPackages.add (package.toUpperCase());
  356. out << "pkg_search_module (" << cmakePkgconfigPackages.strings.getLast() << " REQUIRED " << package << ")" << newLine;
  357. }
  358. out << newLine;
  359. writeCMakeTargets (out, exporter);
  360. for (auto* target : exporter.targets)
  361. {
  362. if (target->type == ProjectType::Target::Type::AggregateTarget)
  363. continue;
  364. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle)
  365. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES PREFIX \"\")" << newLine;
  366. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX \"" << target->getTargetFileSuffix() << "\")" << newLine
  367. << newLine;
  368. }
  369. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  370. {
  371. auto& config = dynamic_cast<const MakefileProjectExporter::MakeBuildConfiguration&> (*c);
  372. out << "#------------------------------------------------------------------------------" << newLine
  373. << "# Config: " << config.getName() << newLine
  374. << "#------------------------------------------------------------------------------" << newLine
  375. << newLine;
  376. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  377. out << "if (" << buildTypeCondition << ")" << newLine
  378. << newLine;
  379. out << "execute_process (COMMAND uname -m OUTPUT_VARIABLE JUCE_ARCH_LABEL OUTPUT_STRIP_TRAILING_WHITESPACE)" << newLine
  380. << newLine;
  381. out << "include_directories (" << newLine;
  382. for (auto& path : exporter.getHeaderSearchPaths (config))
  383. out << " " << path.quoted() << newLine;
  384. for (auto& package : cmakePkgconfigPackages)
  385. out << " ${" << package << "_INCLUDE_DIRS}" << newLine;
  386. out << ")" << newLine << newLine;
  387. StringArray cmakeFoundLibraries;
  388. for (auto& library : exporter.getLibraryNames (config))
  389. {
  390. String cmakeLibraryID (library.toUpperCase());
  391. cmakeFoundLibraries.add (String ("${") + cmakeLibraryID + "}");
  392. out << "find_library (" << cmakeLibraryID << " " << library << newLine;
  393. for (auto& path : exporter.getLibrarySearchPaths (config))
  394. out << " " << path.quoted() << newLine;
  395. out << ")" << newLine
  396. << newLine;
  397. }
  398. for (auto* target : exporter.targets)
  399. {
  400. if (target->type == ProjectType::Target::Type::AggregateTarget)
  401. continue;
  402. auto targetVarName = getTargetVarName (*target);
  403. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  404. << " OUTPUT_NAME " << config.getTargetBinaryNameString().quoted() << newLine;
  405. auto cxxStandard = project.getCppStandardString();
  406. if (cxxStandard == "latest")
  407. cxxStandard = "17";
  408. out << " CXX_STANDARD " << cxxStandard << newLine;
  409. if (! shouldUseGNUExtensions())
  410. out << " CXX_EXTENSIONS OFF" << newLine;
  411. out << ")" << newLine << newLine;
  412. auto defines = exporter.getDefines (config);
  413. defines.addArray (target->getDefines (config));
  414. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  415. for (auto& key : defines.getAllKeys())
  416. out << " " << key << "=" << defines[key] << newLine;
  417. out << ")" << newLine << newLine;
  418. auto targetFlags = target->getCompilerFlags();
  419. if (! targetFlags.isEmpty())
  420. {
  421. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  422. for (auto& flag : targetFlags)
  423. out << " " << flag << newLine;
  424. out << ")" << newLine << newLine;
  425. }
  426. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  427. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  428. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  429. out << " SHARED_CODE" << newLine;
  430. out << " " << exporter.getArchFlags (config) << newLine;
  431. for (auto& flag : target->getLinkerFlags())
  432. out << " " << flag << newLine;
  433. for (auto& flag : exporter.getLinkerFlags (config))
  434. out << " " << flag << newLine;
  435. for (auto& lib : cmakeFoundLibraries)
  436. out << " " << lib << newLine;
  437. for (auto& package : cmakePkgconfigPackages)
  438. out << " ${" << package << "_LIBRARIES}" << newLine;
  439. out << ")" << newLine << newLine;
  440. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  441. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  442. out << "add_dependencies (" << targetVarName << " " << "SHARED_CODE)" << newLine << newLine;
  443. }
  444. StringArray cFlags;
  445. cFlags.add (exporter.getArchFlags (config));
  446. cFlags.addArray (exporter.getCPreprocessorFlags (config));
  447. cFlags.addArray (exporter.getCFlags (config));
  448. out << addToCMakeVariable ("CMAKE_C_FLAGS", cFlags.joinIntoString (" ")) << newLine;
  449. String cxxFlags;
  450. for (auto& flag : exporter.getCXXFlags())
  451. if (! flag.startsWith ("-std="))
  452. cxxFlags += " " + flag;
  453. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", "${CMAKE_C_FLAGS} " + cxxFlags) << newLine
  454. << newLine;
  455. out << "endif (" << buildTypeCondition << ")" << newLine
  456. << newLine;
  457. }
  458. }
  459. //==============================================================================
  460. void writeCMakeListsCodeBlocksSection (OutputStream& out, CodeBlocksProjectExporter& exporter) const
  461. {
  462. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine
  463. << newLine;
  464. writeCMakeTargets (out, exporter);
  465. for (auto* target : exporter.targets)
  466. {
  467. if (target->type == ProjectType::Target::Type::AggregateTarget)
  468. continue;
  469. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES PREFIX \"\")" << newLine
  470. << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX " << target->getTargetSuffix().quoted() << ")" << newLine
  471. << newLine;
  472. }
  473. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  474. {
  475. auto& config = dynamic_cast<const CodeBlocksProjectExporter::CodeBlocksBuildConfiguration&> (*c);
  476. out << "#------------------------------------------------------------------------------" << newLine
  477. << "# Config: " << config.getName() << newLine
  478. << "#------------------------------------------------------------------------------" << newLine
  479. << newLine;
  480. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  481. out << "if (" << buildTypeCondition << ")" << newLine
  482. << newLine;
  483. out << "include_directories (" << newLine;
  484. for (auto& path : exporter.getIncludePaths (config))
  485. out << " " << path.replace ("\\", "/").quoted() << newLine;
  486. out << ")" << newLine << newLine;
  487. for (auto* target : exporter.targets)
  488. {
  489. if (target->type == ProjectType::Target::Type::AggregateTarget)
  490. continue;
  491. auto targetVarName = getTargetVarName (*target);
  492. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  493. << " OUTPUT_NAME " << config.getTargetBinaryNameString().quoted() << newLine;
  494. auto cxxStandard = project.getCppStandardString();
  495. if (cxxStandard == "latest")
  496. cxxStandard = "17";
  497. out << " CXX_STANDARD " << cxxStandard << newLine;
  498. if (! shouldUseGNUExtensions())
  499. out << " CXX_EXTENSIONS OFF" << newLine;
  500. out << ")" << newLine << newLine;
  501. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  502. for (auto& def : exporter.getDefines (config, *target))
  503. out << " " << def << newLine;
  504. out << ")" << newLine << newLine;
  505. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  506. for (auto& option : exporter.getCompilerFlags (config, *target))
  507. if (! option.startsWith ("-std="))
  508. out << " " << option.quoted() << newLine;
  509. out << ")" << newLine << newLine;
  510. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  511. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  512. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  513. out << " SHARED_CODE" << newLine
  514. << " -L." << newLine;
  515. for (auto& path : exporter.getLinkerSearchPaths (config, *target))
  516. {
  517. out << " \"-L\\\"";
  518. if (! isWindowsAbsolutePath (path))
  519. out << "${CMAKE_CURRENT_SOURCE_DIR}/";
  520. out << path.replace ("\\", "/").unquoted() << "\\\"\"" << newLine;
  521. }
  522. for (auto& flag : exporter.getLinkerFlags (config, *target))
  523. out << " " << flag << newLine;
  524. for (auto& flag : exporter.getProjectLinkerLibs())
  525. out << " -l" << flag << newLine;
  526. for (auto& lib : exporter.mingwLibs)
  527. out << " -l" << lib << newLine;
  528. out << ")" << newLine << newLine;
  529. }
  530. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", exporter.getProjectCompilerOptions().joinIntoString (" ")) << newLine
  531. << addToCMakeVariable ("CMAKE_C_FLAGS", "${CMAKE_CXX_FLAGS}") << newLine
  532. << newLine;
  533. out << "endif (" << buildTypeCondition << ")" << newLine
  534. << newLine;
  535. }
  536. }
  537. //==============================================================================
  538. void writeCMakeListsXcodeSection (OutputStream& out, XcodeProjectExporter& exporter) const
  539. {
  540. // We need to find out the SDK root before defining the project. Unfortunately this is
  541. // set per-target in the Xcode project, but we want it per-configuration.
  542. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  543. {
  544. auto& config = dynamic_cast<const XcodeProjectExporter::XcodeBuildConfiguration&> (*c);
  545. for (auto* target : exporter.targets)
  546. {
  547. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  548. || target->type == ProjectType::Target::Type::AggregateTarget
  549. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  550. continue;
  551. auto targetAttributes = target->getTargetSettings (config);
  552. auto targetAttributeKeys = targetAttributes.getAllKeys();
  553. if (targetAttributes.getAllKeys().contains ("SDKROOT"))
  554. {
  555. out << "if (CMAKE_BUILD_TYPE STREQUAL " + config.getName() << ")" << newLine
  556. << " set (CMAKE_OSX_SYSROOT " << targetAttributes["SDKROOT"] << ")" << newLine
  557. << "endif()" << newLine << newLine;
  558. break;
  559. }
  560. }
  561. }
  562. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine << newLine;
  563. writeCMakeTargets (out, exporter);
  564. for (auto* target : exporter.targets)
  565. {
  566. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  567. || target->type == ProjectType::Target::Type::AggregateTarget
  568. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  569. continue;
  570. if (target->type == ProjectType::Target::Type::AudioUnitPlugIn)
  571. out << "find_program (RC_COMPILER Rez NO_DEFAULT_PATHS PATHS \"/Applications/Xcode.app/Contents/Developer/usr/bin\")" << newLine
  572. << "if (NOT RC_COMPILER)" << newLine
  573. << " message (WARNING \"failed to find Rez; older resource-based AU plug-ins may not work correctly\")" << newLine
  574. << "endif (NOT RC_COMPILER)" << newLine << newLine;
  575. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::staticLibrary
  576. || target->getTargetFileType() == ProjectType::Target::TargetFileType::sharedLibraryOrDLL)
  577. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX \"" << target->xcodeBundleExtension << "\")" << newLine
  578. << newLine;
  579. }
  580. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  581. {
  582. auto& config = dynamic_cast<const XcodeProjectExporter::XcodeBuildConfiguration&> (*c);
  583. out << "#------------------------------------------------------------------------------" << newLine
  584. << "# Config: " << config.getName() << newLine
  585. << "#------------------------------------------------------------------------------" << newLine
  586. << newLine;
  587. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  588. out << "if (" << buildTypeCondition << ")" << newLine
  589. << newLine;
  590. out << "execute_process (COMMAND uname -m OUTPUT_VARIABLE JUCE_ARCH_LABEL OUTPUT_STRIP_TRAILING_WHITESPACE)" << newLine
  591. << newLine;
  592. auto configSettings = exporter.getProjectSettings (config);
  593. auto configSettingsKeys = configSettings.getAllKeys();
  594. auto binaryName = config.getTargetBinaryNameString();
  595. if (configSettingsKeys.contains ("PRODUCT_NAME"))
  596. binaryName = configSettings["PRODUCT_NAME"].unquoted();
  597. for (auto* target : exporter.targets)
  598. {
  599. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  600. || target->type == ProjectType::Target::Type::AggregateTarget
  601. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  602. continue;
  603. auto targetVarName = getTargetVarName (*target);
  604. auto targetAttributes = target->getTargetSettings (config);
  605. auto targetAttributeKeys = targetAttributes.getAllKeys();
  606. StringArray headerSearchPaths;
  607. if (targetAttributeKeys.contains ("HEADER_SEARCH_PATHS"))
  608. {
  609. auto paths = targetAttributes["HEADER_SEARCH_PATHS"].trim().substring (1).dropLastCharacters (1);
  610. paths = paths.replace ("\"$(inherited)\"", {})
  611. .replace ("$(HOME)", "$ENV{HOME}")
  612. .replace ("~", "$ENV{HOME}");
  613. headerSearchPaths.addTokens (paths, ",\"\t\\", {});
  614. headerSearchPaths.removeEmptyStrings();
  615. targetAttributeKeys.removeString ("HEADER_SEARCH_PATHS");
  616. }
  617. out << "target_include_directories (" << targetVarName << " PRIVATE" << newLine;
  618. for (auto& path : headerSearchPaths)
  619. out << " " << path.quoted() << newLine;
  620. out << ")" << newLine << newLine;
  621. StringArray defines;
  622. if (targetAttributeKeys.contains ("GCC_PREPROCESSOR_DEFINITIONS"))
  623. {
  624. defines.addTokens (targetAttributes["GCC_PREPROCESSOR_DEFINITIONS"], "() ,\t", {});
  625. defines.removeEmptyStrings();
  626. targetAttributeKeys.removeString ("GCC_PREPROCESSOR_DEFINITIONS");
  627. }
  628. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  629. for (auto& def : defines)
  630. out << " " << def << newLine;
  631. out << ")" << newLine << newLine;
  632. StringArray cppFlags;
  633. String archLabel ("${JUCE_ARCH_LABEL}");
  634. // Fat binaries are not supported.
  635. if (targetAttributeKeys.contains ("ARCHS"))
  636. {
  637. auto value = targetAttributes["ARCHS"].unquoted();
  638. if (value.contains ("NATIVE_ARCH_ACTUAL"))
  639. {
  640. cppFlags.add ("-march=native");
  641. }
  642. else if (value.contains ("ARCHS_STANDARD_32_BIT"))
  643. {
  644. archLabel = "i386";
  645. cppFlags.add ("-arch x86");
  646. }
  647. else if (value.contains ("ARCHS_STANDARD_32_64_BIT")
  648. || value.contains ("ARCHS_STANDARD_64_BIT"))
  649. {
  650. archLabel = "x86_64";
  651. cppFlags.add ("-arch x86_64");
  652. }
  653. targetAttributeKeys.removeString ("ARCHS");
  654. }
  655. if (targetAttributeKeys.contains ("MACOSX_DEPLOYMENT_TARGET"))
  656. {
  657. cppFlags.add ("-mmacosx-version-min=" + targetAttributes["MACOSX_DEPLOYMENT_TARGET"]);
  658. targetAttributeKeys.removeString ("MACOSX_DEPLOYMENT_TARGET");
  659. }
  660. if (targetAttributeKeys.contains ("OTHER_CPLUSPLUSFLAGS"))
  661. {
  662. cppFlags.add (targetAttributes["OTHER_CPLUSPLUSFLAGS"].unquoted());
  663. targetAttributeKeys.removeString ("OTHER_CPLUSPLUSFLAGS");
  664. }
  665. if (targetAttributeKeys.contains ("GCC_OPTIMIZATION_LEVEL"))
  666. {
  667. cppFlags.add ("-O" + targetAttributes["GCC_OPTIMIZATION_LEVEL"]);
  668. targetAttributeKeys.removeString ("GCC_OPTIMIZATION_LEVEL");
  669. }
  670. if (targetAttributeKeys.contains ("LLVM_LTO"))
  671. {
  672. cppFlags.add ("-flto");
  673. targetAttributeKeys.removeString ("LLVM_LTO");
  674. }
  675. if (targetAttributeKeys.contains ("GCC_FAST_MATH"))
  676. {
  677. cppFlags.add ("-ffast-math");
  678. targetAttributeKeys.removeString ("GCC_FAST_MATH");
  679. }
  680. // We'll take this setting from the project
  681. targetAttributeKeys.removeString ("CLANG_CXX_LANGUAGE_STANDARD");
  682. if (targetAttributeKeys.contains ("CLANG_CXX_LIBRARY"))
  683. {
  684. cppFlags.add ("-stdlib=" + targetAttributes["CLANG_CXX_LIBRARY"].unquoted());
  685. targetAttributeKeys.removeString ("CLANG_CXX_LIBRARY");
  686. }
  687. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  688. for (auto& flag : cppFlags)
  689. out << " " << flag << newLine;
  690. out << ")" << newLine << newLine;
  691. StringArray libSearchPaths;
  692. if (targetAttributeKeys.contains ("LIBRARY_SEARCH_PATHS"))
  693. {
  694. auto paths = targetAttributes["LIBRARY_SEARCH_PATHS"].trim().substring (1).dropLastCharacters (1);
  695. paths = paths.replace ("\"$(inherited)\"", {});
  696. paths = paths.replace ("$(HOME)", "$ENV{HOME}");
  697. libSearchPaths.addTokens (paths, ",\"\t\\", {});
  698. libSearchPaths.removeEmptyStrings();
  699. for (auto& libPath : libSearchPaths)
  700. {
  701. libPath = libPath.replace ("${CURRENT_ARCH}", archLabel);
  702. if (! isUnixAbsolutePath (libPath))
  703. libPath = "${CMAKE_CURRENT_SOURCE_DIR}/" + libPath;
  704. }
  705. targetAttributeKeys.removeString ("LIBRARY_SEARCH_PATHS");
  706. }
  707. StringArray linkerFlags;
  708. if (targetAttributeKeys.contains ("OTHER_LDFLAGS"))
  709. {
  710. // CMake adds its own SHARED_CODE library linking flags
  711. auto flagsWithReplacedSpaces = targetAttributes["OTHER_LDFLAGS"].unquoted().replace ("\\\\ ", "^^%%^^");
  712. linkerFlags.addTokens (flagsWithReplacedSpaces, true);
  713. linkerFlags.removeString ("-bundle");
  714. linkerFlags.removeString ("-l" + binaryName.replace (" ", "^^%%^^"));
  715. for (auto& flag : linkerFlags)
  716. flag = flag.replace ("^^%%^^", " ");
  717. targetAttributeKeys.removeString ("OTHER_LDFLAGS");
  718. }
  719. if (target->type == ProjectType::Target::Type::AudioUnitPlugIn)
  720. {
  721. String rezFlags;
  722. if (targetAttributeKeys.contains ("OTHER_REZFLAGS"))
  723. {
  724. rezFlags = targetAttributes["OTHER_REZFLAGS"];
  725. targetAttributeKeys.removeString ("OTHER_REZFLAGS");
  726. }
  727. for (auto& item : exporter.getAllGroups())
  728. {
  729. if (item.getName() == ProjectSaver::getJuceCodeGroupName())
  730. {
  731. auto resSourcesVar = targetVarName + "_REZ_SOURCES";
  732. auto resOutputVar = targetVarName + "_REZ_OUTPUT";
  733. auto sdkVersion = config.getOSXSDKVersionString().upToFirstOccurrenceOf (" ", false, false);
  734. auto sysroot = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" + sdkVersion + ".sdk";
  735. out << "if (RC_COMPILER)" << newLine
  736. << " set (" << resSourcesVar << newLine
  737. << " " << item.determineGroupFolder().getChildFile ("include_juce_audio_plugin_client_AU.r").getFullPathName().quoted() << newLine
  738. << " )" << newLine
  739. << " set (" << resOutputVar << " \"${CMAKE_CURRENT_BINARY_DIR}/" << binaryName << ".rsrc\")" << newLine
  740. << " target_sources (" << targetVarName << " PRIVATE" << newLine
  741. << " ${" << resSourcesVar << "}" << newLine
  742. << " ${" << resOutputVar << "}" << newLine
  743. << " )" << newLine
  744. << " execute_process (COMMAND" << newLine
  745. << " ${RC_COMPILER}" << newLine
  746. << " " << rezFlags.unquoted().removeCharacters ("\\") << newLine
  747. << " -isysroot " << sysroot.quoted() << newLine;
  748. for (auto& path : headerSearchPaths)
  749. {
  750. out << " -I \"";
  751. if (! isUnixAbsolutePath (path))
  752. out << "${PROJECT_SOURCE_DIR}/";
  753. out << path << "\"" << newLine;
  754. }
  755. out << " ${" << resSourcesVar << "}" << newLine
  756. << " -o ${" << resOutputVar << "}" << newLine
  757. << " )" << newLine
  758. << " set_source_files_properties (${" << resOutputVar << "} PROPERTIES" << newLine
  759. << " GENERATED TRUE" << newLine
  760. << " MACOSX_PACKAGE_LOCATION Resources" << newLine
  761. << " )" << newLine
  762. << "endif (RC_COMPILER)" << newLine << newLine;
  763. break;
  764. }
  765. }
  766. }
  767. if (targetAttributeKeys.contains ("INFOPLIST_FILE"))
  768. {
  769. auto plistFile = exporter.getTargetFolder().getChildFile (targetAttributes["INFOPLIST_FILE"]);
  770. XmlDocument infoPlistData (plistFile);
  771. std::unique_ptr<XmlElement> plist (infoPlistData.getDocumentElement());
  772. if (plist != nullptr)
  773. {
  774. if (auto* dict = plist->getChildByName ("dict"))
  775. {
  776. if (auto* entry = dict->getChildByName ("key"))
  777. {
  778. while (entry != nullptr)
  779. {
  780. if (entry->getAllSubText() == "CFBundleExecutable")
  781. {
  782. if (auto* bundleName = entry->getNextElementWithTagName ("string"))
  783. {
  784. bundleName->deleteAllTextElements();
  785. bundleName->addTextElement (binaryName);
  786. }
  787. }
  788. entry = entry->getNextElementWithTagName ("key");
  789. }
  790. }
  791. }
  792. auto updatedPlist = getTargetFolder().getChildFile (config.getName() + "-" + plistFile.getFileName());
  793. plist->writeToFile (updatedPlist, "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">");
  794. targetAttributes.set ("INFOPLIST_FILE", updatedPlist.getFullPathName().quoted());
  795. }
  796. else
  797. {
  798. targetAttributeKeys.removeString ("INFOPLIST_FILE");
  799. }
  800. }
  801. targetAttributeKeys.sort (false);
  802. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  803. << " OUTPUT_NAME " << binaryName.quoted() << newLine;
  804. auto cxxStandard = project.getCppStandardString();
  805. if (cxxStandard == "latest")
  806. cxxStandard = "17";
  807. out << " CXX_STANDARD " << cxxStandard << newLine;
  808. if (! shouldUseGNUExtensions())
  809. out << " CXX_EXTENSIONS OFF" << newLine;
  810. for (auto& key : targetAttributeKeys)
  811. out << " XCODE_ATTRIBUTE_" << key << " " << targetAttributes[key] << newLine;
  812. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::executable
  813. || target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle)
  814. {
  815. out << " MACOSX_BUNDLE_INFO_PLIST " << targetAttributes.getValue ("INFOPLIST_FILE", "\"\"") << newLine
  816. << " XCODE_ATTRIBUTE_PRODUCT_NAME " << binaryName.quoted() << newLine;
  817. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::executable)
  818. {
  819. out << " MACOSX_BUNDLE TRUE" << newLine;
  820. }
  821. else
  822. {
  823. out << " BUNDLE TRUE" << newLine
  824. << " BUNDLE_EXTENSION " << targetAttributes.getValue ("WRAPPER_EXTENSION", "\"\"") << newLine
  825. << " XCODE_ATTRIBUTE_MACH_O_TYPE \"mh_bundle\"" << newLine;
  826. }
  827. }
  828. out << ")" << newLine << newLine;
  829. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  830. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  831. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  832. out << " SHARED_CODE" << newLine;
  833. for (auto& path : libSearchPaths)
  834. out << " \"-L\\\"" << path << "\\\"\"" << newLine;
  835. for (auto& flag : linkerFlags)
  836. out << " " << flag.quoted() << newLine;
  837. for (auto& framework : target->frameworkNames)
  838. out << " \"-framework " << framework << "\"" << newLine;
  839. out << ")" << newLine << newLine;
  840. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  841. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  842. {
  843. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  844. && targetAttributeKeys.contains("INSTALL_PATH"))
  845. {
  846. auto installPath = targetAttributes["INSTALL_PATH"].unquoted().replace ("$(HOME)", "$ENV{HOME}");
  847. auto productFilename = binaryName + (targetAttributeKeys.contains ("WRAPPER_EXTENSION") ? "." + targetAttributes["WRAPPER_EXTENSION"] : String());
  848. auto productPath = (installPath + productFilename).quoted();
  849. out << "add_custom_command (TARGET " << targetVarName << " POST_BUILD" << newLine
  850. << " COMMAND ${CMAKE_COMMAND} -E remove_directory " << productPath << newLine
  851. << " COMMAND ${CMAKE_COMMAND} -E copy_directory \"${CMAKE_BINARY_DIR}/" << productFilename << "\" " << productPath << newLine
  852. << " COMMENT \"Copying \\\"" << productFilename << "\\\" to \\\"" << installPath.unquoted() << "\\\"\"" << newLine
  853. << ")" << newLine << newLine;
  854. }
  855. }
  856. }
  857. std::map<String, String> basicWarnings
  858. {
  859. { "CLANG_WARN_BOOL_CONVERSION", "bool-conversion" },
  860. { "CLANG_WARN_COMMA", "comma" },
  861. { "CLANG_WARN_CONSTANT_CONVERSION", "constant-conversion" },
  862. { "CLANG_WARN_EMPTY_BODY", "empty-body" },
  863. { "CLANG_WARN_ENUM_CONVERSION", "enum-conversion" },
  864. { "CLANG_WARN_INFINITE_RECURSION", "infinite-recursion" },
  865. { "CLANG_WARN_INT_CONVERSION", "int-conversion" },
  866. { "CLANG_WARN_RANGE_LOOP_ANALYSIS", "range-loop-analysis" },
  867. { "CLANG_WARN_STRICT_PROTOTYPES", "strict-prototypes" },
  868. { "GCC_WARN_CHECK_SWITCH_STATEMENTS", "switch" },
  869. { "GCC_WARN_UNUSED_VARIABLE", "unused-variable" },
  870. { "GCC_WARN_MISSING_PARENTHESES", "parentheses" },
  871. { "GCC_WARN_NON_VIRTUAL_DESTRUCTOR", "non-virtual-dtor" },
  872. { "GCC_WARN_64_TO_32_BIT_CONVERSION", "shorten-64-to-32" },
  873. { "GCC_WARN_UNDECLARED_SELECTOR", "undeclared-selector" },
  874. { "GCC_WARN_UNUSED_FUNCTION", "unused-function" }
  875. };
  876. StringArray compilerFlags;
  877. for (auto& key : configSettingsKeys)
  878. {
  879. auto basicWarning = basicWarnings.find (key);
  880. if (basicWarning != basicWarnings.end())
  881. {
  882. compilerFlags.add (configSettings[key] == "YES" ? "-W" + basicWarning->second : "-Wno-" + basicWarning->second);
  883. }
  884. else if (key == "CLANG_WARN_SUSPICIOUS_MOVE" && configSettings[key] == "YES") compilerFlags.add ("-Wmove");
  885. else if (key == "CLANG_WARN_UNREACHABLE_CODE" && configSettings[key] == "YES") compilerFlags.add ("-Wunreachable-code");
  886. else if (key == "CLANG_WARN__DUPLICATE_METHOD_MATCH" && configSettings[key] == "YES") compilerFlags.add ("-Wduplicate-method-match");
  887. else if (key == "GCC_INLINES_ARE_PRIVATE_EXTERN" && configSettings[key] == "YES") compilerFlags.add ("-fvisibility-inlines-hidden");
  888. else if (key == "GCC_NO_COMMON_BLOCKS" && configSettings[key] == "YES") compilerFlags.add ("-fno-common");
  889. else if (key == "GCC_WARN_ABOUT_RETURN_TYPE" && configSettings[key] != "YES") compilerFlags.add (configSettings[key] == "YES_ERROR" ? "-Werror=return-type" : "-Wno-return-type");
  890. else if (key == "GCC_WARN_TYPECHECK_CALLS_TO_PRINTF" && configSettings[key] != "YES") compilerFlags.add ("-Wno-format");
  891. else if (key == "GCC_WARN_UNINITIALIZED_AUTOS")
  892. {
  893. if (configSettings[key] == "YES") compilerFlags.add ("-Wuninitialized");
  894. else if (configSettings[key] == "YES_AGGRESSIVE") compilerFlags.add ("--Wconditional-uninitialized");
  895. else compilerFlags.add (")-Wno-uninitialized");
  896. }
  897. else if (key == "WARNING_CFLAGS") compilerFlags.add (configSettings[key].unquoted());
  898. }
  899. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", compilerFlags.joinIntoString (" ")) << newLine
  900. << addToCMakeVariable ("CMAKE_C_FLAGS", "${CMAKE_CXX_FLAGS}") << newLine
  901. << newLine;
  902. out << "endif (" << buildTypeCondition << ")" << newLine
  903. << newLine;
  904. }
  905. }
  906. //==============================================================================
  907. JUCE_DECLARE_NON_COPYABLE (CLionProjectExporter)
  908. };