cc
The cc module supports building C, C++, Objective-C, and Objective-C++ with Clang, GCC, Microsoft Visual C++, and MinGW on Linux, macOS, and Windows.
Settings
Configure the cc module using the following settings specified in the toolset that initializes the module or overridden in individual buildfiles throughout the project:
architecturesets the architecture (x86_64, armv7, arm64, etc);assertionsis true to enable assetsdebugis true to enable debuggingexceptionsis true to enable C++ exceptionsfast_floating_pointis true to enable fast floating point optimizationsgenerate_map_fileis true to generate a map file;incremental_linkingis true to enable incremental linkinglink_time_code_generationis true to enable link time code generationminimal_rebuildis true to enable minimal rebuilds, false to disableoptimizationis 0 for no optimization, 3 for full optimizationpre_compiled_headersis true to enable pre-compiled headerspreprocessis true to preprocess source instead of compilingprofilingis to compile with profiling hooksrun_time_checksis true to enable run-time checks false to disableruntime_librarysets the standard library used at runtimerun_time_type_infois true to enable run-time type informationstack_sizesets the size of the initial stackstandardsets the C/C++ standardstring_poolingis true to enable string poolingstripis true to enable strippingverbose_linkingis true to enable verbose messages when linkingwarning_levelis 0 for no warnings, 3 for full warningswarnings_as_errorsis true to treat warnings as errors
Prototypes
Executable
-
Links one or more libraries and object files into a single executable.
-
Expected dependencies:
StaticLibrary,Cc,Cxx,ObjC,ObjCxx -
The executable’s identifier should be without any platform specific extension like .exe. The underlying rule decorates the filename as necessary.
-
The executable target’s identifier remains platform independent and portable so that it can be referenced by other buildfiles and/or build scripts without the need to add additional code to decorate the filename all over the place.
-
The
librariesattribute can be set to a list (table) of libraries to link with on the command line. The directories containing these libraries must be added separately to the toolset’s settings through thelibrary_directoriesattribute or made available to the linker through some other means (e.g. by being in the default library search path for that toolchain).
forge:Executable '${bin}/forge' {
'${lib}/forge_${architecture}';
'${lib}/forge_lua_${architecture}';
'${lib}/process_${architecture}';
'${lib}/luaxx_${architecture}';
'${lib}/cmdline_${architecture}';
'${lib}/error_${architecture}';
'${lib}/assert_${architecture}';
'${lib}/liblua_${architecture}';
'${lib}/boost_filesystem_${architecture}';
'${lib}/boost_system_${architecture}';
libraries = libraries;
forge:Cxx '${obj}/%1' {
defines = {
'BOOST_ALL_NO_LIB';
('BUILD_VERSION="\\"%s\\""'):format( version );
};
'Application.cpp',
'main.cpp'
};
};
DynamicLibrary
- As per
Executableabove but links a dynamic library instead of an executable.
StaticLibrary
- Archives one or more object files into a single static library.
- Expected dependencies:
Cc,Cxx,ObjC,ObjCxx
Cc, Cxx, ObjC, ObjCxx
-
Compile C, C++, Objective-C, or Objective-C++ respectively
-
Expected dependencies: Source files of the respective language
-
The
definesattribute can be set to a list of preprocessor macros to pass on the command line. These can be of the formIDENTIFIERorIDENTIFIER=...but take care with quoting of strings as they must pass through Lua before being formatted onto the command line (e.g. backslash characters will be interpreted as escape sequences and should themselves be escaped).
Compilers
clang
framework_directorieslists the directories to search for frameworksgenerate_dsym_bundleis true to generate dSYM bundle for debug symbolsobjc_arcis true to enable Objective-C ARCobjc_modulesis true to enable Objective-C modules
gcc
msvc
subsystemsets the Windows subsystem (BOOT_APPLICATION, CONSOLE, EFI_APPLICATION, EFI_BOOT_SERVICE_DRIVER, EFI_ROM, EFI_RUNTIME_DRIVER, NATIVE, POSIX, WINDOWS[,major[.minor]). See /SUBSYSTEM for more details.
mingw
Preprocessor And Linker Debugging
It is possible to generate preprocessed files from source files rather
than passing them to the the compiler. This is done by setting the settings
field preprocess to true.
It is also possible to set the linker to generate verbose output about the
libraries it is searching for symbols and why it is searching them. This is
done by setting the settings field verbose_linking to true.