lvgl / lv_port_linux

LVGL configured to work with a standard Linux framebuffer
MIT License
260 stars 160 forks source link

How to add nativeapp to Cmakelist? #48

Closed LIMINNAN closed 8 months ago

LIMINNAN commented 8 months ago
.
├── bin
│   └── main
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── cmake_install.cmake
│   ├── lib
│   ├── lvgl
│   └── Makefile
├── CMakeLists.txt
├── custom
│   ├── custom.c
│   ├── custom.h
│   ├── custom.mk
│   ├── custom.py
│   ├── lv_conf_ext.h
│   ├── mp1544294806.png
│   ├── mp-1789058473.png
│   ├── spectrum_1.h
│   ├── spectrum_2.h
│   └── spectrum_3.h
├── generated
│   ├── events_init.c
│   ├── events_init.h
│   ├── generated.mk
│   ├── guider_customer_fonts
│   ├── guider_fonts
│   ├── gui_guider.c
│   ├── gui_guider.h
│   ├── images
│   └── setup_scr_screen.c
├── include
│   ├── include.mk
│   ├── lvgl_config.h
│   └── lvgl_utils.h
├── LICENSE
├── lv_conf.h
├── lvgl
│   ├── CMakeLists.txt
│   ├── component.mk
│   ├── demos
│   ├── docs
│   ├── env_support
│   ├── examples
│   ├── idf_component.yml
│   ├── Kconfig
│   ├── library.json
│   ├── library.properties
│   ├── LICENCE.txt
│   ├── lv_conf_template.h
│   ├── lvgl.h
│   ├── lvgl.mk
│   ├── lvgl.pc.in
│   ├── README.md
│   ├── SConscript
│   ├── scripts
│   ├── src
│   └── tests
├── main.c
├── Makefile
├── README.md
└── source
    └── source.mk

here ,i wanna to add custom/generated files to cmakelist for complaier,but not know how to edit it.

liamHowatt commented 8 months ago

@LIMINNAN

https://github.com/lvgl/lv_port_linux_frame_buffer/blob/dccc6a1ca48372aa993dbea7a8e17dec6f42df6a/CMakeLists.txt#L13

You can change this line to

add_executable(main main.c mouse_cursor_icon.c custom/*.c generated/*.c)
LIMINNAN commented 8 months ago

└── lvgl_Demo ├── build // 可执行文件二进制 ├── custom // GUI_GUIDER生成文件 │ ├── custom.c // #include "lvgl.h" 无法找到,需要更改为 #include "../lvgl/lvgl.h" │ ├── custom.h │ ├── custom.mk │ ├── custom.py │ ├── lv_conf_ext.h │ ├── mp1544294806.png │ ├── mp-1789058473.png │ ├── spectrum_1.h │ ├── spectrum_2.h │ └── spectrum_3.h ├── generated │ ├── events_init.c // #include "lvgl.h" 无法找到,需要更改为 #include "../lvgl/lvgl.h" │ ├── events_init.h │ ├── generated.mk │ ├── guider_customer_fonts │ │ ├── guider_customer_fonts.h │ │ └── guider_customer_fonts.mk │ ├── guider_fonts │ │ ├── guider_fonts.h │ │ ├── guider_fonts.mk │ │ ├── lv_font_arial_16.c // #include "lvgl.h" 无法找到,需要更改为 #include "../lvgl/lvgl.h" │ │ ├── lv_font_arial_20.c // ... │ │ ├── lv_font_arial_23.c │ │ ├── lv_font_arial_26.c │ │ ├── lv_font_simsun_18.c │ │ └── lv_font_simsun_20.c │ ├── gui_guider.c │ ├── gui_guider.h │ ├── images │ │ ├── _btn_list_pause_alpha_70x70.c // ... │ │ ├── _btn_list_play_alpha_70x70.c │ │ ├── _btn_loop_alpha_25x25.c │ │ ├── _btn_next_alpha_61x61.c │ │ ├── _btn_pause_alpha_80x80.c │ │ ├── _btn_play_alpha_80x80.c │ │ ├── _btn_prev_alpha_61x61.c │ │ ├── _btn_rnd_alpha_25x25.c │ │ ├── _cover_1_alpha_175x175.c │ │ ├── _cover_2_alpha_175x175.c │ │ ├── _cover_3_alpha_175x175.c │ │ ├── _icn_chart_alpha_25x25.c │ │ ├── _icn_chat_alpha_25x25.c │ │ ├── _icn_download_alpha_25x25.c │ │ ├── _icn_heart_alpha_25x25.c │ │ ├── _icn_slider_alpha_25x25.c │ │ ├── images.mk │ │ ├── _wave_bottom_alpha_800x51.c │ │ └── _wave_top_alpha_800x51.c │ └── setup_scr_screen.c ├── lv_drivers │ ├── CMakeLists.txt │ ├── lvgl │ ├── CMakeLists.txt │ ├── component.mk │ ├── demos │ ├── ... ├── main.c ├── main.o ├── Makefile └── tree.txt


- 9.0 version of cmakelist does not support GUI_GUIDER I replaced 8.3.10 lvgl, this is my MakeFile    
- 

Makefile

Directory settings

makefile_name := $(abspath $(lastword $(MAKEFILE_LIST))) makefile_path := $(strip $(patsubst %/,% , $(dir $(makefile_name)))) libfile_path := $(makefile_path)/../lib/x86 LVGL_DIR ?= ${shell pwd} PRJ_DIR := $(LVGL_DIR) LVGL_DIR_NAME ?= lvgl

BUILD_DIR := build/ OBJ_DIR := $(BUILD_DIR)object/ GEN_OBJ_DIR := $(OBJ_DIR)generated/ BIN_DIR := $(BUILD_DIR)bin/

NORMAL_OUT := 1

RM := rm -f RMDIR := rm -rf

ifeq ($(OS),Windows_NT) LDFLAGS += -LSDL2\i686-w64-mingw32\lib SIMULATOR_EXE = simulator.exe BUILD_ENV := build\object build\bin NULL_OUT := nul MKDIR_P = mkdir else SIMULATOR_EXE = simulator NULL_OUT := /dev/null MKDIR_P = mkdir -p endif

Compiler settings

CC ?= gcc CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -Wall -Wshadow -Wundef -Wmissing-prototypes \ -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function \ -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing \ -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized \ -Wno-unused-parameter -Wno-missing-field-initializers \ -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral \ -Wno-cast-qual -Wunreachable-code -Wno-switch-default \ -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers \ -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes \ -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body \ -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 \ -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers \ -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra \ -Wno-unused-parameter -Wno-missing-field-initializers \ -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral \ -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes \ -Wunreachable-code -Wno-switch-default -Wreturn-type \ -Wmultichar -Wno-discarded-qualifiers -Wformat-security \ -Wno-ignored-qualifiers -Wno-sign-compare

CFLAGS += -DLV_CONF_INCLUDE_SIMPLE=1

ifeq ($(OS),Windows_NT) LDFLAGS := -lSDL2 -L$(libfile_path) -ldecoder -lopenh264 -lrlottie -lstdc++ -lm else LDFLAGS := -lSDL2 -L$(libfile_path) -ldecoder -lopenh264 -lrlottie -lpthread -lstdc++ -lm -ldl endif

ifeq ($(OS),Windows_NT)

SDL2

CFLAGS += "-ISDL2\i686-w64-mingw32\include" -MMD -MP endif

Binary name

BIN := $(BIN_DIR)demo

Collect the files to compile

MAINSRC := ./main.c

DEPPATH += --dep-path $(makefile_path)/ VPATH += :$(makefile_path)/ CFLAGS += "-I$(makefile_path)/"

include $(LVGL_DIR)/lvgl/lvgl.mk include $(LVGL_DIR)/lv_drivers/lv_drivers.mk include $(PRJ_DIR)/custom/custom.mk include $(PRJ_DIR)/generated/generated.mk

CSRCS += main.c DEPPATH += --dep-path $(makefile_path)/ VPATH += :$(makefile_path)/ CFLAGS += "-I$(makefile_path)/"

ifeq ($(OS),Windows_NT)

SDL2

CFLAGS += "-ISDL2\i686-w64-mingw32\include" -MMD -MP endif

OBJEXT := .o

AOBJS = $(addprefix $(OBJ_DIR),$(ASRCS:.S=$(OBJEXT))) COBJS = $(addprefix $(OBJ_DIR),$(CSRCS:.c=$(OBJEXT))) DEPS = $(addprefix $(OBJ_DIR),$(CSRCS:.c=.d)) GEN_AOBJS = $(addprefix $(GEN_OBJ_DIR),$(GEN_ASRCS:.S=$(OBJEXT))) GEN_COBJS = $(addprefix $(GEN_OBJ_DIR),$(GEN_CSRCS:.c=$(OBJEXT)))

DEPS += $(addprefix $(GEN_OBJ_DIR),$(GEN_CSRCS:.c=.d))

SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) GEN_SRCS = $(GEN_ASRCS) $(GEN_CSRCS) GEN_OBJS = $(GEN_AOBJS) $(GEN_COBJS)

.PHONY: all env clean default cp_lib clean_gen run ifeq ($(OS),Windows_NT) all: env default cp_lib else all: env default endif

monitor header files

-include $(DEPS)

ifeq ($(OS),Windows_NT) env: @if not exist "build/bin" $(MKDIR_P) "build/bin" @if not exist "build/object/generated" $(MKDIR_P) "build/object/generated" else env: @if [ ! -d "build/bin" ]; then $(MKDIR_P) build/bin; fi @if [ ! -d "build/object/generated" ]; then $(MKDIR_P) build/object/generated; fi endif $(OBJ_DIR)main.o: main.c @echo "Compiling $(makefile_path)/$<" @$(CC) $(CFLAGS) -c $< -o $@

$(OBJ_DIR)%.o: %.c @echo "Compiling $<" @$(CC) $(CFLAGS) -c $< -o $@

$(GEN_OBJ_DIR)%.o: %.c @echo "Compiling $<" @$(CC) $(CFLAGS) -c $< -o $@

default: $(OBJS) $(GEN_OBJS) @echo "Linking $(SIMULATOR_EXE)" @$(CC) -o $(BIN_DIR)$(SIMULATOR_EXE) $(OBJS) $(GEN_OBJS) $(LDFLAGS)

cp_lib: -@cp SDL2/lib/SDL2.dll build/bin/SDL2.dll $(NORMAL_OUT)>$(NULL_OUT) -@cp SDL2/lib/libopenh264.dll build/bin/libopenh264.dll $(NORMAL_OUT)>$(NULL_OUT)

clean: -@$(RMDIR) build

gen_images := $(wildcard $(PRJ_DIR)/generated/images/.c) gen_srcs := $(gen_images) $(wildcard $(PRJ_DIR)/generated/.c) $(wildcard $(PRJ_DIR)/generated/*.h)

ifeq ($(OS),Windows_NT) clean_gen_img: -@rm $(gen_images)

clean_gen: clean_gen_img -@rm $(gen_srcs) run: build\bin\simulator.exe else

clean_gen_img: $(RM) $(LVGL_DIR)/generated/images/*.c

clean_gen: clean_gen_img $(RM) $(LVGL_DIR)/generated/.c $(RM) $(LVGL_DIR)/generated/.h endif

LIMINNAN commented 8 months ago

编译Makefile时报错:

In file included from main.c:11:
generated/gui_guider.h:13:10: fatal error: lvgl.h: 没有那个文件或目录
   13 | #include "lvgl.h"
      |          ^~~~~~~~
compilation terminated.

Makefile:

PRJ_DIR := $(makefile_path)/..
LVGL_DIR := $(PRJ_DIR)
SIMULATOR_DIR := $(makefile_path)
LVGL_DIR_NAME ?= lvgl

CFLAGS += -I$(LVGL_DIR)/$(LVGL_DIR_NAME)/

I think and adding CFLAGS contains "lvgl/lvgl.h",why?still con't fine 13 | #include "lvgl.h" | ^~~~