From 0d369f4aa667b7f066d39e60a8c515085ec378f6 Mon Sep 17 00:00:00 2001 From: "ithink.chan" Date: Tue, 31 Dec 2019 11:55:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20CMake=20=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=AF=AD=E6=B3=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ithink.chan --- .../Development/Tools/CMake/CMake_基本语法.md | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Software/Development/Tools/CMake/CMake_基本语法.md diff --git a/Software/Development/Tools/CMake/CMake_基本语法.md b/Software/Development/Tools/CMake/CMake_基本语法.md new file mode 100644 index 0000000..aa72cbf --- /dev/null +++ b/Software/Development/Tools/CMake/CMake_基本语法.md @@ -0,0 +1,107 @@ +# CMake 基本语法 + +CMake 支持大写、小写、混合大小写的命令。 + +## 最小版本号 + +```sh +cmake_minimum_required(VERSION 2.8) +``` + +## 工程名 + +```sh +project() +``` + +## Include 路径 + +*需要出现在 add_executable 和 add_library 等之前。* + +```sh +include_directories( + + + ... + +) +``` + +## 添加库路径 + +*需要出现在 add_executable 和 add_library 等之前。* + +```sh +link_directories( + + + ... + +) +``` + +## 添加库文件 + +*已经被废弃了,需要出现在 add_executable 和 add_library 等之前。* + +```sh +link_libraries( + + + ... + +) +``` + +支持直接全路径的写法。 + +## 可执行文件目标和源码 + +```sh +add_executable( + + + + ... + +) +``` + +## 库文件目标和源码 + +```sh +add_library( + + + + + ... + +) +``` + +## 为目标添加库文件 + +*可添加的动态库或静态库,可以在 add_executable 和 add_library 等之后。* + +```sh +target_link_libraries( + + + + ... + +) +``` + +## 添加依赖工程 + +```sh +add_dependencies( + + + + ... + +) +```