hyperion.ng/libsrc/leddevice/CMakeLists.txt
LordGrey 733aa662bf
Refactor Python for 3.12 integration (#1807)
* Correct JS requestConfig call

* Update requestWriteConfig to new API format

* Add hyperion-light and bare-minimum preset scenarios

* Refactor Python

* Windows add bcrypt until mbedtls  is fixed
(https://github.com/Mbed-TLS/mbedtls/pull/9554)

* Corrections

* Use ScreenCaptureKit under macOS 15 and above

* ReSigning macOS package

* Python 3.11.10 test

* Revert "Python 3.11.10 test"

This reverts commit ee921e4f1284fe3d984d9422b24a1c56c6916c21.

* Handle defined exits from python scripts

* Update change.log

* CodeQL findings

---------

Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2024-12-01 17:08:25 +01:00

185 lines
5.2 KiB
CMake

# Define the current source locations
set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/leddevice)
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/leddevice)
if(ENABLE_DEV_NETWORK)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network REQUIRED)
endif()
if(ENABLE_DEV_SERIAL)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS SerialPort REQUIRED)
endif()
include_directories(
dev_hid
dev_net
dev_other
dev_serial
dev_spi
dev_rpi_pwm
dev_tinker
dev_ftdi
)
file (GLOB Leddevice_SOURCES
"${CURRENT_HEADER_DIR}/*.h"
"${CURRENT_SOURCE_DIR}/*.h"
"${CURRENT_SOURCE_DIR}/*.cpp"
"${CURRENT_SOURCE_DIR}/dev_other/*.h"
"${CURRENT_SOURCE_DIR}/dev_other/*.cpp"
)
if(ENABLE_OSX OR WIN32)
list(REMOVE_ITEM Leddevice_SOURCES "${CURRENT_SOURCE_DIR}/dev_other/LedDevicePiBlaster.h")
list(REMOVE_ITEM Leddevice_SOURCES "${CURRENT_SOURCE_DIR}/dev_other/LedDevicePiBlaster.cpp")
endif()
if(ENABLE_DEV_NETWORK)
file (GLOB Leddevice_NETWORK_SOURCES "${CURRENT_SOURCE_DIR}/dev_net/*.h" "${CURRENT_SOURCE_DIR}/dev_net/*.cpp")
endif()
if(ENABLE_DEV_SERIAL)
file (GLOB Leddevice_SERIAL_SOURCES "${CURRENT_SOURCE_DIR}/dev_serial/*.h" "${CURRENT_SOURCE_DIR}/dev_serial/*.cpp")
endif()
if(ENABLE_DEV_SPI)
file (GLOB Leddevice_SPI_SOURCES "${CURRENT_SOURCE_DIR}/dev_spi/*.h" "${CURRENT_SOURCE_DIR}/dev_spi/*.cpp")
endif()
if(ENABLE_DEV_TINKERFORGE)
file (GLOB Leddevice_TINKER_SOURCES "${CURRENT_SOURCE_DIR}/dev_tinker/*.h" "${CURRENT_SOURCE_DIR}/dev_tinker/*.cpp")
endif()
if(ENABLE_DEV_USB_HID)
find_package(libusb-1.0 REQUIRED)
include_directories(
${CMAKE_SOURCE_DIR}/include/hidapi
${LIBUSB_1_INCLUDE_DIRS}
)
file (GLOB Leddevice_USB_HID_SOURCES "${CURRENT_SOURCE_DIR}/dev_hid/*.h" "${CURRENT_SOURCE_DIR}/dev_hid/*.cpp")
endif()
if(ENABLE_DEV_WS281XPWM)
file (GLOB Leddevice_PWM_SOURCES "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.h" "${CURRENT_SOURCE_DIR}/dev_rpi_pwm/*.cpp")
endif()
if (ENABLE_DEV_FTDI)
FILE ( GLOB Leddevice_FTDI_SOURCES "${CURRENT_SOURCE_DIR}/dev_ftdi/*.h" "${CURRENT_SOURCE_DIR}/dev_ftdi/*.cpp")
endif()
set(LedDevice_RESOURCES ${CURRENT_SOURCE_DIR}/LedDeviceSchemas.qrc )
set(Leddevice_SOURCES
${Leddevice_SOURCES}
${LedDevice_RESOURCES}
${Leddevice_NETWORK_SOURCES}
${Leddevice_PWM_SOURCES}
${Leddevice_SERIAL_SOURCES}
${Leddevice_SPI_SOURCES}
${Leddevice_TINKER_SOURCES}
${Leddevice_USB_HID_SOURCES}
${Leddevice_FTDI_SOURCES}
)
# auto generate header file that include all available leddevice headers
# auto generate cpp file for register() calls
file (WRITE "${CMAKE_BINARY_DIR}/LedDevice_headers.h" "#pragma once\n\n//this file is autogenerated, don't touch it\n\n")
file (WRITE "${CMAKE_BINARY_DIR}/LedDevice_register.cpp" "//this file is autogenerated, don't touch it\n\n")
foreach(f ${Leddevice_SOURCES})
# message (STATUS "Add led device: ${f}")
if("${f}" MATCHES "dev_.*/Led.evice.+h$")
GET_FILENAME_COMPONENT(fname ${f} NAME)
file (APPEND "${CMAKE_BINARY_DIR}/LedDevice_headers.h" "#include \"${fname}\"\n")
string(SUBSTRING ${fname} 9 -1 dname)
string(REPLACE ".h" "" dname "${dname}")
file (APPEND "${CMAKE_BINARY_DIR}/LedDevice_register.cpp" "REGISTER(${dname});\n")
endif()
endforeach()
add_library(leddevice ${CMAKE_BINARY_DIR}/LedDevice_headers.h ${Leddevice_SOURCES})
target_link_libraries(leddevice
hyperion
hyperion-utils
${CMAKE_THREAD_LIBS_INIT}
)
if(WIN32)
target_link_libraries(leddevice ws2_32)
endif()
if(ENABLE_DEV_NETWORK)
target_link_libraries(leddevice Qt${QT_VERSION_MAJOR}::Network ssdp)
if(NOT DEFAULT_USE_SYSTEM_MBEDTLS_LIBS)
if(MBEDTLS_LIBRARIES)
include_directories(${MBEDTLS_INCLUDE_DIR})
target_link_libraries(
leddevice
${MBEDTLS_LIBRARIES}
$<$<BOOL:${WIN32}>:bcrypt.lib>
)
target_include_directories(leddevice PRIVATE ${MBEDTLS_INCLUDE_DIR})
endif (MBEDTLS_LIBRARIES)
endif()
string(REGEX MATCH "[0-9]+|-([A-Za-z0-9_.]+)" MBEDTLS_MAJOR ${MBEDTLS_VERSION})
if(MBEDTLS_MAJOR EQUAL "3")
target_compile_definitions(leddevice PRIVATE USE_MBEDTLS3)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_features(leddevice PRIVATE cxx_std_20)
endif()
endif()
endif()
if(ENABLE_DEV_SERIAL)
target_link_libraries(leddevice Qt${QT_VERSION_MAJOR}::SerialPort)
endif()
if(ENABLE_DEV_TINKERFORGE)
target_link_libraries(leddevice tinkerforge)
endif()
if(ENABLE_DEV_WS281XPWM)
target_include_directories(leddevice PUBLIC "${CMAKE_SOURCE_DIR}/dependencies/external/rpi_ws281x")
target_link_libraries(leddevice ws281x)
endif()
if(ENABLE_DEV_USB_HID)
if(APPLE)
target_link_libraries(leddevice ${LIBUSB_1_LIBRARIES} hidapi-mac)
else()
target_link_libraries(leddevice ${LIBUSB_1_LIBRARIES} hidapi-libusb)
endif()
if(NOT WIN32)
include(CheckCSourceCompiles)
# Glibc compatibilty check
check_c_source_compiles("
#include <time.h>
#include <sys/time.h>
int main() {
struct timespec t;
return clock_gettime(CLOCK_REALTIME, &t);
}
" GLIBC_HAS_CLOCK_GETTIME)
if(NOT GLIBC_HAS_CLOCK_GETTIME)
target_link_libraries(leddevice rt)
endif()
endif()
endif()
if(ENABLE_MDNS)
target_link_libraries(leddevice mdns)
endif()
if( ENABLE_DEV_FTDI )
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIB_FTDI REQUIRED IMPORTED_TARGET libftdi1 )
target_include_directories(leddevice PRIVATE PkgConfig::LIB_FTDI)
target_link_libraries(leddevice PkgConfig::LIB_FTDI)
endif()