ruki 3 年 前
コミット
b3ecfc47fb

+ 68 - 0
manual/project_target.md

@@ -1603,6 +1603,24 @@ Add compilation options to c/c++ code at the same time
 
 Add compilation options only to c++ code
 
+##### Add compiler-specific flags
+
+In version 2.7.3, we have improved all flags adding interfaces to specify flags only for specific compilers, e.g.
+
+```lua
+add_cxxflags("clang::-stdlib=libc++")
+add_cxxflags("gcc::-stdlib=libc++")
+```
+
+Or.
+
+```lua
+add_cxxflags("-stdlib=libc++", {tools = "clang"})
+add_cxxflags("-stdlib=libc++", {tools = "gcc"})
+```
+
+!> Not just for compile flags, but also for link flags such as add_ldflags, which also work.
+
 ### target:add_mflags
 
 #### Add objc compilation flags
@@ -3076,3 +3094,53 @@ target("test")
 ```
 
 ![](https://xmake.io/assets/img/manual/filegroup3.png)
+
+### target:set_exceptions
+
+#### Enabling or disabling exceptions
+
+We can configure C++/Objc exceptions to be enabled and disabled via this configuration.
+
+Normally, if we configure them via the add_cxxflags interface, it would be cumbersome for the compiler to handle them separately, depending on the platform.
+
+For example
+
+```lua
+    on_config(function (target)
+        if (target:has_tool("cxx", "cl")) then
+            target:add("cxflags", "/EHsc", {force = true})
+            target:add("defines", "_HAS_EXCEPTIONS=1", {force = true})
+        elseif(target:has_tool("cxx", "clang") or target:has_tool("cxx", "clang-cl")) then
+            target:add("cxflags", "-fexceptions", {force = true})
+            target:add("cxflags", "-fcxx-exceptions", {force = true})
+        end
+    end)
+```
+
+And with this interface, we can abstract to configure them in a compiler-independent way.
+
+Enabling C++ exceptions:
+
+```lua
+set_exceptions("cxx")
+```
+
+Disable C++ exceptions:
+
+```lua
+set_exceptions("no-cxx")
+```
+
+We can also configure to turn on objc exceptions at the same time.
+
+```lua
+set_exceptions("cxx", "objc")
+```
+
+or disable them.
+
+```lua
+set_exceptions("no-cxx", "no-objc")
+```
+
+Xmake will automatically adapt the flags internally to the different compilers.

+ 39 - 0
mirror/manual/project_target.html

@@ -1471,6 +1471,16 @@ target("demo")
 <h3 id="targetadd_cxxflags">target:add_cxxflags</h3>
 <h4 id="addccompilationflags">Add c++ compilation flags</h4>
 <p>Add compilation options only to c++ code</p>
+<h5 id="addcompilerspecificflags">Add compiler-specific flags</h5>
+<p>In version 2.7.3, we have improved all flags adding interfaces to specify flags only for specific compilers, e.g.</p>
+<pre><code class="lang-lua">add_cxxflags("clang::-stdlib=libc++")
+add_cxxflags("gcc::-stdlib=libc++")
+</code></pre>
+<p>Or.</p>
+<pre><code class="lang-lua">add_cxxflags("-stdlib=libc++", {tools = "clang"})
+add_cxxflags("-stdlib=libc++", {tools = "gcc"})
+</code></pre>
+<p>!> Not just for compile flags, but also for link flags such as add_ldflags, which also work.</p>
 <h3 id="targetadd_mflags">target:add_mflags</h3>
 <h4 id="addobjccompilationflags">Add objc compilation flags</h4>
 <p>Add compilation options only to objc code</p>
@@ -2513,6 +2523,35 @@ $ xmake run -g bench*
     add_filegroups("group1/group2", {rootdir = "... /... /... /... /", mode = "plain"})
 </code></pre>
 <p><img src="https://xmake.io/assets/img/manual/filegroup3.png" alt=""></p>
+<h3 id="targetset_exceptions">target:set_exceptions</h3>
+<h4 id="enablingordisablingexceptions">Enabling or disabling exceptions</h4>
+<p>We can configure C++/Objc exceptions to be enabled and disabled via this configuration.</p>
+<p>Normally, if we configure them via the add_cxxflags interface, it would be cumbersome for the compiler to handle them separately, depending on the platform.</p>
+<p>For example</p>
+<pre><code class="lang-lua">    on_config(function (target)
+        if (target:has_tool("cxx", "cl")) then
+            target:add("cxflags", "/EHsc", {force = true})
+            target:add("defines", "_HAS_EXCEPTIONS=1", {force = true})
+        elseif(target:has_tool("cxx", "clang") or target:has_tool("cxx", "clang-cl")) then
+            target:add("cxflags", "-fexceptions", {force = true})
+            target:add("cxflags", "-fcxx-exceptions", {force = true})
+        end
+    end)
+</code></pre>
+<p>And with this interface, we can abstract to configure them in a compiler-independent way.</p>
+<p>Enabling C++ exceptions:</p>
+<pre><code class="lang-lua">set_exceptions("cxx")
+</code></pre>
+<p>Disable C++ exceptions:</p>
+<pre><code class="lang-lua">set_exceptions("no-cxx")
+</code></pre>
+<p>We can also configure to turn on objc exceptions at the same time.</p>
+<pre><code class="lang-lua">set_exceptions("cxx", "objc")
+</code></pre>
+<p>or disable them.</p>
+<pre><code class="lang-lua">set_exceptions("no-cxx", "no-objc")
+</code></pre>
+<p>Xmake will automatically adapt the flags internally to the different compilers.</p>
 </article>
 </body>
 </html>

+ 2 - 2
mirror/package/remote_package.html

@@ -776,7 +776,7 @@ target("test")
 target("test")
     add_packages("sfml", {components = "graphics")
 </code></pre>
-<p>! > Note: In addition to configuring the list of available components, we also need to configure each component in detail for it to work properly, so it is usually used in conjunction with the <code>on_componment</code> interface.</p>
+<p>!> Note: In addition to configuring the list of available components, we also need to configure each component in detail for it to work properly, so it is usually used in conjunction with the <code>on_componment</code> interface.</p>
 <p>A full example of the configuration and use of package components can be found at: <a href="https://github.com/xmake-io/xmake/blob/master/tests/projects/package/components/xmake.lua">components example</a></p>
 <h4 id="set_base">set_base</h4>
 <p>This is a newly added interface in 2.6.4, through which we can inherit all the configuration of an existing package, and then rewrite some of the configuration on this basis.</p>
@@ -1027,7 +1027,7 @@ end)
 target("test")
     add_packages("sfml", {components = "graphics")
 </code></pre>
-<p>! > Note: In addition to configuring the component information, we also need to configure the list of available components in order to use it properly, so it is usually used in conjunction with the <code>add_components</code> interface.</p>
+<p>!> Note: In addition to configuring the component information, we also need to configure the list of available components in order to use it properly, so it is usually used in conjunction with the <code>add_components</code> interface.</p>
 <p>A full example of the configuration and use of package components can be found at: <a href="https://github.com/xmake-io/xmake/blob/master/tests/projects/package/components/xmake.lua">components example</a></p>
 <h5 id="configuringcompilationinformationforcomponents">Configuring compilation information for components</h5>
 <p>We can configure not only the linking information for each component, but also the compilation information for includedirs, defines etc. We can also configure each component individually.</p>

+ 42 - 6
mirror/zh-cn/manual/project_target.html

@@ -1475,19 +1475,26 @@ target("demo")
 <p>仅对c代码添加编译选项</p>
 <pre><code class="lang-lua">add_cflags("-g", "-O2", "-DDEBUG")
 </code></pre>
-<p><p class="warn"><br>所有选项值都基于gcc的定义为标准,如果其他编译器不兼容(例如:vc),xmake会自动内部将其转换成对应编译器支持的选项值。<br>用户无需操心其兼容性,如果其他编译器没有对应的匹配值,那么xmake会自动忽略器设置。<br></p>
-
-
-</p>
+<p>!> 所有选项值都基于gcc的定义为标准,如果其他编译器不兼容(例如:vc),xmake会自动内部将其转换成对应编译器支持的选项值。<br>用户无需操心其兼容性,如果其他编译器没有对应的匹配值,那么xmake会自动忽略器设置。</p>
 <p>在2.1.9版本之后,可以通过force参数来强制禁用flags的自动检测,直接传入编译器,哪怕编译器有可能不支持,也会设置:</p>
 <pre><code class="lang-lua">add_cflags("-g", "-O2", {force = true})
 </code></pre>
 <h3 id="targetadd_cxflags">target:add_cxflags</h3>
 <h4 id="cc">添加c/c++编译选项</h4>
-<p>同时对c/c++代码添加编译选项</p>
+<p>同时对c/c++代码添加编译选项,用法跟 add_cflags 一致。</p>
 <h3 id="targetadd_cxxflags">target:add_cxxflags</h3>
 <h4 id="c">添加c++编译选项</h4>
-<p>仅对c++代码添加编译选项</p>
+<p>仅对c++代码添加编译选项,用法跟 add_cflags 一致。</p>
+<h5 id="flags">添加特定编译器 flags</h5>
+<p>2.7.3 版本中,我们改进了所有 flags 添加接口,可以仅仅对特定编译器指定 flags,例如:</p>
+<pre><code class="lang-lua">add_cxxflags("clang::-stdlib=libc++")
+add_cxxflags("gcc::-stdlib=libc++")
+</code></pre>
+<p>或者:</p>
+<pre><code class="lang-lua">add_cxxflags("-stdlib=libc++", {tools = "clang"})
+add_cxxflags("-stdlib=libc++", {tools = "gcc"})
+</code></pre>
+<p>!> 不仅仅是编译flags,对 add_ldflags 等链接 flags,也是同样生效的。</p>
 <h3 id="targetadd_mflags">target:add_mflags</h3>
 <h4 id="objc">添加objc编译选项</h4>
 <p>仅对objc代码添加编译选项</p>
@@ -2534,6 +2541,35 @@ $ xmake run -g bench*
     add_filegroups("group1/group2", {rootdir = "../../../../", mode = "plain"})
 </code></pre>
 <p><img src="https://xmake.io/assets/img/manual/filegroup3.png" alt=""></p>
+<h3 id="targetset_exceptions">target:set_exceptions</h3>
+<h4 id="">启用或者禁用异常</h4>
+<p>我们可以通过这个配置,配置启用和禁用 C++/Objc 的异常。</p>
+<p>通常,如果我们通过 add_cxxflags 接口去配置它们,需要根据不同的平台,编译器分别处理它们,非常繁琐。</p>
+<p>例如:</p>
+<pre><code class="lang-lua">    on_config(function (target)
+        if (target:has_tool("cxx", "cl")) then
+            target:add("cxflags", "/EHsc", {force = true})
+            target:add("defines", "_HAS_EXCEPTIONS=1", {force = true})
+        elseif(target:has_tool("cxx", "clang") or target:has_tool("cxx", "clang-cl")) then
+            target:add("cxflags", "-fexceptions", {force = true})
+            target:add("cxflags", "-fcxx-exceptions", {force = true})
+        end
+    end)
+</code></pre>
+<p>而通过这个接口,我们就可以抽象化成编译器无关的方式去配置它们。</p>
+<p>开启 C++ 异常:</p>
+<pre><code class="lang-lua">set_exceptions("cxx")
+</code></pre>
+<p>禁用 C++ 异常:</p>
+<pre><code class="lang-lua">set_exceptions("no-cxx")
+</code></pre>
+<p>我们也可以同时配置开启 objc 异常。</p>
+<pre><code class="lang-lua">set_exceptions("cxx", "objc")
+</code></pre>
+<p>或者禁用它们。</p>
+<pre><code class="lang-lua">set_exceptions("no-cxx", "no-objc")
+</code></pre>
+<p>Xmake 会在内部自动根据不同的编译器,去适配对应的 flags。</p>
 </article>
 </body>
 </html>

+ 2 - 2
package/remote_package.md

@@ -1062,7 +1062,7 @@ target("test")
     add_packages("sfml", {components = "graphics")
 ```
 
-! > Note: In addition to configuring the list of available components, we also need to configure each component in detail for it to work properly, so it is usually used in conjunction with the `on_componment` interface.
+!> Note: In addition to configuring the list of available components, we also need to configure each component in detail for it to work properly, so it is usually used in conjunction with the `on_componment` interface.
 
 A full example of the configuration and use of package components can be found at: [components example](https://github.com/xmake-io/xmake/blob/master/tests/projects/package/components/xmake.lua)
 
@@ -1444,7 +1444,7 @@ target("test")
     add_packages("sfml", {components = "graphics")
 ```
 
-! > Note: In addition to configuring the component information, we also need to configure the list of available components in order to use it properly, so it is usually used in conjunction with the `add_components` interface.
+!> Note: In addition to configuring the component information, we also need to configure the list of available components in order to use it properly, so it is usually used in conjunction with the `add_components` interface.
 
 A full example of the configuration and use of package components can be found at: [components example](https://github.com/xmake-io/xmake/blob/master/tests/projects/package/components/xmake.lua)
 

+ 100 - 100
sitemap.xml

@@ -12,502 +12,502 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2022-11-07T15:45:48+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2022-11-07T15:45:48+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2022-11-07T15:45:48+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:56+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2022-11-07T15:45:48+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2022-11-07T15:45:49+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2022-11-07T15:45:49+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/remote_build.html</loc>
-  <lastmod>2022-11-07T15:45:49+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/unity_build.html</loc>
-  <lastmod>2022-11-07T15:45:49+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:57+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/distcc_build.html</loc>
-  <lastmod>2022-11-07T15:45:49+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/trybuild.html</loc>
-  <lastmod>2022-11-07T15:45:50+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/autogen.html</loc>
-  <lastmod>2022-11-07T15:45:50+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/features/build_cache.html</loc>
-  <lastmod>2022-11-07T15:45:50+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2022-11-07T15:45:50+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:58+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2022-11-07T15:45:50+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2022-11-07T15:45:51+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2022-11-07T15:45:51+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2022-11-07T15:45:51+08:00</lastmod>
+  <lastmod>2022-11-07T16:15:59+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2022-11-07T15:45:51+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2022-11-07T15:45:51+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2022-11-07T15:45:52+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2022-11-07T15:45:52+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2022-11-07T15:45:52+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2022-11-07T15:45:52+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2022-11-07T15:45:52+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2022-11-07T15:45:53+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2022-11-07T15:45:53+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2022-11-07T15:45:53+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2022-11-07T15:45:53+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2022-11-07T15:45:53+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/remote_build.html</loc>
-  <lastmod>2022-11-07T15:45:54+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/unity_build.html</loc>
-  <lastmod>2022-11-07T15:45:54+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/distcc_build.html</loc>
-  <lastmod>2022-11-07T15:45:54+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/trybuild.html</loc>
-  <lastmod>2022-11-07T15:45:54+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/autogen.html</loc>
-  <lastmod>2022-11-07T15:45:54+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/features/build_cache.html</loc>
-  <lastmod>2022-11-07T15:45:55+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2022-11-07T15:45:55+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2022-11-07T15:45:55+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2022-11-07T15:45:55+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2022-11-07T15:45:55+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2022-11-07T15:45:56+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2022-11-07T15:45:56+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2022-11-07T15:45:56+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2022-11-07T15:45:56+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2022-11-07T15:45:57+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2022-11-07T15:45:57+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2022-11-07T15:45:57+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2022-11-07T15:45:57+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2022-11-07T15:45:57+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2022-11-07T15:45:58+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2022-11-07T15:45:58+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2022-11-07T15:45:58+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2022-11-07T15:45:58+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2022-11-07T15:45:58+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2022-11-07T15:45:59+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2022-11-07T15:45:59+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2022-11-07T15:45:59+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2022-11-07T15:45:59+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2022-11-07T15:45:59+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2022-11-07T15:46:00+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2022-11-07T15:46:00+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2022-11-07T15:46:00+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2022-11-07T15:46:00+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2022-11-07T15:46:00+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2022-11-07T15:46:01+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2022-11-07T15:46:01+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2022-11-07T15:46:01+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2022-11-07T15:46:01+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2022-11-07T15:46:01+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2022-11-07T15:46:02+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2022-11-07T15:46:02+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2022-11-07T15:46:02+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2022-11-07T15:46:02+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2022-11-07T15:46:02+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2022-11-07T15:46:03+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2022-11-07T15:46:03+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2022-11-07T15:46:03+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2022-11-07T15:46:03+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2022-11-07T15:46:04+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2022-11-07T15:46:04+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2022-11-07T15:46:04+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2022-11-07T15:46:04+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2022-11-07T15:46:04+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2022-11-07T15:46:05+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2022-11-07T15:46:05+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2022-11-07T15:46:05+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2022-11-07T15:46:05+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2022-11-07T15:46:05+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2022-11-07T15:46:06+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2022-11-07T15:46:06+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2022-11-07T15:46:06+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2022-11-07T15:46:06+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2022-11-07T15:46:06+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2022-11-07T15:46:07+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2022-11-07T15:46:07+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2022-11-07T15:46:07+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2022-11-07T15:46:07+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2022-11-07T15:46:07+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2022-11-07T15:46:08+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2022-11-07T15:46:08+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2022-11-07T15:46:08+08:00</lastmod>
+  <lastmod>2022-11-07T16:16:18+08:00</lastmod>
 </url>
 
 </urlset>

+ 70 - 6
zh-cn/manual/project_target.md

@@ -1581,11 +1581,8 @@ add_undefines("DEBUG")
 add_cflags("-g", "-O2", "-DDEBUG")
 ```
 
-<p class="warn">
-所有选项值都基于gcc的定义为标准,如果其他编译器不兼容(例如:vc),xmake会自动内部将其转换成对应编译器支持的选项值。
+!> 所有选项值都基于gcc的定义为标准,如果其他编译器不兼容(例如:vc),xmake会自动内部将其转换成对应编译器支持的选项值。
 用户无需操心其兼容性,如果其他编译器没有对应的匹配值,那么xmake会自动忽略器设置。
-</p>
-
 
 在2.1.9版本之后,可以通过force参数来强制禁用flags的自动检测,直接传入编译器,哪怕编译器有可能不支持,也会设置:
 
@@ -1597,13 +1594,31 @@ add_cflags("-g", "-O2", {force = true})
 
 #### 添加c/c++编译选项
 
-同时对c/c++代码添加编译选项
+同时对c/c++代码添加编译选项,用法跟 add_cflags 一致。
 
 ### target:add_cxxflags
 
 #### 添加c++编译选项
 
-仅对c++代码添加编译选项
+仅对c++代码添加编译选项,用法跟 add_cflags 一致。
+
+##### 添加特定编译器 flags
+
+2.7.3 版本中,我们改进了所有 flags 添加接口,可以仅仅对特定编译器指定 flags,例如:
+
+```lua
+add_cxxflags("clang::-stdlib=libc++")
+add_cxxflags("gcc::-stdlib=libc++")
+```
+
+或者:
+
+```lua
+add_cxxflags("-stdlib=libc++", {tools = "clang"})
+add_cxxflags("-stdlib=libc++", {tools = "gcc"})
+```
+
+!> 不仅仅是编译flags,对 add_ldflags 等链接 flags,也是同样生效的。
 
 ### target:add_mflags
 
@@ -3084,3 +3099,52 @@ target("test")
 
 ![](https://xmake.io/assets/img/manual/filegroup3.png)
 
+### target:set_exceptions
+
+#### 启用或者禁用异常
+
+我们可以通过这个配置,配置启用和禁用 C++/Objc 的异常。
+
+通常,如果我们通过 add_cxxflags 接口去配置它们,需要根据不同的平台,编译器分别处理它们,非常繁琐。
+
+例如:
+
+```lua
+    on_config(function (target)
+        if (target:has_tool("cxx", "cl")) then
+            target:add("cxflags", "/EHsc", {force = true})
+            target:add("defines", "_HAS_EXCEPTIONS=1", {force = true})
+        elseif(target:has_tool("cxx", "clang") or target:has_tool("cxx", "clang-cl")) then
+            target:add("cxflags", "-fexceptions", {force = true})
+            target:add("cxflags", "-fcxx-exceptions", {force = true})
+        end
+    end)
+```
+
+而通过这个接口,我们就可以抽象化成编译器无关的方式去配置它们。
+
+开启 C++ 异常:
+
+```lua
+set_exceptions("cxx")
+```
+
+禁用 C++ 异常:
+
+```lua
+set_exceptions("no-cxx")
+```
+
+我们也可以同时配置开启 objc 异常。
+
+```lua
+set_exceptions("cxx", "objc")
+```
+
+或者禁用它们。
+
+```lua
+set_exceptions("no-cxx", "no-objc")
+```
+
+Xmake 会在内部自动根据不同的编译器,去适配对应的 flags。