Cleanups II.

This commit is contained in:
Christoph Holzheuer
2026-02-10 14:25:06 +01:00
parent afe8588cd3
commit 0ea9ce2e0f
13 changed files with 545 additions and 47 deletions

138
CMakeLists.txt Normal file
View File

@@ -0,0 +1,138 @@
cmake_minimum_required(VERSION 3.16)
# Projektname und unterstützte Sprachen (C++ für Qt, C für die Treiber)
project(BionxControl LANGUAGES CXX C)
# ------------------------------------------------------------------------------
# 1. C++ Standard & Projekt-Einstellungen
# ------------------------------------------------------------------------------
# Du hast C++23 angefordert. Hinweis: Der Compiler muss sehr aktuell sein (GCC 13+ / MSVC 2022)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Automatische Erstellung von MOC, UIC und RCC aktivieren
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# ------------------------------------------------------------------------------
# 2. Qt-Pakete laden
# ------------------------------------------------------------------------------
# Äquivalent zu: QT += core gui widgets svg
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg)
# ------------------------------------------------------------------------------
# 3. Quellcode definieren
# ------------------------------------------------------------------------------
set(PROJECT_SOURCES
main.cpp
bcmainwindow.cpp
bc.cpp
bcdelightpmwidget.cpp
bcdeviceview.cpp
bcdriver.cpp
bcdriverstatewidget.cpp
bcdrivertinycan.cpp
bcthemeswitchbutton.cpp
bctoggleswitch.cpp
bctransmitter.cpp
bcvalue.cpp
bcvaluedelegate.cpp
bcvaluemodel.cpp
bcvalueslider.cpp
bcvaluesliderstyle.cpp
bcxmlloader.cpp
# Deine Header (wichtig, damit sie in der IDE sichtbar sind)
bcmainwindow.h
bc.h
bcdelightpmwidget.h
bcdeviceview.h
bcdriver.h
bcdriverstatewidget.h
bcdrivertinycan.h
bcthemeswitchbutton.h
bctoggleswitch.h
bctransmitter.h
bcvalue.h
bcvaluedelegate.h
bcvaluemodel.h
bcvalueslider.h
BCValueSliderStyle.h
bcxmlloader.h
# UI Forms
bcmainwindow.ui
bcvalueslider.ui
# Resources
bionxcontrol.qrc
)
# ------------------------------------------------------------------------------
# 4. Plattform-Spezifika (Architektur-Entscheidung)
# ------------------------------------------------------------------------------
# Windows-Spezifische Quellen und Libs
if(WIN32)
message(STATUS "Konfiguration für Windows.")
list(APPEND PROJECT_SOURCES
libwin/can_drv_win.c
libwin/mhs_can_drv.c
)
# Falls du die Libs später aktivieren willst (wie im .pro auskommentiert):
# target_link_libraries(BionxControl PRIVATE Advapi32)
# target_link_directories(BionxControl PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/can_api")
endif()
# Linux / Raspberry Pi (ARM) Logik
if(UNIX AND NOT APPLE)
# Check ob wir auf ARM kompilieren (für RPi)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
message(STATUS "Konfiguration für Raspberry Pi (ARM) erkannt.")
# Optimierungs-Flag aus deiner .pro
add_compile_options(-O3)
# Falls du wiringPi oder can Treiber brauchst:
# target_link_libraries(BionxControl PRIVATE wiringPi mhstcan)
endif()
# Hinweis: Im original .pro waren die .c Files auch unter Linux aktiv.
# Falls die C-Treiber auch unter Linux laufen sollen, verschiebe sie
# aus dem if(WIN32) Block nach oben in PROJECT_SOURCES.
endif()
# ------------------------------------------------------------------------------
# 5. Executable erstellen
# ------------------------------------------------------------------------------
qt_add_executable(BionxControl
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Include-Pfade (Äquivalent zu INCLUDEPATH += . libwin)
target_include_directories(BionxControl PRIVATE
.
libwin
)
# ------------------------------------------------------------------------------
# 6. Bibliotheken linken
# ------------------------------------------------------------------------------
target_link_libraries(BionxControl PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::Svg
)
# ------------------------------------------------------------------------------
# 7. Deployment / Installation
# ------------------------------------------------------------------------------
# Äquivalent zu deinem "target.path" Block
install(TARGETS BionxControl
BUNDLE DESTINATION .
RUNTIME DESTINATION bin
)
# Unter Windows: Konsolenfenster unterdrücken (außer im Debug-Mode wenn gewünscht)
if(WIN32)
set_target_properties(BionxControl PROPERTIES WIN32_EXECUTABLE ON)
endif()