Ryzee119 / lvgl-sdl

A crossplatform SDL wrapper for the Light and Versatile Graphics Library https://lvgl.io/.
MIT License
51 stars 10 forks source link

No build-system for using or installing the library #8

Open JayFoxRox opened 3 years ago

JayFoxRox commented 3 years ago

There's currently no build-system. The README recommends to copy https://github.com/Ryzee119/lvgl-sdl/blob/master/example/CMakeLists.txt

Additionally, that makefile adds a manual build-system for lvgl, which should not be necessary. This is not how CMake usually does things.

Instead, you can normally just use add_subdirectory(${LVDRV_DIR}) which would then link those CMake build-systems together.

I'd expect the example to be closer to this:


# This will expose the (potentially virtual) lvgl library
add_subdirectory(${LVDRV_DIR})

set(SRC_FILES
    # My example project source files (Change this for your own project)
    "${PROJECT_DIR}/example.c"
    "${PROJECT_DIR}/input_test.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_benchmark/*.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_stress/*.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_widgets/*.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_ex_get_started/*.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_ex_style/*.c"
    "${PROJECT_DIR}/lv_examples/src/lv_demo_ex_widgets/*.c"
    "${PROJECT_DIR}/lv_examples/assets/*.c"
)
add_executable(lvgl_example ${SRC_FILES})
target_link_libraries(lvgl_example PUBLIC lvgl)

Furthermore, the SDL2 dependency only has to be added to lvgl, and if it's the right visibility (note the PUBLIC in target_link_libraries), that will have a transitive property and ensure that all users of lvgl_example will also link against SDL2. Consult CMake docs for more information.

For people who don't want to bundle lvgl, all they'll have to do is to replace the add_subdirectory with find_package(REQUIRED lvgl) (or along those lines).

JayFoxRox commented 3 years ago

I think this is partially an issue with upstream, because they also don't have an install target. There don't even seem to be rules which headers should be included or how to package them (without copying the entire source tree). It's a huge mess, but it looks like they are currently transitioning to CMake (unfortunately often using it very poorly).

However, the build-system I proposed can probably be largely be used for bundling (just find_package won't work, because there's no way to install or package the library).