mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
add how_to_use_cmake_to_build_awtk_app.md
This commit is contained in:
parent
99b834aa22
commit
151506e6c7
@ -103,7 +103,7 @@
|
||||
* [如何将资源编译到应用程序并使用它们](how_to_compile_res_into_app_and_use_them.md)
|
||||
* [如何为不同语言加载不同的字体文件](how_to_load_font_for_specific_language.md)
|
||||
* [如何为指定的键设置长按时间](how_to_set_key_long_press_time.md)
|
||||
|
||||
* [如何使用 CMake 构建 AWTK 应用](how_to_use_cmake_to_build_awtk_app.md)
|
||||
|
||||
### 3. 内部原理
|
||||
* [AWTK 脚本绑定原理](script_binding.md)
|
||||
|
@ -1,5 +1,8 @@
|
||||
# 最新动态
|
||||
|
||||
2024/04/15
|
||||
* 增加文档 [如何使用 CMake 构建 AWTK 应用](how_to_use_cmake_to_build_awtk_app.md)
|
||||
|
||||
2024/04/13
|
||||
* nanovg 支持 GL2。
|
||||
* 增加函数 window\_manager\_create\_native\_window
|
||||
|
105
docs/how_to_use_cmake_to_build_awtk_app.md
Normal file
105
docs/how_to_use_cmake_to_build_awtk_app.md
Normal file
@ -0,0 +1,105 @@
|
||||
# 如何使用 CMake 构建 AWTK 应用
|
||||
|
||||
## 1. 安装 CMake
|
||||
|
||||
CMake 是一个开源的跨平台的构建工具,可以用来构建 AWTK 应用。
|
||||
|
||||
在 Windows 下,可以从 [CMake 官网](https://cmake.org/download/) 下载安装包进行安装。
|
||||
|
||||
在 Linux 下,可以使用包管理工具安装:
|
||||
|
||||
```bash
|
||||
sudo apt-get install cmake
|
||||
```
|
||||
|
||||
## 2. 创建 CMakeLists.txt
|
||||
|
||||
* 指定 awtk 的路径
|
||||
|
||||
```cmake
|
||||
set(awtk_DIR "../awtk")
|
||||
```
|
||||
|
||||
* 导入 awtk 的配置
|
||||
|
||||
```cmake
|
||||
find_package(awtk REQUIRED)
|
||||
```
|
||||
|
||||
* 添加头文件路径(请根据自己的情况调整)
|
||||
|
||||
```cmake
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/res
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/3rd
|
||||
)
|
||||
```
|
||||
|
||||
* 添加源文件(请根据自己的情况调整)
|
||||
|
||||
```cmake
|
||||
file(GLOB SOURCES src/*.c 3rd/sqlite3/sqlite3.c)
|
||||
add_executable(hello ${SOURCES})
|
||||
```
|
||||
|
||||
* 添加链接库(请根据自己的情况调整)
|
||||
|
||||
```cmake
|
||||
target_link_libraries(hello awtk)
|
||||
```
|
||||
|
||||
* 设置 WIN32_EXECUTABLE 属性
|
||||
|
||||
```cmake
|
||||
set_target_properties(hello PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
```
|
||||
|
||||
完整示例:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
|
||||
project(hello)
|
||||
|
||||
set(awtk_DIR "../awtk")
|
||||
find_package(awtk REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/res
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/3rd
|
||||
)
|
||||
|
||||
file(GLOB SOURCES src/*.c 3rd/sqlite3/sqlite3.c)
|
||||
add_executable(hello ${SOURCES})
|
||||
target_link_libraries(hello awtk)
|
||||
set_target_properties(hello PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
```
|
||||
|
||||
## 3. 配置
|
||||
|
||||
```bash
|
||||
cmake -S . cmake -B build
|
||||
```
|
||||
|
||||
## 4. 编译
|
||||
|
||||
> 在 Windows 下可以用 visual studio 打开 build 目录下的工程,然后进行编译。
|
||||
|
||||
```bash
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
## 5. 运行
|
||||
|
||||
```bash
|
||||
./build/hello
|
||||
```
|
||||
|
||||
## 6. 调试
|
||||
|
||||
> 在 Windows 下可以用 visual studio 打开 build 目录下的工程,然后进行调试。
|
||||
|
||||
|
||||
参考:[awtk-hello](https://gitee.com/zlgopen/awtk-hello)
|
Loading…
Reference in New Issue
Block a user