mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(cmake): declspecs usage for msvc (#5190)
This commit is contained in:
parent
278d8cf2a2
commit
97aef2bfa5
@ -18,10 +18,19 @@ else()
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/custom.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/custom.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#[[
|
||||||
|
unfortunately CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS does not work for global data.
|
||||||
|
for global data we still need decl specs.
|
||||||
|
Check out the docs to learn more about the limitations of CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
|
||||||
|
https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html#prop_tgt:WINDOWS_EXPORT_ALL_SYMBOLS
|
||||||
|
|
||||||
|
For all compiled sources within the library (i.e. basically all lvgl files) we need to use dllexport.
|
||||||
|
For all compiled sources from outside the library (i.e. files which include lvgl headers) we need to use dllimport.
|
||||||
|
We can do this by using CMakes INTERFACE and PRIVATE keyword.
|
||||||
|
]]
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
if (BUILD_SHARED_LIBS)
|
target_compile_definitions(lvgl
|
||||||
target_compile_definitions(lvgl PUBLIC LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllimport\))
|
INTERFACE LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllimport\)
|
||||||
else()
|
PRIVATE LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllexport\)
|
||||||
target_compile_definitions(lvgl PUBLIC LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllexport\))
|
)
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
@ -205,7 +205,7 @@ typedef struct _lv_global_t {
|
|||||||
#endif
|
#endif
|
||||||
#define LV_GLOBAL_DEFAULT() LV_GLOBAL_CUSTOM()
|
#define LV_GLOBAL_DEFAULT() LV_GLOBAL_CUSTOM()
|
||||||
#else
|
#else
|
||||||
extern lv_global_t lv_global;
|
LV_ATTRIBUTE_EXTERN_DATA extern lv_global_t lv_global;
|
||||||
#define LV_GLOBAL_DEFAULT() (&lv_global)
|
#define LV_GLOBAL_DEFAULT() (&lv_global)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ void lv_font_set_kerning(lv_font_t * font, lv_font_kerning_t kerning);
|
|||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
#define LV_FONT_DECLARE(font_name) extern const lv_font_t font_name;
|
#define LV_FONT_DECLARE(font_name) LV_ATTRIBUTE_EXTERN_DATA extern const lv_font_t font_name;
|
||||||
|
|
||||||
#if LV_FONT_MONTSERRAT_8
|
#if LV_FONT_MONTSERRAT_8
|
||||||
LV_FONT_DECLARE(lv_font_montserrat_8)
|
LV_FONT_DECLARE(lv_font_montserrat_8)
|
||||||
|
@ -445,7 +445,7 @@ static inline void lv_color16_premultiply(lv_color16_t * c, lv_opa_t a)
|
|||||||
#include "lv_palette.h"
|
#include "lv_palette.h"
|
||||||
#include "lv_color_op.h"
|
#include "lv_color_op.h"
|
||||||
|
|
||||||
extern const lv_color_filter_dsc_t lv_color_filter_shade;
|
LV_ATTRIBUTE_EXTERN_DATA extern const lv_color_filter_dsc_t lv_color_filter_shade;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /*extern "C"*/
|
} /*extern "C"*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user