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.

1184 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& projectToUse, const ValueTree& settingsToUse)
  47. {
  48. if (settingsToUse.hasType (getValueTreeTypeName()))
  49. return new CLionProjectExporter (projectToUse, settingsToUse);
  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. StringArray pathComponents = { "..", "MacOSX", "Icon.icns" };
  308. auto xcodeIcnsFile = getTargetFolder();
  309. for (auto& comp : pathComponents)
  310. xcodeIcnsFile = xcodeIcnsFile.getChildFile (comp);
  311. if (xcodeIcnsFile.existsAsFile())
  312. return pathComponents.joinIntoString ("/").quoted();
  313. }
  314. return {};
  315. }();
  316. if (xcodeIcnsFilePath.isNotEmpty())
  317. out << " " << xcodeIcnsFilePath << newLine;
  318. if (exporter.isCodeBlocks() && target->getTargetFileType() == ProjectType::Target::TargetFileType::executable)
  319. {
  320. StringArray pathComponents = { "..", "CodeBlocksWindows", "resources.rc" };
  321. auto windowsRcFile = getTargetFolder();
  322. for (auto& comp : pathComponents)
  323. windowsRcFile = windowsRcFile.getChildFile (comp);
  324. if (windowsRcFile.existsAsFile())
  325. out << " " << pathComponents.joinIntoString ("/").quoted() << newLine;
  326. }
  327. out << ")" << newLine << newLine;
  328. if (isCMakeBundle)
  329. out << "set_source_files_properties (" << pkgInfoPath << " PROPERTIES MACOSX_PACKAGE_LOCATION .)" << newLine;
  330. if (xcodeIcnsFilePath.isNotEmpty())
  331. out << "set_source_files_properties (" << xcodeIcnsFilePath << " PROPERTIES MACOSX_PACKAGE_LOCATION \"Resources\")" << newLine;
  332. for (auto& fileInfo : fileInfoList)
  333. {
  334. if (std::get<1> (fileInfo))
  335. {
  336. auto extraCompilerFlags = std::get<2> (fileInfo);
  337. if (extraCompilerFlags.isNotEmpty())
  338. out << "set_source_files_properties(" << std::get<0> (fileInfo).quoted() << " PROPERTIES COMPILE_FLAGS " << extraCompilerFlags << " )" << newLine;
  339. }
  340. else
  341. {
  342. out << "set_source_files_properties (" << std::get<0> (fileInfo).quoted() << " PROPERTIES HEADER_FILE_ONLY TRUE)" << newLine;
  343. }
  344. }
  345. out << newLine;
  346. }
  347. }
  348. //==============================================================================
  349. void writeCMakeListsMakefileSection (OutputStream& out, MakefileProjectExporter& exporter) const
  350. {
  351. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine
  352. << newLine;
  353. out << "find_package (PkgConfig REQUIRED)" << newLine;
  354. StringArray cmakePkgconfigPackages;
  355. for (auto& package : exporter.getPackages())
  356. {
  357. cmakePkgconfigPackages.add (package.toUpperCase());
  358. out << "pkg_search_module (" << cmakePkgconfigPackages.strings.getLast() << " REQUIRED " << package << ")" << newLine;
  359. }
  360. out << newLine;
  361. writeCMakeTargets (out, exporter);
  362. for (auto* target : exporter.targets)
  363. {
  364. if (target->type == ProjectType::Target::Type::AggregateTarget)
  365. continue;
  366. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle)
  367. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES PREFIX \"\")" << newLine;
  368. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX \"" << target->getTargetFileSuffix() << "\")" << newLine
  369. << newLine;
  370. }
  371. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  372. {
  373. auto& config = dynamic_cast<const MakefileProjectExporter::MakeBuildConfiguration&> (*c);
  374. out << "#------------------------------------------------------------------------------" << newLine
  375. << "# Config: " << config.getName() << newLine
  376. << "#------------------------------------------------------------------------------" << newLine
  377. << newLine;
  378. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  379. out << "if (" << buildTypeCondition << ")" << newLine
  380. << newLine;
  381. out << "execute_process (COMMAND uname -m OUTPUT_VARIABLE JUCE_ARCH_LABEL OUTPUT_STRIP_TRAILING_WHITESPACE)" << newLine
  382. << newLine;
  383. out << "include_directories (" << newLine;
  384. for (auto& path : exporter.getHeaderSearchPaths (config))
  385. out << " " << path.quoted() << newLine;
  386. for (auto& package : cmakePkgconfigPackages)
  387. out << " ${" << package << "_INCLUDE_DIRS}" << newLine;
  388. out << ")" << newLine << newLine;
  389. StringArray cmakeFoundLibraries;
  390. for (auto& library : exporter.getLibraryNames (config))
  391. {
  392. String cmakeLibraryID (library.toUpperCase());
  393. cmakeFoundLibraries.add (String ("${") + cmakeLibraryID + "}");
  394. out << "find_library (" << cmakeLibraryID << " " << library << newLine;
  395. for (auto& path : exporter.getLibrarySearchPaths (config))
  396. out << " " << path.quoted() << newLine;
  397. out << ")" << newLine
  398. << newLine;
  399. }
  400. for (auto* target : exporter.targets)
  401. {
  402. if (target->type == ProjectType::Target::Type::AggregateTarget)
  403. continue;
  404. auto targetVarName = getTargetVarName (*target);
  405. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  406. << " OUTPUT_NAME " << config.getTargetBinaryNameString().quoted() << newLine;
  407. auto cxxStandard = project.getCppStandardString();
  408. if (cxxStandard == "latest")
  409. cxxStandard = "17";
  410. out << " CXX_STANDARD " << cxxStandard << newLine;
  411. if (! shouldUseGNUExtensions())
  412. out << " CXX_EXTENSIONS OFF" << newLine;
  413. out << ")" << newLine << newLine;
  414. auto defines = exporter.getDefines (config);
  415. defines.addArray (target->getDefines (config));
  416. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  417. for (auto& key : defines.getAllKeys())
  418. out << " " << key << "=" << defines[key] << newLine;
  419. out << ")" << newLine << newLine;
  420. auto targetFlags = target->getCompilerFlags();
  421. if (! targetFlags.isEmpty())
  422. {
  423. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  424. for (auto& flag : targetFlags)
  425. out << " " << flag << newLine;
  426. out << ")" << newLine << newLine;
  427. }
  428. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  429. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  430. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  431. out << " SHARED_CODE" << newLine;
  432. out << " " << exporter.getArchFlags (config) << newLine;
  433. for (auto& flag : target->getLinkerFlags())
  434. out << " " << flag << newLine;
  435. for (auto& flag : exporter.getLinkerFlags (config))
  436. out << " " << flag << newLine;
  437. for (auto& lib : cmakeFoundLibraries)
  438. out << " " << lib << newLine;
  439. for (auto& package : cmakePkgconfigPackages)
  440. out << " ${" << package << "_LIBRARIES}" << newLine;
  441. out << ")" << newLine << newLine;
  442. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  443. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  444. out << "add_dependencies (" << targetVarName << " " << "SHARED_CODE)" << newLine << newLine;
  445. }
  446. StringArray cFlags;
  447. cFlags.add (exporter.getArchFlags (config));
  448. cFlags.addArray (exporter.getCPreprocessorFlags (config));
  449. cFlags.addArray (exporter.getCFlags (config));
  450. out << addToCMakeVariable ("CMAKE_C_FLAGS", cFlags.joinIntoString (" ")) << newLine;
  451. String cxxFlags;
  452. for (auto& flag : exporter.getCXXFlags())
  453. if (! flag.startsWith ("-std="))
  454. cxxFlags += " " + flag;
  455. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", "${CMAKE_C_FLAGS} " + cxxFlags) << newLine
  456. << newLine;
  457. out << "endif (" << buildTypeCondition << ")" << newLine
  458. << newLine;
  459. }
  460. }
  461. //==============================================================================
  462. void writeCMakeListsCodeBlocksSection (OutputStream& out, CodeBlocksProjectExporter& exporter) const
  463. {
  464. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine
  465. << newLine;
  466. writeCMakeTargets (out, exporter);
  467. for (auto* target : exporter.targets)
  468. {
  469. if (target->type == ProjectType::Target::Type::AggregateTarget)
  470. continue;
  471. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES PREFIX \"\")" << newLine
  472. << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX " << target->getTargetSuffix().quoted() << ")" << newLine
  473. << newLine;
  474. }
  475. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  476. {
  477. auto& config = dynamic_cast<const CodeBlocksProjectExporter::CodeBlocksBuildConfiguration&> (*c);
  478. out << "#------------------------------------------------------------------------------" << newLine
  479. << "# Config: " << config.getName() << newLine
  480. << "#------------------------------------------------------------------------------" << newLine
  481. << newLine;
  482. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  483. out << "if (" << buildTypeCondition << ")" << newLine
  484. << newLine;
  485. out << "include_directories (" << newLine;
  486. for (auto& path : exporter.getIncludePaths (config))
  487. out << " " << path.replace ("\\", "/").quoted() << newLine;
  488. out << ")" << newLine << newLine;
  489. for (auto* target : exporter.targets)
  490. {
  491. if (target->type == ProjectType::Target::Type::AggregateTarget)
  492. continue;
  493. auto targetVarName = getTargetVarName (*target);
  494. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  495. << " OUTPUT_NAME " << config.getTargetBinaryNameString().quoted() << newLine;
  496. auto cxxStandard = project.getCppStandardString();
  497. if (cxxStandard == "latest")
  498. cxxStandard = "17";
  499. out << " CXX_STANDARD " << cxxStandard << newLine;
  500. if (! shouldUseGNUExtensions())
  501. out << " CXX_EXTENSIONS OFF" << newLine;
  502. out << ")" << newLine << newLine;
  503. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  504. for (auto& def : exporter.getDefines (config, *target))
  505. out << " " << def << newLine;
  506. out << ")" << newLine << newLine;
  507. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  508. for (auto& option : exporter.getCompilerFlags (config, *target))
  509. if (! option.startsWith ("-std="))
  510. out << " " << option.quoted() << newLine;
  511. out << ")" << newLine << newLine;
  512. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  513. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  514. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  515. out << " SHARED_CODE" << newLine
  516. << " -L." << newLine;
  517. for (auto& path : exporter.getLinkerSearchPaths (config, *target))
  518. {
  519. out << " \"-L\\\"";
  520. if (! isWindowsAbsolutePath (path))
  521. out << "${CMAKE_CURRENT_SOURCE_DIR}/";
  522. out << path.replace ("\\", "/").unquoted() << "\\\"\"" << newLine;
  523. }
  524. for (auto& flag : exporter.getLinkerFlags (config, *target))
  525. out << " " << flag << newLine;
  526. for (auto& flag : exporter.getProjectLinkerLibs())
  527. out << " -l" << flag << newLine;
  528. for (auto& lib : exporter.mingwLibs)
  529. out << " -l" << lib << newLine;
  530. out << ")" << newLine << newLine;
  531. }
  532. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", exporter.getProjectCompilerOptions().joinIntoString (" ")) << newLine
  533. << addToCMakeVariable ("CMAKE_C_FLAGS", "${CMAKE_CXX_FLAGS}") << newLine
  534. << newLine;
  535. out << "endif (" << buildTypeCondition << ")" << newLine
  536. << newLine;
  537. }
  538. }
  539. //==============================================================================
  540. void writeCMakeListsXcodeSection (OutputStream& out, XcodeProjectExporter& exporter) const
  541. {
  542. // We need to find out the SDK root before defining the project. Unfortunately this is
  543. // set per-target in the Xcode project, but we want it per-configuration.
  544. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  545. {
  546. auto& config = dynamic_cast<const XcodeProjectExporter::XcodeBuildConfiguration&> (*c);
  547. for (auto* target : exporter.targets)
  548. {
  549. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  550. || target->type == ProjectType::Target::Type::AggregateTarget
  551. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  552. continue;
  553. auto targetAttributes = target->getTargetSettings (config);
  554. auto targetAttributeKeys = targetAttributes.getAllKeys();
  555. if (targetAttributes.getAllKeys().contains ("SDKROOT"))
  556. {
  557. out << "if (CMAKE_BUILD_TYPE STREQUAL " + config.getName() << ")" << newLine
  558. << " set (CMAKE_OSX_SYSROOT " << targetAttributes["SDKROOT"] << ")" << newLine
  559. << "endif()" << newLine << newLine;
  560. break;
  561. }
  562. }
  563. }
  564. out << "project (" << getProject().getProjectNameString().quoted() << " C CXX)" << newLine << newLine;
  565. writeCMakeTargets (out, exporter);
  566. for (auto* target : exporter.targets)
  567. {
  568. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  569. || target->type == ProjectType::Target::Type::AggregateTarget
  570. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  571. continue;
  572. if (target->type == ProjectType::Target::Type::AudioUnitPlugIn)
  573. out << "find_program (RC_COMPILER Rez NO_DEFAULT_PATHS PATHS \"/Applications/Xcode.app/Contents/Developer/usr/bin\")" << newLine
  574. << "if (NOT RC_COMPILER)" << newLine
  575. << " message (WARNING \"failed to find Rez; older resource-based AU plug-ins may not work correctly\")" << newLine
  576. << "endif (NOT RC_COMPILER)" << newLine << newLine;
  577. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::staticLibrary
  578. || target->getTargetFileType() == ProjectType::Target::TargetFileType::sharedLibraryOrDLL)
  579. out << "set_target_properties (" << getTargetVarName (*target) << " PROPERTIES SUFFIX \"" << target->xcodeBundleExtension << "\")" << newLine
  580. << newLine;
  581. }
  582. for (ProjectExporter::ConstConfigIterator c (exporter); c.next();)
  583. {
  584. auto& config = dynamic_cast<const XcodeProjectExporter::XcodeBuildConfiguration&> (*c);
  585. out << "#------------------------------------------------------------------------------" << newLine
  586. << "# Config: " << config.getName() << newLine
  587. << "#------------------------------------------------------------------------------" << newLine
  588. << newLine;
  589. auto buildTypeCondition = String ("CMAKE_BUILD_TYPE STREQUAL " + config.getName());
  590. out << "if (" << buildTypeCondition << ")" << newLine
  591. << newLine;
  592. out << "execute_process (COMMAND uname -m OUTPUT_VARIABLE JUCE_ARCH_LABEL OUTPUT_STRIP_TRAILING_WHITESPACE)" << newLine
  593. << newLine;
  594. auto configSettings = exporter.getProjectSettings (config);
  595. auto configSettingsKeys = configSettings.getAllKeys();
  596. auto binaryName = config.getTargetBinaryNameString();
  597. if (configSettingsKeys.contains ("PRODUCT_NAME"))
  598. binaryName = configSettings["PRODUCT_NAME"].unquoted();
  599. for (auto* target : exporter.targets)
  600. {
  601. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::macOSAppex
  602. || target->type == ProjectType::Target::Type::AggregateTarget
  603. || target->type == ProjectType::Target::Type::AudioUnitv3PlugIn)
  604. continue;
  605. auto targetVarName = getTargetVarName (*target);
  606. auto targetAttributes = target->getTargetSettings (config);
  607. auto targetAttributeKeys = targetAttributes.getAllKeys();
  608. StringArray headerSearchPaths;
  609. if (targetAttributeKeys.contains ("HEADER_SEARCH_PATHS"))
  610. {
  611. auto paths = targetAttributes["HEADER_SEARCH_PATHS"].trim().substring (1).dropLastCharacters (1);
  612. paths = paths.replace ("\"$(inherited)\"", {})
  613. .replace ("$(HOME)", "$ENV{HOME}")
  614. .replace ("~", "$ENV{HOME}");
  615. headerSearchPaths.addTokens (paths, ",\"\t\\", {});
  616. headerSearchPaths.removeEmptyStrings();
  617. targetAttributeKeys.removeString ("HEADER_SEARCH_PATHS");
  618. }
  619. out << "target_include_directories (" << targetVarName << " PRIVATE" << newLine;
  620. for (auto& path : headerSearchPaths)
  621. out << " " << path.quoted() << newLine;
  622. out << ")" << newLine << newLine;
  623. StringArray defines;
  624. if (targetAttributeKeys.contains ("GCC_PREPROCESSOR_DEFINITIONS"))
  625. {
  626. defines.addTokens (targetAttributes["GCC_PREPROCESSOR_DEFINITIONS"], "() ,\t", {});
  627. defines.removeEmptyStrings();
  628. targetAttributeKeys.removeString ("GCC_PREPROCESSOR_DEFINITIONS");
  629. }
  630. out << "target_compile_definitions (" << targetVarName << " PRIVATE" << newLine;
  631. for (auto& def : defines)
  632. out << " " << def << newLine;
  633. out << ")" << newLine << newLine;
  634. StringArray cppFlags;
  635. String archLabel ("${JUCE_ARCH_LABEL}");
  636. // Fat binaries are not supported.
  637. if (targetAttributeKeys.contains ("ARCHS"))
  638. {
  639. auto value = targetAttributes["ARCHS"].unquoted();
  640. if (value.contains ("NATIVE_ARCH_ACTUAL"))
  641. {
  642. cppFlags.add ("-march=native");
  643. }
  644. else if (value.contains ("ARCHS_STANDARD_32_BIT"))
  645. {
  646. archLabel = "i386";
  647. cppFlags.add ("-arch x86");
  648. }
  649. else if (value.contains ("ARCHS_STANDARD_32_64_BIT")
  650. || value.contains ("ARCHS_STANDARD_64_BIT"))
  651. {
  652. archLabel = "x86_64";
  653. cppFlags.add ("-arch x86_64");
  654. }
  655. targetAttributeKeys.removeString ("ARCHS");
  656. }
  657. if (targetAttributeKeys.contains ("MACOSX_DEPLOYMENT_TARGET"))
  658. {
  659. cppFlags.add ("-mmacosx-version-min=" + targetAttributes["MACOSX_DEPLOYMENT_TARGET"]);
  660. targetAttributeKeys.removeString ("MACOSX_DEPLOYMENT_TARGET");
  661. }
  662. if (targetAttributeKeys.contains ("OTHER_CPLUSPLUSFLAGS"))
  663. {
  664. cppFlags.add (targetAttributes["OTHER_CPLUSPLUSFLAGS"].unquoted());
  665. targetAttributeKeys.removeString ("OTHER_CPLUSPLUSFLAGS");
  666. }
  667. if (targetAttributeKeys.contains ("GCC_OPTIMIZATION_LEVEL"))
  668. {
  669. cppFlags.add ("-O" + targetAttributes["GCC_OPTIMIZATION_LEVEL"]);
  670. targetAttributeKeys.removeString ("GCC_OPTIMIZATION_LEVEL");
  671. }
  672. if (targetAttributeKeys.contains ("LLVM_LTO"))
  673. {
  674. cppFlags.add ("-flto");
  675. targetAttributeKeys.removeString ("LLVM_LTO");
  676. }
  677. if (targetAttributeKeys.contains ("GCC_FAST_MATH"))
  678. {
  679. cppFlags.add ("-ffast-math");
  680. targetAttributeKeys.removeString ("GCC_FAST_MATH");
  681. }
  682. // We'll take this setting from the project
  683. targetAttributeKeys.removeString ("CLANG_CXX_LANGUAGE_STANDARD");
  684. if (targetAttributeKeys.contains ("CLANG_CXX_LIBRARY"))
  685. {
  686. cppFlags.add ("-stdlib=" + targetAttributes["CLANG_CXX_LIBRARY"].unquoted());
  687. targetAttributeKeys.removeString ("CLANG_CXX_LIBRARY");
  688. }
  689. out << "target_compile_options (" << targetVarName << " PRIVATE" << newLine;
  690. for (auto& flag : cppFlags)
  691. out << " " << flag << newLine;
  692. out << ")" << newLine << newLine;
  693. StringArray libSearchPaths;
  694. if (targetAttributeKeys.contains ("LIBRARY_SEARCH_PATHS"))
  695. {
  696. auto paths = targetAttributes["LIBRARY_SEARCH_PATHS"].trim().substring (1).dropLastCharacters (1);
  697. paths = paths.replace ("\"$(inherited)\"", {});
  698. paths = paths.replace ("$(HOME)", "$ENV{HOME}");
  699. libSearchPaths.addTokens (paths, ",\"\t\\", {});
  700. libSearchPaths.removeEmptyStrings();
  701. for (auto& libPath : libSearchPaths)
  702. {
  703. libPath = libPath.replace ("${CURRENT_ARCH}", archLabel);
  704. if (! isUnixAbsolutePath (libPath))
  705. libPath = "${CMAKE_CURRENT_SOURCE_DIR}/" + libPath;
  706. }
  707. targetAttributeKeys.removeString ("LIBRARY_SEARCH_PATHS");
  708. }
  709. StringArray linkerFlags;
  710. if (targetAttributeKeys.contains ("OTHER_LDFLAGS"))
  711. {
  712. // CMake adds its own SHARED_CODE library linking flags
  713. auto flagsWithReplacedSpaces = targetAttributes["OTHER_LDFLAGS"].unquoted().replace ("\\\\ ", "^^%%^^");
  714. linkerFlags.addTokens (flagsWithReplacedSpaces, true);
  715. linkerFlags.removeString ("-bundle");
  716. linkerFlags.removeString ("-l" + binaryName.replace (" ", "^^%%^^"));
  717. for (auto& flag : linkerFlags)
  718. flag = flag.replace ("^^%%^^", " ");
  719. targetAttributeKeys.removeString ("OTHER_LDFLAGS");
  720. }
  721. if (target->type == ProjectType::Target::Type::AudioUnitPlugIn)
  722. {
  723. String rezFlags;
  724. if (targetAttributeKeys.contains ("OTHER_REZFLAGS"))
  725. {
  726. rezFlags = targetAttributes["OTHER_REZFLAGS"];
  727. targetAttributeKeys.removeString ("OTHER_REZFLAGS");
  728. }
  729. for (auto& item : exporter.getAllGroups())
  730. {
  731. if (item.getName() == ProjectSaver::getJuceCodeGroupName())
  732. {
  733. auto resSourcesVar = targetVarName + "_REZ_SOURCES";
  734. auto resOutputVar = targetVarName + "_REZ_OUTPUT";
  735. auto sdkVersion = config.getOSXSDKVersionString().upToFirstOccurrenceOf (" ", false, false);
  736. auto sysroot = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" + sdkVersion + ".sdk";
  737. RelativePath rFile ("JuceLibraryCode/include_juce_audio_plugin_client_AU.r", RelativePath::projectFolder);
  738. rFile = rebaseFromProjectFolderToBuildTarget (rFile);
  739. out << "if (RC_COMPILER)" << newLine
  740. << " set (" << resSourcesVar << newLine
  741. << " " << ("${CMAKE_CURRENT_SOURCE_DIR}/" + rFile.toUnixStyle()).quoted() << newLine
  742. << " )" << newLine
  743. << " set (" << resOutputVar << " " << ("${CMAKE_CURRENT_BINARY_DIR}/" + binaryName + ".rsrc").quoted() << ")" << newLine
  744. << " target_sources (" << targetVarName << " PRIVATE" << newLine
  745. << " ${" << resSourcesVar << "}" << newLine
  746. << " ${" << resOutputVar << "}" << newLine
  747. << " )" << newLine
  748. << " execute_process (COMMAND" << newLine
  749. << " ${RC_COMPILER}" << newLine
  750. << " " << rezFlags.unquoted().removeCharacters ("\\") << newLine
  751. << " -isysroot " << sysroot.quoted() << newLine;
  752. for (auto& path : headerSearchPaths)
  753. {
  754. out << " -I \"";
  755. if (! isUnixAbsolutePath (path))
  756. out << "${PROJECT_SOURCE_DIR}/";
  757. out << path << "\"" << newLine;
  758. }
  759. out << " ${" << resSourcesVar << "}" << newLine
  760. << " -o ${" << resOutputVar << "}" << newLine
  761. << " )" << newLine
  762. << " set_source_files_properties (${" << resOutputVar << "} PROPERTIES" << newLine
  763. << " GENERATED TRUE" << newLine
  764. << " MACOSX_PACKAGE_LOCATION Resources" << newLine
  765. << " )" << newLine
  766. << "endif (RC_COMPILER)" << newLine << newLine;
  767. break;
  768. }
  769. }
  770. }
  771. if (targetAttributeKeys.contains ("INFOPLIST_FILE"))
  772. {
  773. auto plistFile = exporter.getTargetFolder().getChildFile (targetAttributes["INFOPLIST_FILE"]);
  774. if (auto plist = parseXML (plistFile))
  775. {
  776. if (auto* dict = plist->getChildByName ("dict"))
  777. {
  778. if (auto* entry = dict->getChildByName ("key"))
  779. {
  780. while (entry != nullptr)
  781. {
  782. if (entry->getAllSubText() == "CFBundleExecutable")
  783. {
  784. if (auto* bundleName = entry->getNextElementWithTagName ("string"))
  785. {
  786. bundleName->deleteAllTextElements();
  787. bundleName->addTextElement (binaryName);
  788. }
  789. }
  790. entry = entry->getNextElementWithTagName ("key");
  791. }
  792. }
  793. }
  794. auto updatedPlist = getTargetFolder().getChildFile (config.getName() + "-" + plistFile.getFileName());
  795. XmlElement::TextFormat format;
  796. format.dtd = "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">";
  797. plist->writeTo (updatedPlist, format);
  798. targetAttributes.set ("INFOPLIST_FILE", ("${CMAKE_CURRENT_SOURCE_DIR}/" + updatedPlist.getFileName()).quoted());
  799. }
  800. else
  801. {
  802. targetAttributeKeys.removeString ("INFOPLIST_FILE");
  803. }
  804. }
  805. targetAttributeKeys.sort (false);
  806. out << "set_target_properties (" << targetVarName << " PROPERTIES" << newLine
  807. << " OUTPUT_NAME " << binaryName.quoted() << newLine;
  808. auto cxxStandard = project.getCppStandardString();
  809. if (cxxStandard == "latest")
  810. cxxStandard = "17";
  811. out << " CXX_STANDARD " << cxxStandard << newLine;
  812. if (! shouldUseGNUExtensions())
  813. out << " CXX_EXTENSIONS OFF" << newLine;
  814. for (auto& key : targetAttributeKeys)
  815. out << " XCODE_ATTRIBUTE_" << key << " " << targetAttributes[key] << newLine;
  816. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::executable
  817. || target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle)
  818. {
  819. out << " MACOSX_BUNDLE_INFO_PLIST " << targetAttributes.getValue ("INFOPLIST_FILE", "\"\"") << newLine
  820. << " XCODE_ATTRIBUTE_PRODUCT_NAME " << binaryName.quoted() << newLine;
  821. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::executable)
  822. {
  823. out << " MACOSX_BUNDLE TRUE" << newLine;
  824. }
  825. else
  826. {
  827. out << " BUNDLE TRUE" << newLine
  828. << " BUNDLE_EXTENSION " << targetAttributes.getValue ("WRAPPER_EXTENSION", "\"\"") << newLine
  829. << " XCODE_ATTRIBUTE_MACH_O_TYPE \"mh_bundle\"" << newLine;
  830. }
  831. }
  832. out << ")" << newLine << newLine;
  833. out << "target_link_libraries (" << targetVarName << " PRIVATE" << newLine;
  834. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  835. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  836. out << " SHARED_CODE" << newLine;
  837. for (auto& path : libSearchPaths)
  838. out << " \"-L\\\"" << path << "\\\"\"" << newLine;
  839. for (auto& flag : linkerFlags)
  840. out << " " << flag.quoted() << newLine;
  841. for (auto& framework : target->frameworkNames)
  842. out << " \"-framework " << framework << "\"" << newLine;
  843. out << ")" << newLine << newLine;
  844. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  845. || target->type == ProjectType::Target::Type::StandalonePlugIn)
  846. {
  847. if (target->getTargetFileType() == ProjectType::Target::TargetFileType::pluginBundle
  848. && targetAttributeKeys.contains("INSTALL_PATH"))
  849. {
  850. auto installPath = targetAttributes["INSTALL_PATH"].unquoted().replace ("$(HOME)", "$ENV{HOME}");
  851. auto productFilename = binaryName + (targetAttributeKeys.contains ("WRAPPER_EXTENSION") ? "." + targetAttributes["WRAPPER_EXTENSION"] : String());
  852. auto productPath = (installPath + productFilename).quoted();
  853. out << "add_custom_command (TARGET " << targetVarName << " POST_BUILD" << newLine
  854. << " COMMAND ${CMAKE_COMMAND} -E remove_directory " << productPath << newLine
  855. << " COMMAND ${CMAKE_COMMAND} -E copy_directory \"${CMAKE_BINARY_DIR}/" << productFilename << "\" " << productPath << newLine
  856. << " COMMENT \"Copying \\\"" << productFilename << "\\\" to \\\"" << installPath.unquoted() << "\\\"\"" << newLine
  857. << ")" << newLine << newLine;
  858. }
  859. }
  860. }
  861. std::map<String, String> basicWarnings
  862. {
  863. { "CLANG_WARN_BOOL_CONVERSION", "bool-conversion" },
  864. { "CLANG_WARN_COMMA", "comma" },
  865. { "CLANG_WARN_CONSTANT_CONVERSION", "constant-conversion" },
  866. { "CLANG_WARN_EMPTY_BODY", "empty-body" },
  867. { "CLANG_WARN_ENUM_CONVERSION", "enum-conversion" },
  868. { "CLANG_WARN_INFINITE_RECURSION", "infinite-recursion" },
  869. { "CLANG_WARN_INT_CONVERSION", "int-conversion" },
  870. { "CLANG_WARN_RANGE_LOOP_ANALYSIS", "range-loop-analysis" },
  871. { "CLANG_WARN_STRICT_PROTOTYPES", "strict-prototypes" },
  872. { "GCC_WARN_CHECK_SWITCH_STATEMENTS", "switch" },
  873. { "GCC_WARN_UNUSED_VARIABLE", "unused-variable" },
  874. { "GCC_WARN_MISSING_PARENTHESES", "parentheses" },
  875. { "GCC_WARN_NON_VIRTUAL_DESTRUCTOR", "non-virtual-dtor" },
  876. { "GCC_WARN_64_TO_32_BIT_CONVERSION", "shorten-64-to-32" },
  877. { "GCC_WARN_UNDECLARED_SELECTOR", "undeclared-selector" },
  878. { "GCC_WARN_UNUSED_FUNCTION", "unused-function" }
  879. };
  880. StringArray compilerFlags;
  881. for (auto& key : configSettingsKeys)
  882. {
  883. auto basicWarning = basicWarnings.find (key);
  884. if (basicWarning != basicWarnings.end())
  885. {
  886. compilerFlags.add (configSettings[key] == "YES" ? "-W" + basicWarning->second : "-Wno-" + basicWarning->second);
  887. }
  888. else if (key == "CLANG_WARN_SUSPICIOUS_MOVE" && configSettings[key] == "YES") compilerFlags.add ("-Wmove");
  889. else if (key == "CLANG_WARN_UNREACHABLE_CODE" && configSettings[key] == "YES") compilerFlags.add ("-Wunreachable-code");
  890. else if (key == "CLANG_WARN__DUPLICATE_METHOD_MATCH" && configSettings[key] == "YES") compilerFlags.add ("-Wduplicate-method-match");
  891. else if (key == "GCC_INLINES_ARE_PRIVATE_EXTERN" && configSettings[key] == "YES") compilerFlags.add ("-fvisibility-inlines-hidden");
  892. else if (key == "GCC_NO_COMMON_BLOCKS" && configSettings[key] == "YES") compilerFlags.add ("-fno-common");
  893. else if (key == "GCC_WARN_ABOUT_RETURN_TYPE" && configSettings[key] != "YES") compilerFlags.add (configSettings[key] == "YES_ERROR" ? "-Werror=return-type" : "-Wno-return-type");
  894. else if (key == "GCC_WARN_TYPECHECK_CALLS_TO_PRINTF" && configSettings[key] != "YES") compilerFlags.add ("-Wno-format");
  895. else if (key == "GCC_WARN_UNINITIALIZED_AUTOS")
  896. {
  897. if (configSettings[key] == "YES") compilerFlags.add ("-Wuninitialized");
  898. else if (configSettings[key] == "YES_AGGRESSIVE") compilerFlags.add ("--Wconditional-uninitialized");
  899. else compilerFlags.add (")-Wno-uninitialized");
  900. }
  901. else if (key == "WARNING_CFLAGS") compilerFlags.add (configSettings[key].unquoted());
  902. }
  903. out << addToCMakeVariable ("CMAKE_CXX_FLAGS", compilerFlags.joinIntoString (" ")) << newLine
  904. << addToCMakeVariable ("CMAKE_C_FLAGS", "${CMAKE_CXX_FLAGS}") << newLine
  905. << newLine;
  906. out << "endif (" << buildTypeCondition << ")" << newLine
  907. << newLine;
  908. }
  909. }
  910. //==============================================================================
  911. JUCE_DECLARE_NON_COPYABLE (CLionProjectExporter)
  912. };