# 15.6 移植安装目标

现在可以配置、编译、链接和测试代码，但是没有测试安装目标。我们将在本节中添加这个目标。

Autotools的构建和安装方式:

```
$ ./configure --prefix=/some/install/path
$ make
$ make install
```

以下是CMake的方式：

```
$ mkdir -p build
$ cd build
$ cmake -D CMAKE_INSTALL_PREFIX=/some/install/path ..
$ cmake --build .
$ cmake --build . --target install
```

要添加安装目标，需要在`src/CMakeLists.txt`中添加以下代码:

```
install(
  TARGETS
      vim
  RUNTIME DESTINATION
      ${CMAKE_INSTALL_BINDIR}
  )
```

本例中，只安装了可执行文件。Vim项目需要安装大量文件(符号链接和文档文件)，为了使本节易于理解，我们就没有迁移示例中所有的安装目标。对于自己的项目而言，应该验证安装步骤的结果是否匹配之前构建框架的安装目标。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chenxiaowei.gitbook.io/cmake-cookbook/15.0-chinese/15.6-chinese.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
