1
0

Add cmake

does not work yet
This commit is contained in:
Arti Zirk 2021-07-20 22:49:38 +03:00
parent 5d6fa6c66f
commit 8366bbe163
6 changed files with 110 additions and 0 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ bin/
*.list
generated.*.ld
.idea
build

33
CMakeLists.txt Normal file
View File

@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.19)
project(dht_test LANGUAGES C)
set(LIBOPENCM3_DIR ${CMAKE_SOURCE_DIR}/libopencm3)
set(CMAKE_C_STANDARD 99)
add_compile_options(
-Wall
-Wextra
-Wconversion
-Wsign-conversion
-ggdb3
-Os
)
add_compile_definitions(
STM32F1
DEBUG
)
add_executable(dht_test main.c)
set_target_properties(dht_test PROPERTIES
SUFFIX .elf
)
target_include_directories(dht_test PRIVATE
${LIBOPENCM3_DIR}/include
RTT
)
add_custom_target(libopencm3 make TARGETS=stm32/f1 -j8 WORKING_DIRECTORY ${LIBOPENCM3_DIR})
link_directories(${LIBOPENCM3_DIR}/lib)

23
CMakePresets.json Normal file
View File

@ -0,0 +1,23 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 19,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/default"
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}

19
print_vars.mk Normal file
View File

@ -0,0 +1,19 @@
PROJECT=dht_test
DEVICE=STM32F103C8T6
OPENCM3_DIR=libopencm3
print_genlink_vars:
@echo LDSCRIPT=$(LDSCRIPT)
@echo LDFLAGS=$(LDFLAGS)
@echo LIBDEPS=$(LIBDEPS)
@echo ARCH_FLAGS=$(ARCH_FLAGS)
@echo TGT_CFLAGS=$(TGT_CFLAGS)
@echo TGT_LDFLAGS=$(TGT_LDFLAGS)
@echo LDLIBS=$(LDLIBS)
include $(OPENCM3_DIR)/mk/genlink-config.mk
include rules.mk
include $(OPENCM3_DIR)/mk/genlink-rules.mk

34
toolchain-STM32F1.cmake Normal file
View File

@ -0,0 +1,34 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION Cortex-M3-STM32F1)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(ARM_OPTIONS -mcpu=cortex-m4 -mfloat-abi=soft --specs=nano.specs)
add_compile_options(
${ARM_OPTIONS}
-fmessage-length=0
-funsigned-char
-ffunction-sections
-fdata-sections
-MMD
-MP
)
add_link_options(
${ARM_OPTIONS}
--specs=rdimon.specs
-u_printf_float
-u_scanf_float
-nostartfiles
LINKER:--gc-sections
LINKER:--build-id
)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)