Skip to content

Commit 336678b

Browse files
authored
Cmake overhaul and more (#104)
* cmake overhaul * fix gcc warning * fix sim compile * add includes to test build
1 parent 2944175 commit 336678b

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

CMakeLists.txt

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@ set(LV_USE_LINUX_DRM ON)
1616
set(LV_CONF_BUILD_DISABLE_DEMOS 1)
1717
set(LV_CONF_BUILD_DISABLE_EXAMPLES 1)
1818
add_subdirectory(lvgl)
19+
20+
# Set include directories for LVGL BEFORE any other targets
1921
target_include_directories(lvgl PUBLIC
2022
${PROJECT_SOURCE_DIR}
21-
/usr/include/libdrm
22-
/usr/include/drm
23+
${PROJECT_SOURCE_DIR}/lvgl
2324
)
2425
set(CMAKE_C_STANDARD 99) # LVGL officially supports C99 and above
2526
set(CMAKE_CXX_STANDARD 17) #C17
2627
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2728

29+
pkg_check_modules(LIBDRM REQUIRED libdrm)
30+
pkg_check_modules(CAIRO IMPORTED_TARGET REQUIRED cairo)
31+
pkg_check_modules(SPDLOG REQUIRED spdlog)
32+
2833
find_package(PNG REQUIRED)
34+
find_package(fmt REQUIRED)
35+
find_package(spdlog REQUIRED)
36+
2937
include_directories(${PNG_INCLUDE_DIR})
3038

3139
# Simulator
@@ -80,7 +88,6 @@ set(SIMULATOR_SOURCES
8088
src/input.h
8189
src/input.cpp
8290
)
83-
# LVGL setup
8491

8592
add_compile_options("-Wno-address-of-packed-member")
8693

@@ -157,32 +164,55 @@ set(SOURCE_FILES
157164
file(GLOB ICONS src/icons/*.png)
158165
file(GLOB OSD_CONFIGS *_osd.json)
159166

160-
include_directories("/usr/include/libdrm" "/usr/include/cairo" "/usr/include/spdlog")
161-
162167
configure_file("${PROJECT_NAME}_config.h.in" "${PROJECT_NAME}_config.h")
163168

164169
if(USE_SIMULATOR)
165170
add_definitions(-DUSE_SIMULATOR)
166171
target_compile_definitions(lvgl PRIVATE USE_SIMULATOR)
167172
pkg_check_modules(LIBSDL REQUIRED sdl2)
168-
add_executable(${PROJECT_NAME} ${SIMULATOR_SOURCES} lvgl)
169-
target_link_libraries(${PROJECT_NAME} lvgl ${LIBSDL_LIBRARIES} ${PNG_LIBRARIES})
173+
add_executable(${PROJECT_NAME} ${SIMULATOR_SOURCES})
174+
target_link_libraries(${PROJECT_NAME} lvgl ${LIBSDL_LIBRARIES} ${PNG_LIBRARIES} ${LIBDRM_LIBRARIES})
170175
else()
171-
find_package(spdlog REQUIRED)
172176
find_package(nlohmann_json 3 REQUIRED)
173177
find_package(yaml-cpp REQUIRED)
174178
pkg_check_modules(LIBGPIOD REQUIRED libgpiod)
175-
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
176-
target_link_libraries(${PROJECT_NAME} rockchip_mpp pthread drm m cairo spdlog::spdlog nlohmann_json::nlohmann_json yaml-cpp rt lvgl ${LIBGPIOD_LIBRARIES} ${PNG_LIBRARIES})
177-
# Embed gstreamer
179+
include_directories(${LIBGPIOD_INCLUDE_DIR})
180+
181+
# GStreamer setup
178182
find_package(PkgConfig REQUIRED)
179183
pkg_search_module(GST REQUIRED
180184
gstreamer-1.0>=1.4
181185
gstreamer-app-1.0>=1.4
182186
)
183187
pkg_search_module(gstreamer REQUIRED IMPORTED_TARGET gstreamer-1.0>=1.4)
184188
pkg_search_module(gstreamer-app REQUIRED IMPORTED_TARGET gstreamer-app-1.0>=1.4)
185-
target_link_libraries(${PROJECT_NAME} PkgConfig::gstreamer PkgConfig::gstreamer-app)
189+
190+
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
191+
192+
# Add include directories for the main target
193+
target_include_directories(${PROJECT_NAME} PRIVATE
194+
${PROJECT_SOURCE_DIR}
195+
${PROJECT_SOURCE_DIR}/lvgl
196+
${LIBDRM_INCLUDE_DIRS}
197+
)
198+
199+
target_link_libraries(${PROJECT_NAME}
200+
rockchip_mpp
201+
pthread
202+
drm
203+
m
204+
PkgConfig::CAIRO
205+
spdlog::spdlog
206+
fmt::fmt
207+
nlohmann_json::nlohmann_json
208+
yaml-cpp
209+
rt
210+
lvgl
211+
${LIBGPIOD_LIBRARIES}
212+
${PNG_LIBRARIES}
213+
PkgConfig::gstreamer
214+
PkgConfig::gstreamer-app
215+
)
186216
endif()
187217

188218
if(CMAKE_BUILD_TYPE MATCHES "Debug")
@@ -215,7 +245,7 @@ if(BUILD_TESTS)
215245

216246
# Test executable
217247
add_executable(pixelpilot_tests ${LIB_SOURCE_FILES} ${TEST_SOURCES})
218-
target_include_directories(pixelpilot_tests PUBLIC "${PROJECT_BINARY_DIR}")
248+
target_include_directories(pixelpilot_tests PUBLIC "${PROJECT_BINARY_DIR}" ${LIBDRM_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS})
219249
# Define the TEST preprocessor directive
220250
target_compile_definitions(pixelpilot_tests PRIVATE TEST)
221251
target_link_libraries(pixelpilot_tests rockchip_mpp pthread drm m cairo spdlog::spdlog nlohmann_json::nlohmann_json yaml-cpp rt lvgl ${LIBGPIOD_LIBRARIES} ${PNG_LIBRARIES} Catch2::Catch2WithMain)

src/gsmenu/helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ void gsmenu_toggle_rxmode() {
935935
lv_obj_add_flag(air_aalink_cont, LV_OBJ_FLAG_HIDDEN);
936936
setenv("REMOTE_IP" , "10.5.0.10", 1);
937937
setenv("AIR_FIRMWARE_TYPE" , "wfb", 1);
938+
#ifndef USE_SIMULATOR
938939
wifi_rssi_monitor_reset();
940+
#endif
939941
break;
940942

941943
default:

src/input.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
#include <yaml-cpp/yaml.h>
1111
#include <glob.h>
1212
#include "main.h"
13-
#include "../../lvgl/lvgl.h"
14-
#include "../../lvgl/src/core/lv_global.h"
13+
#include "lvgl/lvgl.h"
1514
#include "input.h"
1615
#include "gsmenu/gs_system.h"
1716

src/input.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#define INPUT_H
44

55
#include <stdint.h>
6-
#include "../lvgl/lvgl.h"
7-
#include "../lvgl/src/core/lv_global.h"
6+
#include "lvgl/lvgl.h"
87

98
typedef enum {
109
GSMENU_CONTROL_MODE_NAV = 0,

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ void read_gstreamerpipe_stream(MppPacket *packet, int gst_udp_port, const char *
593593
void set_control_verbose(MppApi * mpi, MppCtx ctx,MpiCmd control,RK_U32 enable){
594594
RK_U32 res = mpi->control(ctx, control, &enable);
595595
if(res){
596-
spdlog::warn("Could not set control {} {}", control, enable);
596+
spdlog::warn("Could not set control {} {}", static_cast<int>(control), enable);
597597
assert(false);
598598
}
599599
}

0 commit comments

Comments
 (0)