Update presets and integrate testing concept
This commit is contained in:
parent
b47e962ce9
commit
c91a78a91d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
/.out/
|
||||
/build/
|
||||
|
@ -10,11 +10,13 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
# General Project
|
||||
add_subdirectory(floatpump)
|
||||
if(NOT ENABLE_UNITTESTS)
|
||||
add_subdirectory(floatpump)
|
||||
endif ()
|
||||
|
||||
# Testing Project
|
||||
if(ENABLE_UNITTESTS)
|
||||
message(STATUS "Enabled Unit Tests")
|
||||
add_subirectory(Catch2)
|
||||
add_subdirectory(Catch2)
|
||||
add_subdirectory(Tests)
|
||||
endif()
|
@ -1,4 +1,9 @@
|
||||
{
|
||||
"version": 10,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 22
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "debug@firmware",
|
||||
@ -10,24 +15,61 @@
|
||||
},
|
||||
"binaryDir": "build/debug@firmware"
|
||||
},
|
||||
{
|
||||
"name": "release@firmware",
|
||||
"description": "Firmware Release Build",
|
||||
"generator": "Ninja",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "toolchain/arm-none-eabi-stm32f411ceu6-toolchain.cmake",
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
},
|
||||
"binaryDir": "build/release@firmware"
|
||||
},
|
||||
{
|
||||
"name": "minrelease@firmware",
|
||||
"description": "Firmware Minimized Release Build",
|
||||
"inherits": ["release@firmware"],
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "MinSizeRel"
|
||||
},
|
||||
"binaryDir": "build/minrelease@firmware"
|
||||
},
|
||||
{
|
||||
"name": "debug@tests",
|
||||
"description": "UnitTests Debug Buil",
|
||||
"description": "UnitTests Debug Build",
|
||||
"generator": "Ninja",
|
||||
"cacheVariables": {
|
||||
"ENABLE_UNITTESTS": "ON"
|
||||
}
|
||||
},
|
||||
"binaryDir": "build/debug@tests"
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "build-debug@firmware",
|
||||
"name": "build-debug",
|
||||
"description": "Builds the debugging firmware",
|
||||
"cleanFirst": false,
|
||||
"configuration": "debug@firmware",
|
||||
"configurePreset": "debug@firmware",
|
||||
"targets": [
|
||||
"FloatPUMP.elf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build-release",
|
||||
"description": "Builds the normal release firmware",
|
||||
"cleanFirst": true,
|
||||
"configurePreset": "minrelease@firmware",
|
||||
"targets": [
|
||||
"FloatPUMP.elf"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build-tests",
|
||||
"description": "Creates a debug build of all tests",
|
||||
"configurePreset": "debug@tests",
|
||||
"targets": [
|
||||
"testtests"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,4 +1,10 @@
|
||||
find_package(Catch2 REQUIRED)
|
||||
# Catch 2 is already loaded from the main CMakeLists.txt as a subdirectory
|
||||
|
||||
add_executable(testtests experiments/example-test.cpp)
|
||||
target_link_libraries(testtests PRIVATE Catch2::Catch2WithMain)
|
||||
target_link_libraries(testtests PRIVATE Catch2::Catch2WithMain)
|
||||
|
||||
# General catch configuration
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
|
||||
catch_discover_tests(testtests)
|
14
floatpump/CMake/githash.cmake
Normal file
14
floatpump/CMake/githash.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
# Obtain the short git hash for burning it into the firmware
|
||||
set(GIT_HASH "undefined")
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
message(STATUS "Burning in git hash: ${GIT_HASH}")
|
||||
else ()
|
||||
message(WARNING "Cannot obtain git hash for burning into firmware")
|
||||
endif()
|
@ -1,22 +1,6 @@
|
||||
set(GIT_HASH "undefined")
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h
|
||||
OUTPUT_VARIABLE GIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "Burning in git hash: ${GIT_HASH}")
|
||||
|
||||
add_definitions("-DGIT_HASH=\"${GIT_HASH}\"")
|
||||
|
||||
#include(${CMAKE_CURRENT_LIST_DIR}/../toolchain/arm-none-eabi-stm32f411ceu6-toolchain.cmake)
|
||||
# uncomment to mitigate c++17 absolute addresses warnings
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")
|
||||
include(CMake/githash.cmake)
|
||||
|
||||
# All required source definitions
|
||||
file(GLOB_RECURSE SOURCES
|
||||
"Core/*.*"
|
||||
"Middlewares/*.*"
|
||||
@ -24,9 +8,17 @@ file(GLOB_RECURSE SOURCES
|
||||
"USB_DEVICE/*.*"
|
||||
)
|
||||
|
||||
message(WARNING "linker script is : ${LINKER_SCRIPT}")
|
||||
# Check if the correct toolchain was used and the LINKER_SCRIPT is defined
|
||||
if(NOT DEFINED LINKER_SCRIPT)
|
||||
message(FATAL_ERROR "You need to define the LINKER_SCRIPT variable from within the toolchain for the correct MCU")
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
|
||||
add_executable(FloatPUMP.elf ${SOURCES} ${LINKER_SCRIPT})
|
||||
|
||||
# Custom target options
|
||||
target_compile_definitions(FloatPUMP.elf PUBLIC
|
||||
"-DGIT_HASH=\"${GIT_HASH}\""
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}.elf PUBLIC
|
||||
USB_DEVICE/App
|
||||
|
Loading…
x
Reference in New Issue
Block a user