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.

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