Skip to content

Commit 775ad9c

Browse files
authored
Improved the installation method via Conan. (#1106)
1 parent f5785fd commit 775ad9c

File tree

1 file changed

+92
-12
lines changed

1 file changed

+92
-12
lines changed

doc/installation_conan.md

Lines changed: 92 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,104 @@
11
@page installation_conan Conan
2+
@tableofcontents
23

3-
Unofficial recipe for FTXUI exists on Conan Center:
4-
<https://conan.io/center/recipes/ftxui>
4+
FTXUI can be easily obtained and integrated into your project using the Conan package manager.
5+
6+
## Prerequisites
7+
8+
First, ensure that Conan is installed on your system. If not, you can install it via pip:
9+
10+
```powershell
11+
pip install conan
12+
```
13+
Conan often works in tandem with CMake, so you will need to have CMake installed as well. Once you have confirmed both Conan and CMake are installed, create a project directory, for example, `ftxui-demo`:
14+
15+
```powershell
16+
mkdir C:\ftxui-demo
17+
cd C:\ftxui-demo
18+
```
19+
20+
## Configuration
21+
22+
After ensuring your environment is set up correctly, create a Conan configuration file `conanfile.txt`. This file is used to declare your project's dependencies. The community-maintained package for FTXUI can be found on [Conan Center](https://conan.io/center/recipes/ftxui).
523

624
> [!note]
7-
> This is an unofficial recipe. That means it is not maintained by the FTXUI
8-
> team, but by the community. The package maintainers seems to actively update
9-
> the package to the latest version. Thanks to the maintainers for their work!
25+
> This is an unofficial build script. This means it is not maintained by the FTXUI
26+
> team but by the community. The package maintainer appears to actively update it
27+
> to the latest releases. Many thanks to the maintainer for their work!
28+
29+
@todo If you are familiar with the process, please consider adding an "official" build script to Conan Center.
30+
This could be a GitHub Action that automatically updates Conan Center upon new releases.
31+
32+
```ini
33+
[requires]
34+
ftxui/6.0.2
35+
36+
[generators]
37+
CMakeDeps
38+
CMakeToolchain
39+
40+
[layout]
41+
cmake_layout
42+
```
43+
44+
## Install Dependencies and Build
45+
46+
Once configured, run the following command to install FTXUI and its dependencies:
1047

48+
```powershell
49+
conan install . --output-folder=build --build=missing
50+
```
1151

12-
@todo Add instructions on how to use the conan recipe.
52+
This will download and install `ftxui/6.0.2` along with all its dependencies from Conan's remote repositories.
1353

14-
@todo Please consider adding an "official" recipe to Conan Center if know how.
15-
It could be a github action that will automatically update the conan center
16-
when a new release is made.
54+
After the installation completes, you can test it by creating a `demo.cpp` file in your project directory:
55+
56+
```cpp
57+
#include <ftxui/screen/screen.hpp>
58+
#include <ftxui/dom/elements.hpp>
59+
#include <iostream>
60+
61+
int main() {
62+
using namespace ftxui;
63+
auto document = hbox({
64+
text(" Hello "),
65+
text("FTXUI ") | bold | color(Color::Red),
66+
text(" world! ")
67+
});
68+
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
69+
Render(screen, document);
70+
std::cout << screen.ToString() << std::endl;
71+
return 0;
72+
}
73+
```
74+
75+
If the test is successful, you can then create a `CMakeLists.txt` file in the project directory:
76+
77+
```cmake
78+
cmake_minimum_required(VERSION 3.20)
79+
project(ftxui-demo)
80+
81+
# Set the C++ standard
82+
set(CMAKE_CXX_STANDARD 20)
83+
84+
# Find the FTXUI package installed via Conan
85+
find_package(ftxui CONFIG REQUIRED)
86+
87+
# Create the executable
88+
add_executable(demo demo.cpp)
89+
90+
# Link the executable to the FTXUI library
91+
target_link_libraries(demo PRIVATE ftxui::component)
92+
```
93+
94+
@todo 考虑到中国多数地区使用Conan很有可能遇到各种网络问题,我想做一个定制的版本说明,但是我对conan的了解有限再加上没有找到合适的资料,因此这个计划短暂的被搁置了,如果您知道方法,欢迎在[中文版本](xiaoditx.girhub.io/public/docs/ftxui%E4%B8%AD%E6%96%87%E7%BF%BB%E8%AF%91/installation/conan/)的下方留下评论以提醒我
95+
96+
---
1797

1898
<div class="section_buttons">
19-
99+
20100
| Previous |
21101
|:------------------|
22102
| [Getting Started](getting-started.html) |
23-
24-
</div>
103+
104+
</div>

0 commit comments

Comments
 (0)