From 2c469279f53f9dee63d71295c6058749bc87ce73 Mon Sep 17 00:00:00 2001 From: Marex Date: Sat, 20 Apr 2024 20:33:09 +0200 Subject: [PATCH] fix(cmake): generate versioned shared libraries (#5865) Signed-off-by: Marek Vasut Co-authored-by: Marek Vasut --- env_support/cmake/custom.cmake | 18 +++++++++++++++++- lv_version.h | 14 ++++++++++++++ lv_version.h.in | 14 ++++++++++++++ lvgl.h | 5 +---- lvgl.pc.in | 2 +- 5 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 lv_version.h create mode 100644 lv_version.h.in diff --git a/env_support/cmake/custom.cmake b/env_support/cmake/custom.cmake index 2f8d25120..a1868f810 100644 --- a/env_support/cmake/custom.cmake +++ b/env_support/cmake/custom.cmake @@ -1,3 +1,10 @@ +set(LVGL_VERSION_MAJOR "9") +set(LVGL_VERSION_MINOR "1") +set(LVGL_VERSION_PATCH "1") +set(LVGL_VERSION_INFO "dev") +set(LVGL_VERSION ${LVGL_VERSION_MAJOR}.${LVGL_VERSION_MINOR}.${LVGL_VERSION_PATCH}) +set(LVGL_SOVERSION ${LVGL_VERSION_MAJOR}) + # Option to define LV_LVGL_H_INCLUDE_SIMPLE, default: ON option(LV_LVGL_H_INCLUDE_SIMPLE "Use #include \"lvgl.h\" instead of #include \"../../lvgl.h\"" ON) @@ -47,7 +54,7 @@ if(LV_CONF_SKIP) endif() # Include root and optional parent path of LV_CONF_PATH -target_include_directories(lvgl SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR}) +target_include_directories(lvgl SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR} ${CMAKE_CURRENT_BINARY_DIR}) if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL) @@ -120,6 +127,7 @@ endif() configure_file("${LVGL_ROOT_DIR}/lvgl.pc.in" lvgl.pc @ONLY) +configure_file("${LVGL_ROOT_DIR}/lv_version.h.in" lv_version.h @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/lvgl.pc" @@ -129,6 +137,8 @@ install( set_target_properties( lvgl PROPERTIES OUTPUT_NAME lvgl + VERSION ${LVGL_VERSION} + SOVERSION ${LVGL_SOVERSION} ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" @@ -147,6 +157,8 @@ if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL) set_target_properties( lvgl_thorvg PROPERTIES OUTPUT_NAME lvgl_thorvg + VERSION ${LVGL_VERSION} + SOVERSION ${LVGL_SOVERSION} ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" @@ -165,6 +177,8 @@ if(NOT LV_CONF_BUILD_DISABLE_DEMOS) set_target_properties( lvgl_demos PROPERTIES OUTPUT_NAME lvgl_demos + VERSION ${LVGL_VERSION} + SOVERSION ${LVGL_SOVERSION} ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" @@ -183,6 +197,8 @@ if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES) set_target_properties( lvgl_examples PROPERTIES OUTPUT_NAME lvgl_examples + VERSION ${LVGL_VERSION} + SOVERSION ${LVGL_SOVERSION} ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" diff --git a/lv_version.h b/lv_version.h new file mode 100644 index 000000000..b266f68d5 --- /dev/null +++ b/lv_version.h @@ -0,0 +1,14 @@ +/** + * @file version.h + * The current version of LVGL + */ + +#ifndef LVGL_VERSION_H +#define LVGL_VERSION_H + +#define LVGL_VERSION_MAJOR 9 +#define LVGL_VERSION_MINOR 1 +#define LVGL_VERSION_PATCH 1 +#define LVGL_VERSION_INFO "dev" + +#endif /*LVGL_VERSION_H*/ diff --git a/lv_version.h.in b/lv_version.h.in new file mode 100644 index 000000000..cad0daaf5 --- /dev/null +++ b/lv_version.h.in @@ -0,0 +1,14 @@ +/** + * @file version.h + * The current version of LVGL + */ + +#ifndef LVGL_VERSION_H +#define LVGL_VERSION_H + +#define LVGL_VERSION_MAJOR @LVGL_VERSION_MAJOR@ +#define LVGL_VERSION_MINOR @LVGL_VERSION_MINOR@ +#define LVGL_VERSION_PATCH @LVGL_VERSION_PATCH@ +#define LVGL_VERSION_INFO "@LVGL_VERSION_INFO@" + +#endif /*LVGL_VERSION_H*/ diff --git a/lvgl.h b/lvgl.h index 725a43c4b..3ae629297 100644 --- a/lvgl.h +++ b/lvgl.h @@ -13,10 +13,7 @@ extern "C" { /*************************** * CURRENT VERSION OF LVGL ***************************/ -#define LVGL_VERSION_MAJOR 9 -#define LVGL_VERSION_MINOR 1 -#define LVGL_VERSION_PATCH 1 -#define LVGL_VERSION_INFO "dev" +#include "lv_version.h" /********************* * INCLUDES diff --git a/lvgl.pc.in b/lvgl.pc.in index 09b3d2b5f..db5eb7246 100644 --- a/lvgl.pc.in +++ b/lvgl.pc.in @@ -5,6 +5,6 @@ libdir=${prefix}/lib Name: lvgl Description: Light and Versatile Graphics Library URL: https://lvgl.io/ -Version: 9.1.0 +Version: @LVGL_VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -llvgl