Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions CMAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ flowchart TD

### Configuration Layer

- `CMakePresets.json`: Build and configure presets for cross-compilation and host testing.
- `CMakePresets.json`: Configure and build presets for cross-compilation and host testing.
- Toolchain files: `gcc-arm-none-eabi.cmake`, `HOOTL.cmake` for compiler, flags, and environment.
- Root `CMakeLists.txt`: Includes platform, utility, and project CMake files. Calls `add_GR_project()` for each project/platform.

Expand Down Expand Up @@ -139,9 +139,22 @@ flowchart TD

### `CMakePresets.json`

- Build presets for different configurations:
- Debug/Release/MinSizeRel: ARM cross-compilation builds
- HOOTLTest: Host-based testing
Defines configure and build presets for different target configurations:

**Configure Presets:**

- `stm` hidden base: Common configuration for all STM32 embedded targets
- Uses `gcc-arm-none-eabi.cmake` toolchain
- Sets `TARGET_TYPE=Embedded` and `CMAKE_PRESET_NAME`
- `Debug`, `Release`, `RelWithDebInfo`, `MinSizeRel`: Inherit from `stm` with corresponding `CMAKE_BUILD_TYPE`
- `HOOTLTest`: Host-based testing configuration
- Uses `HOOTL.cmake` toolchain
- Sets `CMAKE_BUILD_TYPE=Debug`, `TARGET_TYPE=Host`

**Build Presets:**

- Corresponding build presets for each configure preset
- Convenience for building a given preset

### Toolchain Files

Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)

if(NOT DEFINED CMAKE_BUILD_TYPE)
if(NOT DEFINED CMAKE_PRESET_NAME)
message(
FATAL_ERROR
"This project requires configuration using a CMake preset. Please use 'cmake --preset <preset-name>' or select a preset in your IDE."
Expand Down Expand Up @@ -51,6 +51,14 @@ message(
${CMAKE_BUILD_TYPE}
)

message(STATUS "Target type: ${TARGET_TYPE}")

message(
STATUS
"Active CMake Preset: "
${CMAKE_PRESET_NAME}
)

# Projects
add_gr_project(STM32G474xE ECU)

Expand Down
9 changes: 7 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/Lib/cmake/gcc-arm-none-eabi.cmake",
"cacheVariables": {}
"cacheVariables": {
"TARGET_TYPE": "Embedded",
"CMAKE_PRESET_NAME": "${presetName}"
}
},
{
"name": "HOOTLTest",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "${sourceDir}/Lib/cmake/HOOTL.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Test"
"CMAKE_BUILD_TYPE": "Debug",
"TARGET_TYPE": "Host",
"CMAKE_PRESET_NAME": "${presetName}"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion ECU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endif()
# what, does in fact not get the filename of somthing but rather the name of the project from the path
get_filename_component(GR_PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

if(CMAKE_BUILD_TYPE STREQUAL "Test")
if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
add_executable(state_machine_tick_returns)
target_include_directories(
state_machine_tick_returns
Expand Down
6 changes: 3 additions & 3 deletions Lib/GlobalShare/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ target_include_directories(
)

if(
CMAKE_BUILD_TYPE
CMAKE_PRESET_NAME
STREQUAL
"Debug"
OR
CMAKE_BUILD_TYPE
CMAKE_PRESET_NAME
STREQUAL
"RelWithDebInfo"
)
Expand All @@ -26,7 +26,7 @@ if(
)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Test")
if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
target_compile_definitions(GLOBALSHARE_LIB INTERFACE LOGOMATIC_ENABLED)

add_executable(logomatic_simple)
Expand Down
2 changes: 1 addition & 1 deletion Lib/Utils/BitManipulations/bit-utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target_sources(
${CMAKE_CURRENT_LIST_DIR}/Src/setBits.c
)

if(CMAKE_BUILD_TYPE STREQUAL "Test")
if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
add_executable(
BitManipulations_VerifyGetBit_test
${CMAKE_CURRENT_LIST_DIR}/Test/verifyGetBit.c
Expand Down
2 changes: 1 addition & 1 deletion Lib/Utils/CircularBuffer/circular-buffer-lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target_include_directories(
)

# link test to this library
if(CMAKE_BUILD_TYPE STREQUAL "Test")
if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
# Initialization
add_executable(
CircularBuffer_Lib_Initialization_test
Expand Down
2 changes: 1 addition & 1 deletion Lib/cmake/gr-lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function(add_gr_project)
set(Platform ${ARGV0})
set(GR_PROJECT ${ARGV1})

if(CMAKE_BUILD_TYPE STREQUAL "Test")
if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest")
if(DEFINED GR_PROJECT_PATH)
add_subdirectory("${GR_PROJECT}/${GR_PROJECT_PATH}")
else()
Expand Down
Loading