Add support for setting C++ version for build module compilation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -26,11 +26,42 @@ namespace Flax.Build.NativeCpp
|
||||
SmallCode
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The compilation optimization hint.
|
||||
/// </summary>
|
||||
public enum CppVersion
|
||||
{
|
||||
/// <summary>
|
||||
/// C++14
|
||||
/// </summary>
|
||||
Cpp14,
|
||||
|
||||
/// <summary>
|
||||
/// C++17
|
||||
/// </summary>
|
||||
Cpp17,
|
||||
|
||||
/// <summary>
|
||||
/// C++20
|
||||
/// </summary>
|
||||
Cpp20,
|
||||
|
||||
/// <summary>
|
||||
/// The latest version supported by the compiler.
|
||||
/// </summary>
|
||||
Latest,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The C++ compilation environment required to build source files in the native modules.
|
||||
/// </summary>
|
||||
public class CompileEnvironment : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// C++ standard version to use for compilation.
|
||||
/// </summary>
|
||||
public CppVersion CppVersion = CppVersion.Cpp14;
|
||||
|
||||
/// <summary>
|
||||
/// Selects a predefined set of options that affect the size and speed of generated code.
|
||||
/// </summary>
|
||||
@@ -131,6 +162,7 @@ namespace Flax.Build.NativeCpp
|
||||
{
|
||||
var clone = new CompileEnvironment
|
||||
{
|
||||
CppVersion = CppVersion,
|
||||
FavorSizeOrSpeed = FavorSizeOrSpeed,
|
||||
EnableExceptions = EnableExceptions,
|
||||
RuntimeTypeInfo = RuntimeTypeInfo,
|
||||
|
||||
@@ -284,7 +284,21 @@ namespace Flax.Build.Platforms
|
||||
commonArgs.Add("-pipe");
|
||||
commonArgs.Add("-x");
|
||||
commonArgs.Add("c++");
|
||||
commonArgs.Add("-std=c++14");
|
||||
|
||||
// C++ version
|
||||
switch (compileEnvironment.CppVersion)
|
||||
{
|
||||
case CppVersion.Cpp14:
|
||||
commonArgs.Add("-std=c++14");
|
||||
break;
|
||||
case CppVersion.Cpp17:
|
||||
case CppVersion.Latest:
|
||||
commonArgs.Add("-std=c++17");
|
||||
break;
|
||||
case CppVersion.Cpp20:
|
||||
commonArgs.Add("-std=c++20");
|
||||
break;
|
||||
}
|
||||
|
||||
commonArgs.Add("-Wdelete-non-virtual-dtor");
|
||||
commonArgs.Add("-fno-math-errno");
|
||||
|
||||
@@ -433,6 +433,23 @@ namespace Flax.Build.Platforms
|
||||
// Compile Without Linking
|
||||
commonArgs.Add("/c");
|
||||
|
||||
// C++ version
|
||||
switch (compileEnvironment.CppVersion)
|
||||
{
|
||||
case CppVersion.Cpp14:
|
||||
commonArgs.Add("/std:c++14");
|
||||
break;
|
||||
case CppVersion.Cpp17:
|
||||
commonArgs.Add("/std:c++17");
|
||||
break;
|
||||
case CppVersion.Cpp20:
|
||||
commonArgs.Add("/std:c++20");
|
||||
break;
|
||||
case CppVersion.Latest:
|
||||
commonArgs.Add("/std:c++latest");
|
||||
break;
|
||||
}
|
||||
|
||||
// Generate Intrinsic Functions
|
||||
if (compileEnvironment.IntrinsicFunctions)
|
||||
commonArgs.Add("/Oi");
|
||||
|
||||
Reference in New Issue
Block a user