256 lines
7.4 KiB
CMake
Executable File
256 lines
7.4 KiB
CMake
Executable File
cmake_minimum_required(VERSION 3.12.4)
|
|
project(lvgl C CXX)
|
|
|
|
# 设置版本号
|
|
set(APP_VERSION "1.0.0")
|
|
set(PROTOCOL_VERSION 0)
|
|
set(DISP_COUNT 1)
|
|
set(TAG_TYPE "70")
|
|
# 根据DISP_COUNT设置APP_ID
|
|
if(${DISP_COUNT} EQUAL 1)
|
|
set(APP_ID "com.eplayer.linux_single.00.$TAG_TYPE")
|
|
set(FIRMWARE_ID "com.eplayer.firmware.linux_single.00.$TAG_TYPE")
|
|
else()
|
|
set(APP_ID "com.eplayer.linux_dual.00.$TAG_TYPE")
|
|
set(FIRMWARE_ID "com.eplayer.firmware.linux_dual.00.$TAG_TYPE")
|
|
endif()
|
|
|
|
|
|
# 从命令行参数获取版本号
|
|
if(DEFINED ENV{APP_VERSION})
|
|
set(APP_VERSION $ENV{APP_VERSION})
|
|
endif()
|
|
if(DEFINED ENV{PROTOCOL_VERSION})
|
|
set(PROTOCOL_VERSION $ENV{PROTOCOL_VERSION})
|
|
endif()
|
|
|
|
if(DEFINED ENV{DISP_COUNT})
|
|
set(DISP_COUNT $ENV{DISP_COUNT})
|
|
endif()
|
|
if(DEFINED ENV{TAG_TYPE})
|
|
set(TAG_TYPE $ENV{TAG_TYPE})
|
|
endif()
|
|
|
|
if(DEFINED ENV{APP_ID})
|
|
set(APP_ID $ENV{APP_ID})
|
|
endif()
|
|
if(DEFINED ENV{FIRMWARE_ID})
|
|
set(FIRMWARE_ID $ENV{FIRMWARE_ID})
|
|
endif()
|
|
|
|
|
|
|
|
# 生成头文件
|
|
configure_file(
|
|
${PROJECT_SOURCE_DIR}/include/version.h.in
|
|
${PROJECT_SOURCE_DIR}/include/version.h
|
|
)
|
|
|
|
|
|
# Main include files of the project
|
|
include_directories(
|
|
${PROJECT_SOURCE_DIR}/include
|
|
${PROJECT_SOURCE_DIR}/extern/qlibquammapi/include
|
|
${PROJECT_SOURCE_DIR}/extern/qlibcurl/include
|
|
${PROJECT_SOURCE_DIR}/extern/qlibcjson/include
|
|
${PROJECT_SOURCE_DIR}/extern/qlibopenssl/include
|
|
${PROJECT_SOURCE_DIR}/extern/qlibjpegturbo/include
|
|
#${PROJECT_SOURCE_DIR}/extern/libgif/include
|
|
)
|
|
|
|
|
|
# Define options for LVGL with default values (OFF)
|
|
#option(LV_USE_DRAW_SDL "Use SDL draw unit" OFF)
|
|
option(LV_USE_LIBPNG "Use libpng to decode PNG" OFF)
|
|
option(LV_USE_LIBJPEG_TURBO "Use libjpeg turbo to decode JPEG" OFF)
|
|
option(LV_USE_FFMPEG "Use libffmpeg to display video using lv_ffmpeg" OFF)
|
|
option(LV_USE_FREETYPE "Use freetype library" OFF)
|
|
option(CONFIG_LV_BUILD_DEMOS "Build demos" OFF)
|
|
|
|
set_property(GLOBAL PROPERTY LVGL_DRIVERS_USE_SDL OFF)
|
|
|
|
# Set C and C++ standards
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
# Set the output path for the executable
|
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
|
set(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
|
|
|
|
|
# Add LVGL subdirectory
|
|
add_subdirectory(lvgl)
|
|
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR} ) #${SDL2_INCLUDE_DIRS}
|
|
target_compile_definitions(lvgl PUBLIC LV_CONF_INCLUDE_SIMPLE)
|
|
add_executable(e_player
|
|
${PROJECT_SOURCE_DIR}/src/main.c
|
|
${PROJECT_SOURCE_DIR}/src/e_port_disp.c
|
|
${PROJECT_SOURCE_DIR}/src/display/fbdev.c
|
|
${PROJECT_SOURCE_DIR}/src/display/fbdev_10xd.c
|
|
${PROJECT_SOURCE_DIR}/src/display/fbdev2.c
|
|
${PROJECT_SOURCE_DIR}/src/display/fbdev2_10xd.c
|
|
${PROJECT_SOURCE_DIR}/src/e_logger.c
|
|
${PROJECT_SOURCE_DIR}/src/e_player_list.c
|
|
)
|
|
|
|
# Define LVGL configuration as a simple include
|
|
target_compile_definitions(e_player PRIVATE LV_CONF_INCLUDE_SIMPLE)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
# 添加 MQTT 客户端源码
|
|
pkg_check_modules(MOSQUITTO libmosquitto)
|
|
|
|
pkg_check_modules(PNG REQUIRED libpng)
|
|
|
|
include_directories(
|
|
${MOSQUITTO_INCLUDE_DIRS}
|
|
${PNG_INCLUDE_DIRS}
|
|
)
|
|
|
|
|
|
link_directories(
|
|
${MOSQUITTO_LIBRARY_DIRS}
|
|
${PNG_LIBRARY_DIRS}
|
|
)
|
|
|
|
add_definitions(
|
|
${MOSQUITTO_CFLAGS_OTHER}
|
|
)
|
|
|
|
|
|
target_link_libraries(e_player PRIVATE
|
|
lvgl
|
|
m
|
|
pthread
|
|
${PNG_LIBRARIES}
|
|
)
|
|
|
|
|
|
add_custom_target(run COMMAND ${EXECUTABLE_OUTPUT_PATH}/e_player DEPENDS e_player)
|
|
|
|
|
|
# 加载so库
|
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/libs)
|
|
file(GLOB SO_FILES
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibquammapi/qm10xd_linux/*.so"
|
|
#"${PROJECT_SOURCE_DIR}/extern/qlibquammapi/qm10xd_linux/quamm/*.so"
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibcurl/qm10xd_linux/lib/*.so"
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibcjson/qm10xd_linux/*.so"
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibopenssl/qm10xd_linux/lib/*.so"
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibjpegturbo/qm10xd_linux/*"
|
|
"${PROJECT_SOURCE_DIR}/extern/libhardware.so"
|
|
#"${PROJECT_SOURCE_DIR}/extern/libgif/lib/libgif.so"
|
|
)
|
|
|
|
|
|
# 排除特定文件
|
|
list(REMOVE_ITEM SO_FILES
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibquammapi/qm10xd_linux/libquamm_kwswakeup.so"
|
|
"${PROJECT_SOURCE_DIR}/extern/qlibquammapi/qm10xd_linux/libbootanimation_client.so"
|
|
)
|
|
|
|
file(COPY ${SO_FILES} DESTINATION ${CMAKE_BINARY_DIR}/libs/)
|
|
|
|
|
|
# 修改链接函数,添加版本和依赖信息
|
|
function(link_custom_so target name path)
|
|
if(NOT TARGET ${name})
|
|
add_library(${name} SHARED IMPORTED GLOBAL)
|
|
set_target_properties(${name} PROPERTIES
|
|
IMPORTED_LOCATION "${path}"
|
|
IMPORTED_NO_SONAME TRUE
|
|
)
|
|
# 可选:添加版本信息
|
|
get_filename_component(so_dir "${path}" DIRECTORY)
|
|
if(EXISTS "${so_dir}/${name}.so.version")
|
|
set_target_properties(${name} PROPERTIES
|
|
VERSION "${so_dir}/${name}.so.version"
|
|
)
|
|
endif()
|
|
endif()
|
|
target_link_libraries(${target} PRIVATE ${name})
|
|
endfunction()
|
|
|
|
# 并行处理设置
|
|
include(ProcessorCount)
|
|
ProcessorCount(N)
|
|
if(NOT N EQUAL 0)
|
|
set(CMAKE_JOB_POOL_LINK link_pool_job${N})
|
|
set(CMAKE_JOB_POOLS link_pool_job${N}=${N})
|
|
endif()
|
|
|
|
# 注册所有SO库
|
|
file(GLOB COPIED_SO_FILES "${CMAKE_BINARY_DIR}/libs/lib*.so")
|
|
foreach(so_file ${COPIED_SO_FILES})
|
|
get_filename_component(so_we "${so_file}" NAME_WE)
|
|
# 移除可能的lib前缀
|
|
string(REGEX REPLACE "^lib" "" so_we ${so_we})
|
|
message(STATUS "Registering target: ${so_we} from ${so_file}")
|
|
link_custom_so(e_player ${so_we} "${so_file}")
|
|
endforeach()
|
|
|
|
|
|
# Apply additional compile options if the build type is Debug
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
message(STATUS "Debug mode enabled")
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
# macOS上Clang的特定设置
|
|
target_compile_options(lvgl PRIVATE
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
-Wshadow
|
|
-Wundef
|
|
-Wpointer-arith
|
|
-Wcast-align
|
|
-Wstrict-prototypes
|
|
-Wmissing-prototypes
|
|
-Wunreachable-code
|
|
-Wfloat-conversion
|
|
)
|
|
else()
|
|
# 保留原有的GCC警告选项
|
|
target_compile_options(lvgl PRIVATE
|
|
-pedantic-errors
|
|
-Wall
|
|
-Wclobbered
|
|
-Wdeprecated
|
|
-Wdouble-promotion
|
|
-Wempty-body
|
|
-Wextra
|
|
-Wformat-security
|
|
-Wmaybe-uninitialized
|
|
|
|
# -Wmissing-prototypes
|
|
-Wpointer-arith
|
|
-Wmultichar
|
|
-Wno-pedantic # ignored for now, we convert functions to pointers for properties table.
|
|
-Wreturn-type
|
|
-Wshadow
|
|
-Wshift-negative-value
|
|
-Wsizeof-pointer-memaccess
|
|
-Wtype-limits
|
|
-Wundef
|
|
-Wuninitialized
|
|
-Wunreachable-code
|
|
-Wfloat-conversion
|
|
-Wstrict-aliasing
|
|
)
|
|
endif()
|
|
|
|
if(ASAN)
|
|
message(STATUS "AddressSanitizer enabled")
|
|
|
|
# Add AddressSanitizer flags
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
|
|
else()
|
|
message(STATUS "AddressSanitizer disabled")
|
|
endif()
|
|
endif()
|