Lin_Simulator/cpp/CMakeLists.txt
Mohamed Salem b808770573 Step 1: GUI skeleton for LIN Simulator (Python + C++)
- PyQt6 main window with Tx/Rx tables, connection dock, LDF toolbar,
  control bar with global send rate, and status bar
- C++ Qt6 equivalent with identical layout and feature parity
- About dialog: TeqanyLogix LTD / Developer: Mohamed Salem
- Application logo (SVG + PNG) with LIN bus waveform design
- Full test suites: Python (32 tests), C++ QTest (34 tests)
- Project plan and Step 1 documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 16:40:52 +02:00

89 lines
3.2 KiB
CMake

# CMakeLists.txt — Build configuration for the LIN Simulator (C++)
#
# CMAKE BASICS:
# =============
# CMake is a build system generator. It doesn't compile code directly.
# Instead, it generates platform-specific build files:
# - macOS/Linux: Makefiles (then you run `make`)
# - Windows: Visual Studio project files
# - Any platform: Ninja build files (faster than Make)
#
# The workflow is:
# 1. mkdir build && cd build
# 2. cmake .. ← generates build files from this CMakeLists.txt
# 3. cmake --build . ← compiles and links the project
# 4. ./lin_simulator ← run the application
#
# Qt6 integration:
# CMake has built-in support for Qt via find_package(Qt6).
# Qt needs special preprocessing for its features:
# - MOC (Meta-Object Compiler): processes Q_OBJECT macros for signals/slots
# - UIC: compiles .ui designer files to C++ headers (we don't use these)
# - RCC: compiles resource files (icons, etc.) into the binary
cmake_minimum_required(VERSION 3.16)
project(LINSimulator
VERSION 0.1.0
LANGUAGES CXX
DESCRIPTION "LIN Simulator using BabyLIN devices"
)
# C++17 standard — required for structured bindings, std::optional, etc.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ── Qt6 auto-processing ──
# These three lines enable Qt's special preprocessors:
# AUTOMOC: automatically runs MOC on headers containing Q_OBJECT
# AUTOUIC: automatically compiles .ui files (if we had any)
# AUTORCC: automatically compiles .qrc resource files
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# ── Find Qt6 ──
# find_package searches for Qt6 on the system.
# REQUIRED means CMake will error if Qt6 is not found.
# COMPONENTS lists which Qt modules we need:
# Widgets: GUI widgets (QMainWindow, QPushButton, etc.)
# We'll add SerialPort in Step 5 when we need device communication.
find_package(Qt6 REQUIRED COMPONENTS Widgets)
# ── Main application target ──
# qt_add_executable is Qt's wrapper around add_executable.
# It handles platform-specific details (macOS app bundle, Windows subsystem, etc.)
qt_add_executable(lin_simulator
src/main.cpp
src/main_window.cpp
src/main_window.h
)
# Link against Qt6 Widgets library
# PRIVATE means this dependency is only for building this target,
# not propagated to anything that depends on us.
target_link_libraries(lin_simulator PRIVATE Qt6::Widgets)
# ── Tests ──
# We use Qt's built-in test framework (QTest) instead of GoogleTest
# because it integrates naturally with Qt's event loop and widgets.
# QTest provides:
# - QVERIFY(condition): assert a condition is true
# - QCOMPARE(actual, expected): assert two values are equal
# - QTest::mouseClick(): simulate mouse events
# - QTest::keyClick(): simulate keyboard events
enable_testing()
find_package(Qt6 REQUIRED COMPONENTS Test)
qt_add_executable(test_main_window
tests/test_main_window.cpp
src/main_window.cpp
src/main_window.h
)
target_link_libraries(test_main_window PRIVATE Qt6::Widgets Qt6::Test)
target_include_directories(test_main_window PRIVATE src)
# Register the test with CTest so `ctest` can discover and run it
add_test(NAME test_main_window COMMAND test_main_window)