ws281x include files workaround

This commit is contained in:
LordGrey 2023-10-29 13:32:58 +01:00
parent 3f7ba14093
commit 1b98308718
4 changed files with 25 additions and 5 deletions

3
.gitignore vendored
View File

@ -23,6 +23,9 @@ compile_commands.json
libsrc/flatbufserver/hyperion_reply_generated.h
libsrc/flatbufserver/hyperion_request_generated.h
# Copied ws281x header files
/dependencies/include/ws2811
# Kdevelop project files
*.kdev*

View File

@ -12,6 +12,23 @@ if(ENABLE_DEV_WS281XPWM)
external/rpi_ws281x/pwm.c external/rpi_ws281x/dma.c
external/rpi_ws281x/pcm.c
external/rpi_ws281x/rpihw.c)
#Workaround: Copy ws281x headers to avoid that the "version" file is treated as a header file.
set(WS281X_SOURCE_DIR "${CMAKE_SOURCE_DIR}/dependencies/external/rpi_ws281x")
set(WS281X_DEST_DIR "${CMAKE_SOURCE_DIR}/dependencies/include/ws2811")
file(GLOB WS281X_HEADER_FILES "${WS281X_SOURCE_DIR}/*.h")
message(STATUS "WS281X_SOURCE_DIR = ${WS281X_SOURCE_DIR}")
message(STATUS "WS281X_DEST_DIR = ${WS281X_DEST_DIR}")
message(STATUS "WS281X_HEADER_FILES = ${WS281X_HEADER_FILES}")
add_custom_command(
TARGET ws281x
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${WS281X_DEST_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${WS281X_HEADER_FILES} "${WS281X_DEST_DIR}"
)
endif()
#=============================================================================
@ -133,9 +150,9 @@ endif()
if(ENABLE_PROTOBUF_SERVER)
set(USE_SYSTEM_PROTO_LIBS ${DEFAULT_USE_SYSTEM_PROTO_LIBS} CACHE BOOL "use protobuf library from system")
# defines for 3rd party sub-modules
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "Build abseil-cpp with C++ version requirements propagated")
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "Build abseil-cpp with C++ version requirements propagated")
if (USE_SYSTEM_PROTO_LIBS)
find_package(Protobuf REQUIRED)
@ -163,7 +180,7 @@ if(ENABLE_PROTOBUF_SERVER)
# define the protobuf library
set(PROTOBUF_LIBRARIES protobuf::libprotobuf)
endif()
# redefine at parent scope

View File

@ -60,7 +60,7 @@ if ( ENABLE_DEV_USB_HID )
endif()
if ( ENABLE_DEV_WS281XPWM )
include_directories(../../dependencies/external/rpi_ws281x)
target_include_directories(ws281x PRIVATE "${CMAKE_SOURCE_DIR}/include/ws2811")
FILE ( GLOB Leddevice_PWM_SOURCES "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.h" "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.cpp")
endif()

View File

@ -3,7 +3,7 @@
// LedDevice includes
#include <leddevice/LedDevice.h>
#include <ws2811.h>
#include <ws2811/ws2811.h>
///
/// Implementation of the LedDevice interface for writing to WS281x LED-device via pwm.