Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

setCompilerOptionMap

クラス: coder.make.BuildTool
名前空間: coder.make

選択したビルド ツール (コンパイラ) に C/C++ 言語標準とコンパイラ オプションを設定します。

構文

h.setCompilerOptionMap(std,opts);

説明

h.setCompilerOptionMap(std,opts); は特定の coder.make.BuildTool オブジェクトの C/C++ 言語標準と対応するコンパイラのオプションを coder.make.ToolchainInfo.BuildTools に設定します。

入力引数

すべて展開する

coder.make.BuildToolオブジェクトのオブジェクト ハンドル。変数で指定します。

例: tool

BuildTool 定義内のコンパイラの C/C++ 言語標準。文字ベクトルとして指定します。

std 値に次のいずれかを使用します。

  • 'C89/C90 (ANSI)'

  • 'C99 (ISO)'

  • 'C++03 (ISO)'

データ型: char

特定の BuildTool 名に対応するコンパイラ オプションと C/C++ 言語標準の選択。文字ベクトルとして指定します。次の表に、Intel ツールチェーンに対するサンプル値の組み合わせを示します。

ビルド ツール名 (コンパイラ)

std 値

opts 値

'Intel C Compiler'

'C99 (ISO)'

Windows®'/Qstd=c99'

UNIX®'-std=c99'

'Intel C++ Compiler'

'C++03 (ISO)'

Windows 版 '/Qstd=c++0x'

UNIX 版 '-std=c++0x'

Intel 関連のオプションの詳細については、https://software.intel.com/en-us/articles/iso-iec-standards-language-conformance-for-intel-c-compiler を参照してください。

データ型: char

次のバージョンの intel_tc.m ファイルはMATLAB® Coder™ ビルド プロセスへのカスタム ツールチェーンの追加の例と異なります。この例は、C_STANDARD_OPTS マクロと CPP_STANDARD_OPTS マクロを定義して、マクロの値を setCompilerOptionMap メソッドで設定し、ビルド構成でマクロを適用する方法を示しています。

C/C++ STANDARD_OPTS マクロの定義

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adding a build tool to ToolchainInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function tc = intel_tc
%INTEL_TC Creates an Intel v14 ToolchainInfo object.
% This file can be used as a template to define other toolchains on Windows.

% Copyright 2012-2016 The MathWorks, Inc.

tc = coder.make.ToolchainInfo('BuildArtifact', 'nmake makefile');
tc.Name             = 'Intel v14 | nmake makefile (64-bit Windows)';
tc.Platform         = 'win64';
tc.SupportedVersion = '14';

tc.addAttribute('TransformPathsWithSpaces');
tc.addAttribute('RequiresCommandFile');
tc.addAttribute('RequiresBatchFile');

% ------------------------------
% Setup
% ------------------------------
% Below we are using %ICPP_COMPILER14% as root folder where Intel Compiler is installed.
% You can either set an environment variable or give full path to the
% compilervars.bat file
tc.ShellSetup{1} = 'call %ICPP_COMPILER14%\bin\compilervars.bat intel64';


% ------------------------------
% Macros
% ------------------------------
tc.addMacro('MW_EXTERNLIB_DIR',     ['$(MATLAB_ROOT)\extern\lib\' tc.Platform '\microsoft']);
tc.addMacro('MW_LIB_DIR',           ['$(MATLAB_ROOT)\lib\' tc.Platform]);
tc.addMacro('CFLAGS_ADDITIONAL',    '-D_CRT_SECURE_NO_WARNINGS');
tc.addMacro('CPPFLAGS_ADDITIONAL',  '-EHs -D_CRT_SECURE_NO_WARNINGS');
tc.addMacro('LIBS_TOOLCHAIN',       '$(conlibs)');
tc.addMacro('CVARSFLAG',            '');

tc.addIntrinsicMacros({'ldebug', 'conflags', 'cflags'});
tc.addIntrinsicMacros({'C_STANDARD_OPTS', 'CPP_STANDARD_OPTS'});

% ------------------------------
% C Compiler
% ------------------------------
 
tool = tc.getBuildTool('C Compiler');

tool.setName(           'Intel C Compiler');
tool.setCommand(        'icl');
tool.setPath(           '');

tool.setDirective(      'IncludeSearchPath',    '-I');
tool.setDirective(      'PreprocessorDefine',   '-D');
tool.setDirective(      'OutputFlag',           '-Fo');
tool.setDirective(      'Debug',                '-Zi');

tool.setFileExtension(  'Source',               '.c');
tool.setFileExtension(  'Header',               '.h');
tool.setFileExtension(  'Object',               '.obj');

tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

tool.setCompilerOptionMap('C99 (ISO)', '/Qstd=c99');

% ------------------------------
% C++ Compiler
% ------------------------------

tool = tc.getBuildTool('C++ Compiler');

tool.setName(           'Intel C++ Compiler');
tool.setCommand(        'icl');
tool.setPath(           '');

tool.setDirective(      'IncludeSearchPath',  	'-I');
tool.setDirective(      'PreprocessorDefine', 	'-D');
tool.setDirective(      'OutputFlag',           '-Fo');
tool.setDirective(      'Debug',                '-Zi');

tool.setFileExtension(  'Source',               '.cpp');
tool.setFileExtension(  'Header',               '.hpp');
tool.setFileExtension(  'Object',               '.obj');

tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

tool.setCompilerOptionMap('C99 (ISO)', '/Qstd=c++0x');

% ------------------------------
% Linker
% ------------------------------

tool = tc.getBuildTool('Linker');

tool.setName(           'Intel C/C++ Linker');
tool.setCommand(        'xilink');
tool.setPath(           '');

tool.setDirective(      'Library',              '-L');
tool.setDirective(      'LibrarySearchPath',    '-I');
tool.setDirective(      'OutputFlag',           '-out:');
tool.setDirective(      'Debug',                '');

tool.setFileExtension(  'Executable',           '.exe');
tool.setFileExtension(  'Shared Library',       '.dll');

tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

% ------------------------------
% C++ Linker
% ------------------------------

tool = tc.getBuildTool('C++ Linker');

tool.setName(           'Intel C/C++ Linker');
tool.setCommand(        'xilink');
tool.setPath(           '');

tool.setDirective(      'Library',              '-L');
tool.setDirective(      'LibrarySearchPath',    '-I');
tool.setDirective(      'OutputFlag',           '-out:');
tool.setDirective(      'Debug',                '');

tool.setFileExtension(  'Executable',           '.exe');
tool.setFileExtension(  'Shared Library',       '.dll');

tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

% ------------------------------
% Archiver
% ------------------------------

tool = tc.getBuildTool('Archiver');

tool.setName(           'Intel C/C++ Archiver');
tool.setCommand(        'xilib');
tool.setPath(           '');
tool.setDirective(      'OutputFlag',           '-out:');
tool.setFileExtension(  'Static Library',       '.lib');
tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');

% ------------------------------
% Builder
% ------------------------------

tc.setBuilderApplication(tc.Platform);

% --------------------------------------------
% BUILD CONFIGURATIONS
% --------------------------------------------

optimsOffOpts    = {'/c /Od'};
optimsOnOpts     = {'/c /O2'};
cCompilerOpts    = '$(cflags) $(CVARSFLAG) $(CFLAGS_ADDITIONAL) $(C_STANDARD_OPTS) ';
cppCompilerOpts  = '$(cflags) $(CVARSFLAG) $(CPPFLAGS_ADDITIONAL) $(CPP_STANDARD_OPTS)';
linkerOpts       = {'$(ldebug) $(conflags) $(LIBS_TOOLCHAIN)'};
sharedLinkerOpts = horzcat(linkerOpts, '-dll -def:$(DEF_FILE)');
archiverOpts     = {'/nologo'};

% Get the debug flag per build tool
debugFlag.CCompiler   = '$(CDEBUG)';   
debugFlag.CppCompiler = '$(CPPDEBUG)';
debugFlag.Linker      = '$(LDDEBUG)';  
debugFlag.CppLinker   = '$(CPPLDDEBUG)';  
debugFlag.Archiver    = '$(ARDEBUG)';  

% Set the toolchain flags for 'Faster Builds' build configuration

cfg = tc.getBuildConfiguration('Faster Builds');
cfg.setOption( 'C Compiler',                horzcat(cCompilerOpts,   optimsOffOpts));
cfg.setOption( 'C++ Compiler',              horzcat(cppCompilerOpts, optimsOffOpts));
cfg.setOption( 'Linker',                    linkerOpts);
cfg.setOption( 'C++ Linker',                linkerOpts);
cfg.setOption( 'Shared Library Linker',     sharedLinkerOpts);
cfg.setOption( 'Archiver',                  archiverOpts);

% Set the toolchain flags for 'Faster Runs' build configuration

cfg = tc.getBuildConfiguration('Faster Runs');
cfg.setOption( 'C Compiler',                horzcat(cCompilerOpts,   optimsOnOpts));
cfg.setOption( 'C++ Compiler',              horzcat(cppCompilerOpts, optimsOnOpts));
cfg.setOption( 'Linker',                    linkerOpts);
cfg.setOption( 'C++ Linker',                linkerOpts);
cfg.setOption( 'Shared Library Linker',     sharedLinkerOpts);
cfg.setOption( 'Archiver',                  archiverOpts);

% Set the toolchain flags for 'Debug' build configuration

cfg = tc.getBuildConfiguration('Debug');
cfg.setOption( 'C Compiler',              	horzcat(cCompilerOpts,   optimsOffOpts, debugFlag.CCompiler));
cfg.setOption( 'C++ Compiler',          	horzcat(cppCompilerOpts, optimsOffOpts, debugFlag.CppCompiler));
cfg.setOption( 'Linker',                	horzcat(linkerOpts,       debugFlag.Linker));
cfg.setOption( 'C++ Linker',               	horzcat(linkerOpts,       debugFlag.CppLinker));
cfg.setOption( 'Shared Library Linker',  	horzcat(sharedLinkerOpts, debugFlag.Linker));
cfg.setOption( 'Archiver',              	horzcat(archiverOpts,     debugFlag.Archiver));

tc.setBuildConfigurationOption('all', 'Download',      '');
tc.setBuildConfigurationOption('all', 'Execute',       '');
tc.setBuildConfigurationOption('all', 'Make Tool',     '-f $(MAKEFILE)');

バージョン履歴

R2013a で導入