When constructing custom commands we need to supply our own pattern to the buildsystem
This is done by overriding the 3 base::Target::Config
strings
base::Target::Config config;
config.pch_command = "{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_compile_flags} {compile_flags} -o {output} -c {input}";
config.compile_command = "{compiler} {preprocessor_flags} {include_dirs} {common_compile_flags} {pch_object_flags} {compile_flags} -o {output} -c {input}";
config.link_command = "{cpp_compiler} {link_flags} {compiled_sources} -o {output} {lib_dirs} {lib_deps}";
The following {}
commands are available to pch_command
, compile_command
and link_command
See build.cpp Target::Build API
include_dirs
: Aggregated include directories for header fileslib_dirs
: Aggregated lib directories for external librariespreprocessor_flags
: Preprocessor definitionscommon_compile_flags
: Common compile flags forPCH
,ASM
,C
andCPP
fileslink_flags
: Flags supplied during linkingasm_compiler
: Assembly compilerc_compiler
: C compilercpp_compiler
: C++ compilerarchiver
: Archiver for Static Librarieslinker
: Linker usually used during the Linking phase / Library creation
NOTE, When PCH is not used these options are aggregated to an empty string ("")
pch_compile_flags
: PCH flags applied when compiling a PCHpch_object_flags
: PCH flags applied to object files after compiling a PCHpch_object_output
: [Specific use case] Certain compilers (MSVC) require source/object with the header inputs.input_source
(mentioned below) is added locally duringpch_command
translation whereaspch_object_output
is added globally. (However thepch_object_output
will most likely be used bylink_command
translation if added by the user.)
See CompilePch::ConstructCompileCommand API
compiler
: Selects CPP compiler if project contains CPP source else C compilercompile_flags
: Selects CPP flags if project contains CPP source else C flagsoutput
: PCH output pathinput
: PCH input generated path (Headers are aggregated into a .h file)input_source
: PCH input source generated path (Dummy source file with corresponding extension, .c for C source and .cpp for C++ source)
See CompileObject::CacheCompileCommands API
compiler
: Automatically chosen amongst ASM, C and C++ toolchain compilercompile_flags
: Automatically chosen amongst{c/cpp}_flags
output
: Object fileinput
: Input source file
See LinkTarget::CacheLinkCommand API
output
: Generated target asTarget::GetName()
compiled_sources
: Aggregated object fileslib_deps
: External libraries and full path libraries