Skip to content

Commit

Permalink
feat: 假如 USE_SDL_FROM_SRC 选项用于强制使用源码中的 SDL2,并更新 README
Browse files Browse the repository at this point in the history
  • Loading branch information
Augtons committed Mar 30, 2024
1 parent 3fb40a0 commit 0ddffd5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_subdirectory(dependencies/lvgl)

find_package(SDL2 CONFIG COMPONENTS SDL2 SDL2main SDL2-static)
if(NOT SDL2_FOUND)
message(WARNING "SDL2 notfound in your system! SDL2 in source code will be used.")

if(USE_SDL_FROM_SRC)
message(STATUS "Using the SDL2 from the source code.")
add_subdirectory(dependencies/sdl2)
elseif(NOT SDL2_FOUND)
message(WARNING "SDL2 notfound in your system! Using the SDL2 from the source code.")
add_subdirectory(dependencies/sdl2)
else()
message(STATUS "SDL2 found in your system.")
message(STATUS "Installed SDL2 has been found in your system. Using the SDL2 from your system.")
endif()

add_subdirectory(src)
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Other Languages: [简体中文](README_zh_CN.md)

A Cross-Platform Simulator for LVGL using SDL2.
A Cross-Platform Simulator Library for LVGL using SDL2. Supports Multi-Window.

## Contents

Expand All @@ -19,7 +19,7 @@ You need to install this library first, and then create a new project or use the

The purpose is to **avoid repeated compilation** and **make the compiled product distributable** at will.

1. **Clone this repository:**
1. **Clone this repository**: **Be sure to add** `--recursive` **flag !!!**
```shell
git clone --recursive https://github.com/Augtons/lvglsim.git
```
Expand All @@ -43,6 +43,18 @@ The purpose is to **avoid repeated compilation** and **make the compiled product
>
> The benefit of this is to avoid cumbersome dependency management
>
> **Using the System SDL2 Library:**
>
> If CMake successfully locates the SDL2 library using `find_package` during the project build,
> it will **directly use it instead of compiling from source**.
>
> If you want to use an already installed SDL2 library or if you are cross-compiling this project,
> you can specify `-DCMAKE_PREFIX_PATH=<path>` when loading the project,
> for adding the **parent path** containing `SDL2/SDL2Config.cmake`.
>
> To **force compilation of the SDL library from the source code**,
> specify `-DUSE_SDL_FROM_SRC=ON` when loading the project
>
> **Uninstall:**
>
> If you want to uninstall this library, only requires deleting the export file and deleting the cmake compilation intermediate folder
Expand Down
13 changes: 11 additions & 2 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

其他语言:[English](README.md)

基于 SDL2 的跨平台 LVGL 模拟器。
基于 SDL2 的跨平台 LVGL 模拟器。支持多窗口。

## 目录

Expand All @@ -19,7 +19,7 @@

目的是为了**避免重复编译****使编译的产品可以随意分发**

1. **克隆本仓库:**
1. **克隆本仓库:** **务必添加** `--recursive` **标志!!!**
```shell
git clone --recursive https://github.com/Augtons/lvglsim.git
```
Expand All @@ -42,6 +42,15 @@
>
> 这样做的好处是避免了繁琐的依赖管理
>
> **使用系统 SDL2 库:**
>
> 若构建此项目时,CMake 成功使用 `find_package` 找到 SDL2 库,那么就会**直接使用而不是从源码编译**
>
> 如果你想使用已被安装到的 SDL2 库,或者你正在交叉编译本项目。
> 你可以在加载项目时指定 `-DCMAKE_PREFIX_PATH=<路径>`,将包含 `SDL2/SDL2Config.cmake`**父路径**添加进去
>
> 如果想**强制编译源码中的 SDL 库**,您可在加载项目时指定 `-DUSE_SDL_FROM_SRC=ON`
>
> **卸载:**
>
> 如果你想卸载这个库,只需要删除导出文件 (export file) 以及删除cmake编译中间文件夹
Expand Down

0 comments on commit 0ddffd5

Please sign in to comment.