ruki 4 anni fa
parent
commit
1fc16746c6

+ 73 - 0
mirror/package/local_package.html

@@ -180,6 +180,79 @@ target("bar")
 <pre><code class="lang-console">$ xmake package -f remote --url=https://xxxx/xxx.tar.gz --shasum=xxxxx --homepage=xxxxx`
 </code></pre>
 <p>xmake will also read the relevant configuration information from the target&#39;s <code>set_license</code> and <code>set_version</code> configurations.</p>
+<h3 id="findpackagesfromcmake">Find packages from CMake</h3>
+<p>Now cmake is the de facto standard, so the find_package provided by CMake can already find a large number of libraries and modules. We fully reuse this part of cmake&#39;s ecology to expand xmake&#39;s integration of packages.</p>
+<p>We can use <code>find_package("cmake::xxx")</code> to find some packages with cmake, xmake will automatically generate a cmake script to call cmake&#39;s find_package to find some packages and get the bread information.</p>
+<p>E.g:</p>
+<pre><code class="lang-console">$ xmake l find_package cmake::ZLIB
+{
+  links = {
+    "z"
+  },
+  includedirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/include"
+  },
+  linkdirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/lib"
+  }
+}
+$ xmake l find_package cmake::LibXml2
+{
+  links = {
+    "xml2"
+  },
+  includedirs = {
+    "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2"
+  },
+  linkdirs = {
+    "/usr/lib"
+  }
+}
+</code></pre>
+<h4 id="specifyversion">Specify version</h4>
+<pre><code class="lang-lua">find_package("cmake::OpenCV", {required_version = "4.1.1"})
+</code></pre>
+<h4 id="specifiedcomponents">Specified components</h4>
+<pre><code class="lang-lua">find_package("cmake::Boost", {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)
+</code></pre>
+<h4 id="setenvironmentvariables">Set environment variables</h4>
+<pre><code class="lang-lua">find_package("cmake::OpenCV", {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}})
+</code></pre>
+<p>Related issues: <a href="https://github.com/xmake-io/xmake/issues/1632">#1632</a></p>
 </article>
 </body>
 </html>

+ 73 - 0
mirror/zh-cn/package/local_package.html

@@ -180,6 +180,79 @@ target("bar")
 <pre><code class="lang-console">$ xmake package -f remote --url=https://xxxx/xxx.tar.gz --shasum=xxxxx --homepage=xxxxx`
 </code></pre>
 <p>xmake 也会从 target 的 <code>set_license</code> 和 <code>set_version</code> 等配置中读取相关配置信息。</p>
+<h3 id="cmake">从 CMake 中查找包</h3>
+<p>现在 cmake 已经是事实上的标准,所以 CMake 提供的 find_package 已经可以查找大量的库和模块,我们完全复用 cmake 的这部分生态来扩充 xmake 对包的集成。</p>
+<p>我们可以通过 <code>find_package("cmake::xxx")</code> 去借助 cmake 来找一些包,xmake 会自动生成一个 cmake 脚本来调用 cmake 的 find_package 去查找一些包,获取里面包信息。</p>
+<p>例如:</p>
+<pre><code class="lang-console">$ xmake l find_package cmake::ZLIB
+{
+  links = {
+    "z"
+  },
+  includedirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/include"
+  },
+  linkdirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/lib"
+  }
+}
+$ xmake l find_package cmake::LibXml2
+{
+  links = {
+    "xml2"
+  },
+  includedirs = {
+    "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2"
+  },
+  linkdirs = {
+    "/usr/lib"
+  }
+}
+</code></pre>
+<h4 id="">指定版本</h4>
+<pre><code class="lang-lua">find_package("cmake::OpenCV", {required_version = "4.1.1"})
+</code></pre>
+<h4 id="">指定组件</h4>
+<pre><code class="lang-lua">find_package("cmake::Boost", {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)
+</code></pre>
+<h4 id="">设置环境变量</h4>
+<pre><code class="lang-lua">find_package("cmake::OpenCV", {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}})
+</code></pre>
+<p>相关 issues: <a href="https://github.com/xmake-io/xmake/issues/1632">#1632</a></p>
 </article>
 </body>
 </html>

+ 102 - 0
package/local_package.md

@@ -121,3 +121,105 @@ $ xmake package -f remote --url=https://xxxx/xxx.tar.gz --shasum=xxxxx --homepag
 ```
 
 xmake will also read the relevant configuration information from the target's `set_license` and `set_version` configurations.
+
+### Find packages from CMake
+
+Now cmake is the de facto standard, so the find_package provided by CMake can already find a large number of libraries and modules. We fully reuse this part of cmake's ecology to expand xmake's integration of packages.
+
+We can use `find_package("cmake::xxx")` to find some packages with cmake, xmake will automatically generate a cmake script to call cmake's find_package to find some packages and get the bread information.
+
+E.g:
+
+```console
+$ xmake l find_package cmake::ZLIB
+{
+  links = {
+    "z"
+  },
+  includedirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/include"
+  },
+  linkdirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/lib"
+  }
+}
+$ xmake l find_package cmake::LibXml2
+{
+  links = {
+    "xml2"
+  },
+  includedirs = {
+    "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2"
+  },
+  linkdirs = {
+    "/usr/lib"
+  }
+}
+```
+
+#### Specify version
+
+```lua
+find_package("cmake::OpenCV", {required_version = "4.1.1"})
+```
+
+#### Specified components
+
+```lua
+find_package("cmake::Boost", {components = {"regex", "system"}})
+```
+
+#### Default switch
+
+```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)
+```
+
+#### Set environment variables
+
+```lua
+find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+```
+
+#### Specify custom FindFoo.cmake module script directory
+
+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}})
+```
+
+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-10-29T22:38:19+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/other_features.html</loc>
-  <lastmod>2021-10-29T22:38:19+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2021-10-29T22:38:19+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:00+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2021-10-29T22:38:19+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:01+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2021-10-29T22:38:20+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:02+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2021-10-29T22:38:21+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/other_features.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:03+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2021-10-29T22:38:22+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:04+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2021-10-29T22:38:23+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:05+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2021-10-29T22:38:24+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:06+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2021-10-29T22:38:25+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:07+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2021-10-29T22:38:26+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:08+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2021-10-29T22:38:27+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:09+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2021-10-29T22:38:28+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:10+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2021-10-29T22:38:29+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:11+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2021-10-29T22:38:30+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:12+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2021-10-29T22:38:31+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:13+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-10-29T22:38:32+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-10-29T22:38:33+08:00</lastmod>
+  <lastmod>2021-10-29T23:44:14+08:00</lastmod>
 </url>
 
 </urlset>

+ 102 - 0
zh-cn/package/local_package.md

@@ -121,3 +121,105 @@ $ xmake package -f remote --url=https://xxxx/xxx.tar.gz --shasum=xxxxx --homepag
 ```
 
 xmake 也会从 target 的 `set_license` 和 `set_version` 等配置中读取相关配置信息。
+
+### 从 CMake 中查找包
+
+现在 cmake 已经是事实上的标准,所以 CMake 提供的 find_package 已经可以查找大量的库和模块,我们完全复用 cmake 的这部分生态来扩充 xmake 对包的集成。
+
+我们可以通过 `find_package("cmake::xxx")` 去借助 cmake 来找一些包,xmake 会自动生成一个 cmake 脚本来调用 cmake 的 find_package 去查找一些包,获取里面包信息。
+
+例如:
+
+```console
+$ xmake l find_package cmake::ZLIB
+{
+  links = {
+    "z"
+  },
+  includedirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/include"
+  },
+  linkdirs = {
+    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
+15.sdk/usr/lib"
+  }
+}
+$ xmake l find_package cmake::LibXml2
+{
+  links = {
+    "xml2"
+  },
+  includedirs = {
+    "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2"
+  },
+  linkdirs = {
+    "/usr/lib"
+  }
+}
+```
+
+#### 指定版本
+
+```lua
+find_package("cmake::OpenCV", {required_version = "4.1.1"})
+```
+
+#### 指定组件
+
+```lua
+find_package("cmake::Boost", {components = {"regex", "system"}})
+```
+
+#### 预设开关
+
+```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)
+```
+
+#### 设置环境变量
+
+```lua
+find_package("cmake::OpenCV", {envs = {CMAKE_PREFIX_PATH = "xxx"}})
+```
+
+#### 指定自定义 FindFoo.cmake 模块脚本目录
+
+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}})
+```
+
+相关 issues: [#1632](https://github.com/xmake-io/xmake/issues/1632)