ggerganov / imtui

ImTui: Immediate Mode Text-based User Interface C++ Library
https://imtui.ggerganov.com
MIT License
2.94k stars 123 forks source link

Packaging imtui for Linux distributions #17

Open jubalh opened 3 years ago

jubalh commented 3 years ago

I would like to build a package for this.

ggerganov commented 3 years ago

Sounds great!

1, 2 and 3 will do very soon. 4 will probably take some time.

ggerganov commented 3 years ago

Should the tar contain just a copy of the source + the submodules?

jubalh commented 3 years ago

Should the tar contain just a copy of the source + the submodules?

Yep, if that is what is needed to build it. Many Linux distros have a build environment that doesn't allow network connections for their package building.

Being curious: what submodules are used?

ggerganov commented 3 years ago

It uses the Dear ImGui library.

I think I was able to modify the CMake configuration to properly install targets. You can try with this release:

https://github.com/ggerganov/imtui/releases/tag/v1.0.2

To build shared libs, use cmake -DBUILD_SHARED_LIBS=1. By default it builds static.

Let me know if something else is needed.

jubalh commented 3 years ago

The release exports 2 C++ libraries: libimtui and libimtui-ncurses.

What's the difference? (I'm not yet familiar with the codebase. Only found the project today)

ggerganov commented 3 years ago

'libimtui' just renders the ImGui draw data into a memory buffer.

You now need a way display this buffer on the screen and also provide input from the keyboard and/or mouse. This is what 'libimtui-ncurses' does.

In theory, one can use some other lib X instead of ncurses and then ImTui would provide 'libimtui-X' or the user can directly use 'libimtui' with their I/O.

Hope that makes sense. This library separation is very similar to what Dear ImGui does - I'm simply following their example.

carlosjoserg commented 3 years ago

Hey, I'd be happy to help on this one.. ! We've been using this library for some months, building from a cmake Add_ExternalProject, but we'd like to treat it as a system dependency (so a deb package would be great!)

I recently synced our fork at master to test the install feature... but I wasn't able to build directly. I had to do a couple of not-so-elegant tweaks in the cmake to build my dependant projects as before, namely:

  1. Install ImGUI related files: https://github.com/beta-robots/imtui/commit/94a43adc7c34c53fa4c3c4b78ba5b67040970866
  2. Install ImTUI headers into a imtui folder, so they can find each other: https://github.com/beta-robots/imtui/commit/c71e1e9aa4dd4842b01819251173d51b3d73b1ed

Let me know if you need more user-side testing. And thanks for the library!

ggerganov commented 3 years ago

Hi @carlosjoserg . Thanks for the info.

I recently synced our fork at master to test the install feature... but I wasn't able to build directly.

Yes, I think I somehow messed up the CMake install commands at some point. I'll take a look at your suggested changes and push proper CMakeLists to master.

Regarding the package: I am not familiar with the process of publishing the package and making it available to various distros. Do I need to make my own PPA? Or do I apply somewhere? Any help/info on that would be much appreciated.

jubalh commented 3 years ago

I am not familiar with the process of publishing the package and making it available to various distros. Do I need to make my own PPA? Or do I apply somewhere?

No you don't. Packagers do this. What you basically need to do is what I mentioned in my first request: https://github.com/ggerganov/imtui/issues/17#issue-767751669

From there packagers will pick up your package if they are interested. One can also file requests for packaging in various distributions.

ggerganov commented 3 years ago

@carlosjoserg

I made a PR that should fix the CMake install targets: #26 Let me know if that works for you.

@jubalh

After we merge #26 I will make a new release that should satisfy the first 3 points in your comment. Will post an update here when this is ready. Thanks!

jubalh commented 3 years ago

@ggerganov that's great. I'll package imtui then for openSUSE.

ggerganov commented 3 years ago

@jubalh Just made the v1.0.4 release:

https://github.com/ggerganov/imtui/releases/tag/v1.0.4

There is also a tarball attached.

To build, use:

tar -zxvf imtui-1.0.4.tar.gz
cd imtui-1.0.4
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/some/path/to/install ..
make install
carlosjoserg commented 3 years ago

@carlosjoserg

I made a PR that should fix the CMake install targets: #26 Let me know if that works for you.

Yes, that worked. Thanks!

jubalh commented 3 years ago

I made a test package at https://build.opensuse.org/package/show/home:jubalh/imtui now. It seems imtui also installs imgui header files. We have an imgui test package too: https://build.opensuse.org/package/show/devel:libraries:c_c++/imgui So I would like to rather depend on that one. So that not two packages install the same files.

Could you add an option so that we don't install the imgui files when building/installing imtui?

ggerganov commented 3 years ago

I added the option and made release v1.0.5:

https://github.com/ggerganov/imtui/releases/tag/v1.0.5

Use like this:

cmake -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/some/path/to/install -DIMTUI_INSTALL_IMGUI_HEADERS=OFF ..

I am wondering if it would be better if I moved the imgui headers that imtui provides into a folder called imgui-for-imtui. This way, imtui can continue to distribute it's imgui headers and we will avoid the name clash.

jubalh commented 3 years ago

@ggerganov thanks for this. I now have the package moved to an official devel repo for openSUSE: https://build.opensuse.org/package/show/devel:libraries:c_c++/imtui

It would be really great if you could use library versioning: https://autotools.io/libtool/version.html And a .pc file would also be nice but is not as important.

After adding library versioning I could push this into official repositories.

ggerganov commented 3 years ago

@jubalh Regarding the library versioning: I also find this page and I think I now understand how it works: https://www.sourceware.org/autobook/autobook/autobook_61.html

I should make a new release with version 0.0.0 and increment the numbers as explained.

Before I make the release: do I need to change my CMake to generate the .so files with the version number at the end? For example:

endgame commented 2 years ago

It looks like you do, but I haven't been in the C++ space for ages: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html