-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
31 lines (23 loc) · 1.15 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cmake_minimum_required(VERSION 3.5.0)
project(stm32-DS18x20)
IF(NOT CMAKE_CROSSCOMPILING)
message(FATAL_ERROR "Cross compiling only. Please use -DCMAKE_TOOLCHAIN_FILE=/PATH/TO/TOOLCHAIN_FILE .")
ENDIF(NOT CMAKE_CROSSCOMPILING)
add_definitions(-DSTM32F1)
set(LIBOPENCM3_DIR ${CMAKE_SOURCE_DIR}/libopencm3)
add_custom_target(libopencm3 make WORKING_DIRECTORY ${LIBOPENCM3_DIR})
link_directories(${LIBOPENCM3_DIR}/lib)
#file(GLOB_RECURSE USER_SOURCES src/*.c)
include_directories(
${LIBOPENCM3_DIR}/include
inc)
set(STM32F1_FLAGS "-mcpu=cortex-m3 -mthumb -mthumb-interwork -msoft-float")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall ${STM32F1_FLAGS} -std=c99 -Os -ffunction-sections -fdata-sections ")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall --std=c++14 ${STM32F1_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_SOURCE_DIR}/libopencm3.ld -nostartfiles -lopencm3_stm32f1 -lc -lnosys --specs=rdimon.specs -Wl,--gc-sections")
function(add_bin_from_elf bin elf)
add_custom_target(${bin}
ALL ${CMAKE_OBJCOPY}
-Obinary ${elf} ${bin} DEPENDS ${elf})
endfunction(add_bin_from_elf)
add_subdirectory(src)