Dixon/src/RobotNode/CMakeLists.txt
Russell Gilbert 3a4e00a409 Adds basic logging and refactors main loop
Adds a basic logging system using std::clog with color codes for different log levels.
Refactors the main loop to use the logging system and improve readability.
Changes DixonNodeState to use atomic exchange for setting node status and logs status changes.
Removes the old main.cpp and adds a new one that uses a separate thread for signal handling.
Updates the CMakeLists.txt to link against gpiod and spdlog.
Moves version information into a version.txt file and creates a custom target to bump the version using a python script.
2026-02-20 15:27:42 +00:00

53 lines
No EOL
1.7 KiB
CMake

cmake_minimum_required(VERSION 3.10)
# Define the Version Bumper Target
# This target is like a "recipe" that isn't cooked until we ask for it.
add_custom_target(BumpVersion
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/bump_version.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Bumping version in version.txt..."
)
# Read the version for the Project metadata
# This still happens during "Reload" so CMake knows the project version.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" RAW_VERSION)
string(STRIP "${RAW_VERSION}" DIXON_VERSION_FROM_FILE)
message(STATUS "Dixon Version detected from file: ${DIXON_VERSION_FROM_FILE}")
# Use that variable in your project definition
project(Dixon VERSION ${DIXON_VERSION_FROM_FILE} LANGUAGES CXX)
# Forces the compiler to use C++20 features
set(CMAKE_CXX_STANDARD 20)
# Define the executable and its source files
add_executable(dixon
main.cpp
DixonNodeState.cpp
DixonNodeState.h
DixonBrain.cpp
DixonBrain.h
CardioCenter/Heart.cpp
CardioCenter/Heart.h
Logging/DixonLogger.h)
# Create the Dependency
# This tells CMake: "Before you build Dixon, you MUST run BumpVersion."
add_dependencies(dixon BumpVersion)
# Generate the header from the template
configure_file(Version.h.in "${CMAKE_CURRENT_BINARY_DIR}/Version.h")
# Consolidated Include Paths
target_include_directories(dixon PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}" # For generated Version.h
)
# Link the gpiod & spdlog libraries
target_link_libraries(dixon PRIVATE
gpiodcxx
gpiod)
# Tell the linker: "Trust me, the Pi has the rest of the C++ and C libraries"
target_link_options(dixon PRIVATE "-Wl,--allow-shlib-undefined")