Bladeren bron

improve docs

ruki 4 jaren geleden
bovenliggende
commit
464cbb1899
5 gewijzigde bestanden met toevoegingen van 179 en 220 verwijderingen
  1. 19 31
      mirror/package/local_package.html
  2. 19 31
      mirror/zh-cn/package/local_package.html
  3. 25 34
      package/local_package.md
  4. 90 90
      sitemap.xml
  5. 26 34
      zh-cn/package/local_package.md

+ 19 - 31
mirror/package/local_package.html

@@ -211,46 +211,34 @@ $ xmake l find_package cmake::LibXml2
   }
 }
 </code></pre>
+<h4 id="integratethepackageintheproject">Integrate the package in the project</h4>
+<p>If we integrate and find cmake dependent packages in the xmake.lua project configuration, we usually don&#39;t need to use find_package directly, and we can use a more general and simple package integration method.</p>
+<pre><code class="lang-lua">add_requires("cmake::ZLIB", {alias = "zlib", system = true})
+target("test")
+    set_kind("binary")
+    add_files("src/*.c")
+    add_packages("zlib")
+</code></pre>
+<p>We specify <code>system = true</code> to tell xmake to force cmake to find the package from the system. If it cannot be found, the installation logic will not be followed, because cmake does not provide the installation function of package managers such as vcpkg/conan.<br>Only the package search feature is provided.</p>
 <h4 id="specifyversion">Specify version</h4>
-<pre><code class="lang-lua">find_package("cmake::OpenCV", {required_version = "4.1.1"})
+<pre><code class="lang-lua">add_requires("cmake::OpenCV 4.1.1", {system = true})
 </code></pre>
 <h4 id="specifiedcomponents">Specified components</h4>
-<pre><code class="lang-lua">find_package("cmake::Boost", {components = {"regex", "system"}})
+<pre><code class="lang-lua">add_requires("cmake::Boost", {configs = {components = {"regex", "system"}}))
 </code></pre>
 <h4 id="defaultswitch">Default switch</h4>
-<pre><code class="lang-lua">find_package("cmake::Boost", {components = {"regex", "system"}, presets = {Boost_USE_STATIC_LIB = true}})
-set(Boost_USE_STATIC_LIB ON) - will be used in FindBoost.cmake
-find_package(Boost REQUIRED COMPONENTS regex system)
+<pre><code class="lang-lua">add_requires("cmake::Boost", {configs = {components = {"regex", "system"},
+                                         presets = {Boost_USE_STATIC_LIB = true}})}
 </code></pre>
-<h4 id="setenvironmentvariables">Set environment variables</h4>
-<pre><code class="lang-lua">find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+<p>It is equivalent to predefine some configurations in CMakeLists.txt before calling find_package internally to find the package to control the find_package search strategy and status.</p>
+<pre><code>set(Boost_USE_STATIC_LIB ON) - will be used in FindBoost.cmake
+find_package(Boost REQUIRED COMPONENTS regex system)
+</code></pre><h4 id="setenvironmentvariables">Set environment variables</h4>
+<pre><code class="lang-lua">add_requires("cmake::OpenCV", {configs = {envs = {CMAKE_PREFIX_PATH = "xxx"}}})
 </code></pre>
 <h4 id="specifycustomfindfoocmakemodulescriptdirectory">Specify custom FindFoo.cmake module script directory</h4>
 <p>mydir/cmake_modules/FindFoo.cmake</p>
-<pre><code class="lang-lua">find_package("cmake::Foo", {moduledirs = "mydir/cmake_modules"})
-</code></pre>
-<h4 id="packagedependencyintegration">Package dependency integration</h4>
-<pre><code class="lang-lua">package("xxx")
-    on_fetch(function (package, opt)
-         return package:find_package("cmake::xxx", opt)
-    end)
-package_end()
-
-add_requires("xxx")
-</code></pre>
-<h4 id="packagedependencyintegrationoptionalcomponent">Package dependency integration (optional component)</h4>
-<pre><code class="lang-lua">package("boost")
-    add_configs("regex", {description = "Enable regex.", default = false, type = "boolean"})
-    on_fetch(function (package, opt)
-         opt.components = {}
-         if package:config("regex") then
-             table.insert(opt.components, "regex")
-         end
-         return package:find_package("cmake::Boost", opt)
-    end)
-package_end()
-
-add_requires("boost", {configs = {regex = true}})
+<pre><code class="lang-lua">add_requires("cmake::Foo", {configs = {moduledirs = "mydir/cmake_modules"}})
 </code></pre>
 <p>Related issues: <a href="https://github.com/xmake-io/xmake/issues/1632">#1632</a></p>
 </article>

+ 19 - 31
mirror/zh-cn/package/local_package.html

@@ -211,46 +211,34 @@ $ xmake l find_package cmake::LibXml2
   }
 }
 </code></pre>
+<h4 id="">在项目中集成包</h4>
+<p>如果我们在 xmake.lua 项目配置中集成查找 cmake 的依赖包,通常不需要直接使用 find_package,我们可以用更加通用、简单的包集成方式。</p>
+<pre><code class="lang-lua">add_requires("cmake::ZLIB", {alias = "zlib", system = true})
+target("test")
+    set_kind("binary")
+    add_files("src/*.c")
+    add_packages("zlib")
+</code></pre>
+<p>我们指定 <code>system = true</code> 告诉 xmake 强制从系统中调用 cmake 查找包,如果找不到,不再走安装逻辑,因为 cmake 没有提供类似 vcpkg/conan 等包管理器的安装功能,<br>只提供了包查找特性。</p>
 <h4 id="">指定版本</h4>
-<pre><code class="lang-lua">find_package("cmake::OpenCV", {required_version = "4.1.1"})
+<pre><code class="lang-lua">add_requires("cmake::OpenCV 4.1.1", {system = true})
 </code></pre>
 <h4 id="">指定组件</h4>
-<pre><code class="lang-lua">find_package("cmake::Boost", {components = {"regex", "system"}})
+<pre><code class="lang-lua">add_requires("cmake::Boost", {configs = {components = {"regex", "system"}})}
 </code></pre>
 <h4 id="">预设开关</h4>
-<pre><code class="lang-lua">find_package("cmake::Boost", {components = {"regex", "system"}, presets = {Boost_USE_STATIC_LIB = true}})
-set(Boost_USE_STATIC_LIB ON) -- will be used in FindBoost.cmake
-find_package(Boost REQUIRED COMPONENTS regex system)
+<pre><code class="lang-lua">add_requires("cmake::Boost", {configs = {components = {"regex", "system"},
+                                         presets = {Boost_USE_STATIC_LIB = true}})}
 </code></pre>
-<h4 id="">设置环境变量</h4>
-<pre><code class="lang-lua">find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+<p>相当于内部调用 find_package 查找包之前,在 CMakeLists.txt 中预定义一些配置,控制 find_package 的查找策略和状态。</p>
+<pre><code>set(Boost_USE_STATIC_LIB ON) -- will be used in FindBoost.cmake
+find_package(Boost REQUIRED COMPONENTS regex system)
+</code></pre><h4 id="">设置环境变量</h4>
+<pre><code class="lang-lua">add_requires("cmake::OpenCV", {configs = {envs = {CMAKE_PREFIX_PATH = "xxx"}}})
 </code></pre>
 <h4 id="findfoocmake">指定自定义 FindFoo.cmake 模块脚本目录</h4>
 <p>mydir/cmake_modules/FindFoo.cmake</p>
-<pre><code class="lang-lua">find_package("cmake::Foo", {moduledirs = "mydir/cmake_modules"})
-</code></pre>
-<h4 id="">包依赖集成</h4>
-<pre><code class="lang-lua">package("xxx")
-    on_fetch(function (package, opt)
-         return package:find_package("cmake::xxx", opt)
-    end)
-package_end()
-
-add_requires("xxx")
-</code></pre>
-<h4 id="">包依赖集成(可选组件)</h4>
-<pre><code class="lang-lua">package("boost")
-    add_configs("regex",   { description = "Enable regex.", default = false, type = "boolean"})
-    on_fetch(function (package, opt)
-         opt.components = {}
-         if package:config("regex") then
-             table.insert(opt.components, "regex")
-         end
-         return package:find_package("cmake::Boost", opt)
-    end)
-package_end()
-
-add_requires("boost", {configs = {regex = true}})
+<pre><code class="lang-lua">add_requires("cmake::Foo", {configs = {moduledirs = "mydir/cmake_modules"}})
 </code></pre>
 <p>相关 issues: <a href="https://github.com/xmake-io/xmake/issues/1632">#1632</a></p>
 </article>

+ 25 - 34
package/local_package.md

@@ -158,23 +158,43 @@ $ xmake l find_package cmake::LibXml2
   }
 }
 ```
+#### Integrate the package in the project
+
+If we integrate and find cmake dependent packages in the xmake.lua project configuration, we usually don't need to use find_package directly, and we can use a more general and simple package integration method.
+
+```lua
+add_requires("cmake::ZLIB", {alias = "zlib", system = true})
+target("test")
+    set_kind("binary")
+    add_files("src/*.c")
+    add_packages("zlib")
+```
+
+We specify `system = true` to tell xmake to force cmake to find the package from the system. If it cannot be found, the installation logic will not be followed, because cmake does not provide the installation function of package managers such as vcpkg/conan.
+Only the package search feature is provided.
 
 #### Specify version
 
 ```lua
-find_package("cmake::OpenCV", {required_version = "4.1.1"})
+add_requires("cmake::OpenCV 4.1.1", {system = true})
 ```
 
 #### Specified components
 
 ```lua
-find_package("cmake::Boost", {components = {"regex", "system"}})
+add_requires("cmake::Boost", {configs = {components = {"regex", "system"}}))
 ```
 
 #### Default switch
 
 ```lua
-find_package("cmake::Boost", {components = {"regex", "system"}, presets = {Boost_USE_STATIC_LIB = true}})
+add_requires("cmake::Boost", {configs = {components = {"regex", "system"},
+                                         presets = {Boost_USE_STATIC_LIB = true}})}
+```
+
+It is equivalent to predefine some configurations in CMakeLists.txt before calling find_package internally to find the package to control the find_package search strategy and status.
+
+```
 set(Boost_USE_STATIC_LIB ON) - will be used in FindBoost.cmake
 find_package(Boost REQUIRED COMPONENTS regex system)
 ```
@@ -182,7 +202,7 @@ find_package(Boost REQUIRED COMPONENTS regex system)
 #### Set environment variables
 
 ```lua
-find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+add_requires("cmake::OpenCV", {configs = {envs = {CMAKE_PREFIX_PATH = "xxx"}}})
 ```
 
 #### Specify custom FindFoo.cmake module script directory
@@ -190,36 +210,7 @@ find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
 mydir/cmake_modules/FindFoo.cmake
 
 ```lua
-find_package("cmake::Foo", {moduledirs = "mydir/cmake_modules"})
-```
-
-#### Package dependency integration
-
-```lua
-package("xxx")
-    on_fetch(function (package, opt)
-         return package:find_package("cmake::xxx", opt)
-    end)
-package_end()
-
-add_requires("xxx")
-```
-
-#### Package dependency integration (optional component)
-
-```lua
-package("boost")
-    add_configs("regex", {description = "Enable regex.", default = false, type = "boolean"})
-    on_fetch(function (package, opt)
-         opt.components = {}
-         if package:config("regex") then
-             table.insert(opt.components, "regex")
-         end
-         return package:find_package("cmake::Boost", opt)
-    end)
-package_end()
-
-add_requires("boost", {configs = {regex = true}})
+add_requires("cmake::Foo", {configs = {moduledirs = "mydir/cmake_modules"}})
 ```
 
 Related issues: [#1632](https://github.com/xmake-io/xmake/issues/1632)

+ 90 - 90
sitemap.xml

@@ -12,452 +12,452 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2021-12-15T09:15:49+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/other_features.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2021-12-15T09:15:50+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2021-12-15T09:15:51+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/other_features.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2021-12-15T09:15:52+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-12-15T09:15:53+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-12-15T09:15:54+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2021-12-15T09:15:55+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2021-12-15T09:15:56+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2021-12-15T09:15:57+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2021-12-15T09:15:58+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2021-12-15T09:15:59+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2021-12-15T09:16:00+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2021-12-15T09:16:01+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2021-12-15T09:16:02+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2021-12-15T09:16:03+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-12-15T09:16:03+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-12-15T09:16:03+08:00</lastmod>
+  <lastmod>2021-12-16T23:48:25+08:00</lastmod>
 </url>
 
 </urlset>

+ 26 - 34
zh-cn/package/local_package.md

@@ -159,22 +159,43 @@ $ xmake l find_package cmake::LibXml2
 }
 ```
 
+#### 在项目中集成包
+
+如果我们在 xmake.lua 项目配置中集成查找 cmake 的依赖包,通常不需要直接使用 find_package,我们可以用更加通用、简单的包集成方式。
+
+```lua
+add_requires("cmake::ZLIB", {alias = "zlib", system = true})
+target("test")
+    set_kind("binary")
+    add_files("src/*.c")
+    add_packages("zlib")
+```
+
+我们指定 `system = true` 告诉 xmake 强制从系统中调用 cmake 查找包,如果找不到,不再走安装逻辑,因为 cmake 没有提供类似 vcpkg/conan 等包管理器的安装功能,
+只提供了包查找特性。
+
 #### 指定版本
 
 ```lua
-find_package("cmake::OpenCV", {required_version = "4.1.1"})
+add_requires("cmake::OpenCV 4.1.1", {system = true})
 ```
 
 #### 指定组件
 
 ```lua
-find_package("cmake::Boost", {components = {"regex", "system"}})
+add_requires("cmake::Boost", {configs = {components = {"regex", "system"}})}
 ```
 
 #### 预设开关
 
 ```lua
-find_package("cmake::Boost", {components = {"regex", "system"}, presets = {Boost_USE_STATIC_LIB = true}})
+add_requires("cmake::Boost", {configs = {components = {"regex", "system"},
+                                         presets = {Boost_USE_STATIC_LIB = true}})}
+```
+
+相当于内部调用 find_package 查找包之前,在 CMakeLists.txt 中预定义一些配置,控制 find_package 的查找策略和状态。
+
+```
 set(Boost_USE_STATIC_LIB ON) -- will be used in FindBoost.cmake
 find_package(Boost REQUIRED COMPONENTS regex system)
 ```
@@ -182,7 +203,7 @@ find_package(Boost REQUIRED COMPONENTS regex system)
 #### 设置环境变量
 
 ```lua
-find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+add_requires("cmake::OpenCV", {configs = {envs = {CMAKE_PREFIX_PATH = "xxx"}}})
 ```
 
 #### 指定自定义 FindFoo.cmake 模块脚本目录
@@ -190,36 +211,7 @@ find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
 mydir/cmake_modules/FindFoo.cmake
 
 ```lua
-find_package("cmake::Foo", {moduledirs = "mydir/cmake_modules"})
-```
-
-#### 包依赖集成
-
-```lua
-package("xxx")
-    on_fetch(function (package, opt)
-         return package:find_package("cmake::xxx", opt)
-    end)
-package_end()
-
-add_requires("xxx")
-```
-
-#### 包依赖集成(可选组件)
-
-```lua
-package("boost")
-    add_configs("regex",   { description = "Enable regex.", default = false, type = "boolean"})
-    on_fetch(function (package, opt)
-         opt.components = {}
-         if package:config("regex") then
-             table.insert(opt.components, "regex")
-         end
-         return package:find_package("cmake::Boost", opt)
-    end)
-package_end()
-
-add_requires("boost", {configs = {regex = true}})
+add_requires("cmake::Foo", {configs = {moduledirs = "mydir/cmake_modules"}})
 ```
 
 相关 issues: [#1632](https://github.com/xmake-io/xmake/issues/1632)