mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Compare commits
1 Commits
8daba47a21
...
3e04ffc5b3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e04ffc5b3 |
@@ -6,7 +6,6 @@ add_library(ftxui-modules)
|
|||||||
|
|
||||||
target_sources(ftxui-modules
|
target_sources(ftxui-modules
|
||||||
PUBLIC FILE_SET CXX_MODULES FILES
|
PUBLIC FILE_SET CXX_MODULES FILES
|
||||||
src/ftxui/ftxui.cppm
|
|
||||||
src/ftxui/component.cppm
|
src/ftxui/component.cppm
|
||||||
src/ftxui/component/animation.cppm
|
src/ftxui/component/animation.cppm
|
||||||
src/ftxui/component/captured_mouse.cppm
|
src/ftxui/component/captured_mouse.cppm
|
||||||
|
|||||||
@@ -12,24 +12,8 @@ FTXUI experimentally supports
|
|||||||
compilation times and improve code organization. Each header has a
|
compilation times and improve code organization. Each header has a
|
||||||
corresponding module.
|
corresponding module.
|
||||||
|
|
||||||
Use the FTXUI_BUILD_MODULES option to build the FTXUI project itself to provide C++ 20 modules,
|
**Example with CMake and Ninja**
|
||||||
for example with CMake and Ninja:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cmake \
|
|
||||||
-DCMAKE_GENERATOR=Ninja \
|
|
||||||
-DFTXUI_BUILD_MODULES=ON \
|
|
||||||
..
|
|
||||||
|
|
||||||
ninja
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> To use modules, you need a C++20 compatible compiler, CMake version 3.20 or
|
|
||||||
> higher, and use a compatible generator like Ninja. Note that Makefile
|
|
||||||
> generators **do not support modules**.
|
|
||||||
|
|
||||||
Then, in your own code you can consume the modules and code as normal:
|
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
import ftxui;
|
import ftxui;
|
||||||
@@ -42,30 +26,23 @@ int main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note, the `ftxui` convenience module which simply pulls together all the modules:
|
```sh
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_GENERATOR=Ninja \
|
||||||
|
-DFTXUI_BUILD_MODULES=ON \
|
||||||
|
..
|
||||||
|
|
||||||
```cpp
|
ninja
|
||||||
export import ftxui.component;
|
|
||||||
export import ftxui.dom;
|
|
||||||
export import ftxui.screen;
|
|
||||||
export import ftxui.util;
|
|
||||||
```
|
|
||||||
You can instead import only the module(s) you need if desired.
|
|
||||||
|
|
||||||
To properly find and link the modules with CMake, use `target_link_libraries` to get the right
|
|
||||||
compiler, linker, etc. flags.
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
target_link_libraries(my_executable
|
|
||||||
#...whatever...
|
|
||||||
PRIVATE ftxui::modules
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
> [!NOTE]
|
||||||
|
> To use modules, you need a C++20 compatible compiler, CMake version 3.20 or
|
||||||
|
> higher, and use a compatible generator like Ninja. Note that Makefile
|
||||||
|
> generators **do not support modules**.
|
||||||
|
|
||||||
### Module list
|
### Module list
|
||||||
|
|
||||||
The modules directly reference the corresponding header, or a group of related
|
The modules directly reference the corresponding header, or a group of related
|
||||||
headers to provide a more convenient interface. The following modules
|
headers to provide a more convenient interface. The following modules
|
||||||
are available:
|
are available:
|
||||||
|
|
||||||
- `ftxui`
|
- `ftxui`
|
||||||
|
|||||||
Reference in New Issue
Block a user