From bead152176e253aff44a95c8307e3b1a0455f56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Sun, 1 Oct 2023 23:24:57 +0100 Subject: [PATCH 1/4] build(cmake): bump minimum cmake version to 3.13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bump cmake minimum version to 3.13 and make it possible to use CMP0077: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html * starting with cmake 3.13 the behaviour of option() changed so that any value already set is preserved when the option() statement is reached. Signed-off-by: António Oliveira --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fadccaa..0b8bd08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12.4) +cmake_minimum_required(VERSION 3.13) project(lv_drivers HOMEPAGE_URL https://github.com/lvgl/lv_drivers/) From f41e47c439a230fc68d88d09142712563c0ba9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Sun, 1 Oct 2023 23:38:06 +0100 Subject: [PATCH 2/4] build(cmake): fix install to use sources dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * the install() statement copies all *.h files from the top level dir of the current project, instead of only the lv_drivers headers. This appears to be a typo, as the actual variable that makes sense to refer to the headers in the lv_drivers project files is CMAKE_CURRENT_SOURCE_DIR, so I changed it. * Without this change, calling install on a project which bundles lv_drivers within its source tree, would copy every single .h file in the whole project, which can be nasty, especially with large codebases. Signed-off-by: António Oliveira --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b8bd08..ac65eb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ if("${INC_INSTALL_DIR}" STREQUAL "") endif() install( - DIRECTORY "${CMAKE_SOURCE_DIR}/" + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/" FILES_MATCHING PATTERN "*.h" From acc746f7dc9bea7653bbedab384b4b87d0766f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Sun, 1 Oct 2023 23:50:37 +0100 Subject: [PATCH 3/4] build(cmake): add option LV_DRIVERS_BUNDLED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added the option to set lv_drivers as bundled. If enabled, the install targets are not defined and no lv_drivers headers or objects will be installed, since lv_drivers will be directly linked to any of its dependants. * the default behaviour is preserved. Signed-off-by: António Oliveira --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac65eb3..f5ee93e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.13) project(lv_drivers HOMEPAGE_URL https://github.com/lvgl/lv_drivers/) +# Option to set the project as bundled. +# If bundled, the installation steps are skipped because lv_drivers are linked +# directly with any dependant targets. +option( LV_DRIVERS_BUNDLED "Set lv_drivers as bundled (disables install)" OFF ) + # Option to build as shared library (as opposed to static), default: OFF option(BUILD_SHARED_LIBS "Build shared as library (as opposed to static)" OFF) @@ -30,6 +35,7 @@ if("${INC_INSTALL_DIR}" STREQUAL "") set(INC_INSTALL_DIR "include/lvgl/lv_drivers") endif() +if (NOT LV_DRIVERS_BUNDLED) install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/" @@ -39,6 +45,7 @@ install( PATTERN "CMakeFiles" EXCLUDE PATTERN "docs" EXCLUDE PATTERN "lib" EXCLUDE) +endif() file(GLOB LV_DRIVERS_PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/lv_drv_conf.h") @@ -50,9 +57,11 @@ set_target_properties( RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" PUBLIC_HEADER "${LV_DRIVERS_PUBLIC_HEADERS}") +if (NOT LV_DRIVERS_BUNDLED) install( TARGETS lv_drivers ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" LIBRARY DESTINATION "${LIB_INSTALL_DIR}" RUNTIME DESTINATION "${LIB_INSTALL_DIR}" PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}") +endif() \ No newline at end of file From 741b7ff8a030f6416efac8e7167d3caf0d64d342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Oliveira?= Date: Tue, 17 Oct 2023 23:42:10 +0100 Subject: [PATCH 4/4] build(cmake): add option to link against SDL2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * if lv_drivers is used with: #define USE_SDL 1 The CMake option LV_DRIVERS_USE_SDL may be set to automatically find libsdl2 and add it to the list of link libraries Signed-off-by: António Oliveira --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5ee93e..b2398b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,13 @@ find_package(PkgConfig) pkg_check_modules(PKG_WAYLAND wayland-client wayland-cursor wayland-protocols xkbcommon) target_link_libraries(lv_drivers PUBLIC lvgl ${PKG_WAYLAND_LIBRARIES}) +option( LV_DRIVERS_USE_SDL "Use SDL2 libraries" OFF ) + +if( LV_DRIVERS_USE_SDL ) + find_package( SDL2 REQUIRED ) + target_link_libraries( lv_drivers PRIVATE SDL2::SDL2 ) +endif( LV_DRIVERS_USE_SDL ) + if("${LIB_INSTALL_DIR}" STREQUAL "") set(LIB_INSTALL_DIR "lib") endif()