|
| 1 | +# Properties |
| 2 | + |
| 3 | +The |
| 4 | +[MSBuild properties](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-properties) |
| 5 | +described on this page are used by the Zig SDK. These properties can all be set |
| 6 | +in `PropertyGroup`s in your project file. Most of them should have sensible |
| 7 | +defaults for new projects; a few (such as `TreatWarningsAsErrors` and |
| 8 | +`SymbolVisibility`) have defaults that are not quite as sensible for unfortunate |
| 9 | +historical reasons. |
| 10 | + |
| 11 | +## Project Setup |
| 12 | + |
| 13 | +* `CompilerMode` (`C`, `Cxx`, `Zig`): The language to compile the project as. |
| 14 | + This is inferred from the project file extension by default. |
| 15 | +* `AssemblyName`: Name of the project. By default, this is set to the file name |
| 16 | + of the project file. Used to compute the final binary name (e.g. `foo` becomes |
| 17 | + `libfoo.so`). |
| 18 | +* `OutputType` (`Exe`, `Library`): Output binary type. Defaults to `Library`. |
| 19 | +* `IsTestable` (`true`, `false`): Enable/disable `dotnet test` for Zig projects. |
| 20 | + Defaults to `true`. |
| 21 | +* `IsPackable` (`true`, `false`): Enable/disable `dotnet pack`. Defaults to |
| 22 | + `true`. |
| 23 | +* `IsPublishable` (`true`, `false`): Enable/disable `dotnet publish`. Defaults |
| 24 | + to `true`. |
| 25 | +* `DefaultSources` (`true`, `false`): Enable/disable default `Compile` item |
| 26 | + includes. Defaults to `true`. |
| 27 | +* `Deterministic` (`true`, `false`): Enable/disable deterministic builds. Among |
| 28 | + other things, this will try to prevent the compiler from using absolute paths |
| 29 | + and will prevent usage of certain problematic language features like |
| 30 | + `__TIME__`. Defaults to `true`. |
| 31 | +* `EditorSupport` (`true`, `false`): Enable/disable editor support. For C/C++ |
| 32 | + projects, this means generating a `compile_commands.json` compilation database |
| 33 | + in `IntermediateOutputPath`. Defaults to `true`. |
| 34 | +* `FormatOnBuild` (`true`, `false`): Enable/disable formatting source code into |
| 35 | + canonical style on build in Zig projects. Defaults to `false`. |
| 36 | + |
| 37 | +## Package Information |
| 38 | + |
| 39 | +* `Product`: Human-friendly product name for the package. Defaults to the value |
| 40 | + of `AssemblyName`. |
| 41 | +* `Authors`: A list of package authors. Defaults to the value of `AssemblyName`. |
| 42 | +* `Description`: Brief description of the package. Defaults to |
| 43 | + `Package Description`. |
| 44 | +* `Version`: Package version in [Semantic Versioning 2.0.0](https://semver.org) |
| 45 | + form. Defaults to `1.0.0`. |
| 46 | +* `Copyright`: Copyright notice for the package. Unset by default. |
| 47 | +* `PackageLicenseExpression`: [SPDX](https://spdx.org/licenses) license |
| 48 | + identifier for the package. Unset by default. |
| 49 | +* `PackageProjectUrl`: Website URL associated with the package. Unset by |
| 50 | + default. |
| 51 | +* `RepositoryUrl`: Source code repository URL for the package. Unset by default. |
| 52 | + |
| 53 | +## Preprocessor |
| 54 | + |
| 55 | +* `PublicHeadersPath`: Can be set to a directory containing public C/C++ |
| 56 | + headers. These headers will be included in the NuGet package and will flow to |
| 57 | + dependent projects. This directory will also be treated as an |
| 58 | + `IncludeDirectory`. Unset by default. |
| 59 | +* `DefineConstants`: A comma-separated list of preprocessor macros to define. |
| 60 | + Each entry can be a simple name or an assignment of the form `NAME=VALUE`. |
| 61 | + These macros are passed to the compiler with the `-D` flag. Note that this |
| 62 | + applies to Zig as well, not just C/C++. |
| 63 | +* `CompilerDefines` (`true`, `false`): Enable/disable adding some implicit |
| 64 | + `DefineConstants` macros that describe the Zig compiler version. Defaults to |
| 65 | + `true`. |
| 66 | +* `PlatformDefines` (`true`, `false`): Enable/disable adding some implicit |
| 67 | + `DefineConstants` macros that describe the target platform characteristics. |
| 68 | + Defaults to `true`. |
| 69 | +* `ConfigurationDefines` (`true`, `false`): Enable/disable adding some implicit |
| 70 | + `DefineConstants` macros that describe the build configuration (`Debug`, |
| 71 | + `ReleaseFast`, etc). Defaults to `true`. |
| 72 | +* `PackageDefines` (`true`, `false`): Enable/disable adding some implicit |
| 73 | + `DefineConstants` macros that describe the project being built. Defaults to |
| 74 | + `true`. |
| 75 | + |
| 76 | +## Language Features |
| 77 | + |
| 78 | +* `ZigVersion` (`major.minor.patch`): The version of the Zig compiler toolset to |
| 79 | + use. Defaults to the latest version known to the Zig SDK package that is in |
| 80 | + use. |
| 81 | +* `LanguageStandard`: The language standard used for C/C++ projects. Passed to |
| 82 | + Clang's `-std` flag. Defaults to the latest standards known to the compiler |
| 83 | + version that `ZigVersion` defaults to. |
| 84 | +* `AccessControl` (`true`, `false`): Enable/disable access control in C++ |
| 85 | + projects. Defaults to `true`. |
| 86 | +* `BlockExtensions` (`true`, `false`): Enable/disable Clang's block language |
| 87 | + extensions. Defaults to `false`. |
| 88 | +* `CxxExceptions` (`true`, `false`): Enable/disable C++ exceptions. In C |
| 89 | + projects, this controls whether the C code will be unwindable by C++ |
| 90 | + exceptions. Defaults to `true`. |
| 91 | +* `CxxReflection` (`true`, `false`): Enable/disable generating C++ run-time type |
| 92 | + information. This feature is required for some uses of `dynamic_cast`. |
| 93 | + Defaults to `true`. |
| 94 | +* `MicrosoftExtensions` (`true`, `false`): Enable/disable a variety of |
| 95 | + Microsoft C/C++ extensions. Defaults to `false`, but note that the compiler |
| 96 | + itself always enables some parts of this when targeting Windows as Windows |
| 97 | + headers require it. |
| 98 | + |
| 99 | +## Static Analysis |
| 100 | + |
| 101 | +* `EnforceCodeStyleInBuild` (`true`, `false`): Enable/disable checking that |
| 102 | + source code is in the canonical style during build in Zig projects. Defaults |
| 103 | + to `false`. |
| 104 | +* `ConsumptionAnalysis` (`true`, `false`): Enable/disable static analysis with |
| 105 | + [consumption and type state annotations](https://clang.llvm.org/docs/AttributeReference.html#consumed-annotation-checking) |
| 106 | + in C/C++ projects. Defaults to `true`. |
| 107 | +* `DocumentationAnalysis` (`true`, `false`): Enable/disable |
| 108 | + [Doxygen](https://doxygen.nl) documentation comment checking in C/C++ |
| 109 | + projects. Defaults to `false`. |
| 110 | +* `NullabilityAnalysis` (`true`, `false`): Enable/disable static analysis with |
| 111 | + [nullability annotations](https://clang.llvm.org/docs/analyzer/developer-docs/nullability.html) |
| 112 | + in C/C++ projects. Defaults to `true`. |
| 113 | +* `TagAnalysis` (`true`, `false`): Enable/disable static analysis with |
| 114 | + [type tag annotations](https://clang.llvm.org/docs/AttributeReference.html#type-safety-checking) |
| 115 | + in C/C++ projects. Defaults to `true`. |
| 116 | +* `ThreadingAnalysis` (`true`, `false`): Enable/disable static analysis with |
| 117 | + [thread safety annotations](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) |
| 118 | + in C/C++ projects. Defaults to `true`. |
| 119 | +* `TrustAnalysis` (`true`, `false`): Enable/disable static analysis with |
| 120 | + [trusted computing base annotations](https://clang.llvm.org/docs/AttributeReference.html#enforce-tcb) |
| 121 | + in C/C++ projects. Defaults to `true`. |
| 122 | +* `WarningLevel` (`0`-`4`): How aggressively the compiler should analyze C/C++ |
| 123 | + projects for potentially problematic code. `0` disables warnings completely; |
| 124 | + `4` enables all warnings, including a few controversial ones. Defaults to `3`. |
| 125 | +* `DisableWarnings`: A comma-separated list of |
| 126 | + [warning names](https://clang.llvm.org/docs/DiagnosticsReference.html) (e.g. |
| 127 | + `cast-align`) to disable in C/C++ projects. Unset by default. |
| 128 | +* `TreatWarningsAsErrors` (`true`, `false`): Enable/disable reporting warnings |
| 129 | + as errors in C/C++ projects. Defaults to `false`. |
| 130 | + |
| 131 | +## Code Generation |
| 132 | + |
| 133 | +* `Configuration` (`Debug`, `Release`): Specifies the overarching configuration. |
| 134 | + When `Release` is specified, `ReleaseMode` comes into effect. Defaults to |
| 135 | + `Debug`. Usually specified by the user as e.g. `dotnet build -c Release`. |
| 136 | +* `DebugSymbols` (`true`, `false`): Enable/disable emitting debug symbols. |
| 137 | + Defaults to `true` if `Configuration` is `Debug`; otherwise, `false`. |
| 138 | +* `ReleaseMode` (`Fast`, `Safe`, `Small`): The |
| 139 | + [build mode](https://ziglang.org/documentation/master/#Build-Mode) to use when |
| 140 | + `Configuration` is set to `Release`. Defaults to `Fast`. |
| 141 | +* `FastMath` (`true`, `false`): Enable/disable certain lossy floating point |
| 142 | + optimizations that may not be standards-compliant. Defaults to `false`. |
| 143 | +* `LinkTimeOptimization` (`true`, `false`): Enable/disable link-time |
| 144 | + optimization. Note that link-time optimization is known not to work well on |
| 145 | + some targets and so should be used selectively. Defaults to `false`. |
| 146 | +* `SymbolExports` (`Used`, `All`): Specifies whether to export all public |
| 147 | + symbols or only those that are needed to link successfully. This only applies |
| 148 | + when building executables. Defaults to `Used`. |
| 149 | +* `SymbolVisibility` (`Default`, `Hidden`): Specifies the symbol visibility in |
| 150 | + C/C++ projects when `__attribute__((visibility(...)))` is not specified. |
| 151 | + `Default` (the default 😉) means public, while `Hidden` means private. |
| 152 | +* `ExecutableStack` (`true`, `false`): Enables/disables marking the stack as |
| 153 | + executable for the resulting binary. Executable stack memory is a significant |
| 154 | + security risk. Defaults to `false`. |
| 155 | +* `EagerBinding` (`true`, `false`): Enables/disables eager binding of symbols |
| 156 | + when performing dynamic linking at run time. Eager binding has security |
| 157 | + benefits, especially in combination with `RelocationHardening`. It is also |
| 158 | + more reliable if calling external functions from signal handlers. Defaults to |
| 159 | + `true`. |
| 160 | +* `RelocationHardening` (`true`, `false`): Enables/disables marking relocations |
| 161 | + as read-only. This has security benefits, especially in combination with |
| 162 | + `EagerBinding`. Defaults to `true`. |
| 163 | +* `Sanitizers`: A semicolon-separated list of |
| 164 | + [sanitizers](https://github.com/google/sanitizers) to instrument code with. |
| 165 | + Currently, only `thread` is supported. Unset by default. |
| 166 | + |
| 167 | +## Cross-Compilation |
| 168 | + |
| 169 | +* `RuntimeIdentifier`: Specifies the runtime identifier (i.e. platform) to |
| 170 | + target. When unset, `Build` and `Clean` will run for all runtime identifiers |
| 171 | + specified in `RuntimeIdentifiers`. Usually specified by the user as e.g. |
| 172 | + `dotnet build -r linux-x64`. Unset by default. |
| 173 | +* `RuntimeIdentifiers`: A semicolon-separated list of runtime identifiers that |
| 174 | + the project supports. All targets on this list will be cross-compiled as |
| 175 | + necessary. Defaults to all targets that the Zig compiler has known-good |
| 176 | + support for. |
| 177 | +* `UseEmulator` (`true`, `false`): Enable/disable usage of an appropriate binary |
| 178 | + emulator when cross-compiling. Defaults to `true`. |
0 commit comments