cmake instead of make
This commit is contained in:
@@ -79,7 +79,7 @@ FORMAT = ihex
|
|||||||
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
||||||
# it will preserve the spelling of the filenames, and gcc itself does
|
# it will preserve the spelling of the filenames, and gcc itself does
|
||||||
# care about how the name is spelled on its command-line.
|
# care about how the name is spelled on its command-line.
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
# Optional compiler flags.
|
# Optional compiler flags.
|
||||||
# -g: generate debugging information (for GDB, or for COFF conversion)
|
# -g: generate debugging information (for GDB, or for COFF conversion)
|
||||||
@@ -312,7 +312,7 @@ clean_list :
|
|||||||
[ -s $@ ] || rm -f $@
|
[ -s $@ ] || rm -f $@
|
||||||
|
|
||||||
# Remove the '-' if you want to see the dependency files generated.
|
# Remove the '-' if you want to see the dependency files generated.
|
||||||
-include $(SRC:.c=.d)
|
include $(SRC:.c=.d)
|
||||||
|
|
||||||
-include $(PSRC:.cpp=.d)
|
-include $(PSRC:.cpp=.d)
|
||||||
|
|
||||||
|
|||||||
81
CMakeLists.txt
Normal file
81
CMakeLists.txt
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
|
||||||
|
#
|
||||||
|
#include_directories(arduino/hardware/arduino/variants/standard)
|
||||||
|
#include_directories(arduino/hardware/arduino/avr/libraries/SPI/src)
|
||||||
|
#include_directories(arduino/hardware/arduino/avr/cores/arduino)
|
||||||
|
#include_directories(arduino/hardware/arduino/avr/variants/standard)
|
||||||
|
#include_directories(arduino/libraries/RF24)
|
||||||
|
#include_directories(arduino/libraries/SoftPWM)
|
||||||
|
#include_directories(arduino/hardware/tools/avr/avr/include)
|
||||||
|
#include_directories(./)
|
||||||
|
##include_directories(arduino/hardware/tools/avr/avr/include/avr/iom328p.h)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# Project name
|
||||||
|
project(battletank)
|
||||||
|
|
||||||
|
# CMake version
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
# Options
|
||||||
|
# Adjust to your board
|
||||||
|
set(MCU "atmega328p" )
|
||||||
|
set(CPU_SPEED "16000000" )
|
||||||
|
set(PORT "/dev/ttyUSB0")
|
||||||
|
set(PORT_SPEED "57600")
|
||||||
|
set(PIN_VARIANT "standard")
|
||||||
|
set(ARDUINO_PATH "arduino")
|
||||||
|
set(PROGRAMMER "arduino")
|
||||||
|
set(COMPILE_FLAGS "")
|
||||||
|
|
||||||
|
# Set own source files
|
||||||
|
# Simply list all your C / C++ source (not header!) files here
|
||||||
|
set(SRC_FILES main.cpp)
|
||||||
|
|
||||||
|
# Include directories
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/libraries/SPI/src
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/cores/arduino
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/variants/standard
|
||||||
|
${ARDUINO_PATH}/libraries/SoftPWM
|
||||||
|
${ARDUINO_PATH}/libraries/RF24
|
||||||
|
${ARDUINO_PATH}/hardware/tools/avr/avr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# Find Arduino source files.
|
||||||
|
file(GLOB_RECURSE ARDUINO_CORE_SRC
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/cores/arduino/*.c
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/cores/arduino/*.cpp
|
||||||
|
${ARDUINO_PATH}/libraries/SoftPWM/*.cpp
|
||||||
|
${ARDUINO_PATH}/libraries/RF24/*.cpp
|
||||||
|
${ARDUINO_PATH}/hardware/arduino/avr/libraries/SPI/src/*.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Compiler suite specification
|
||||||
|
set(CMAKE_C_COMPILER avr-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER avr-g++)
|
||||||
|
set(CMAKE_OBJCOPY avr-objcopy)
|
||||||
|
set(CMAKE_OBJDUMP avr-objdump)
|
||||||
|
set(CMAKE_RANLIB avr-ranlib)
|
||||||
|
set(CMAKE_LINKER avr-ld)
|
||||||
|
|
||||||
|
# Compiler flags
|
||||||
|
add_definitions(-DBAUD=9600UL -DARDUINO -DROLE=1)
|
||||||
|
add_definitions(-mmcu=${MCU} -DF_CPU=${CPU_SPEED})
|
||||||
|
add_definitions(-c -g -Os -Wall)
|
||||||
|
add_definitions(-fpack-struct -fno-exceptions -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fshort-enums)
|
||||||
|
|
||||||
|
# Linker flags
|
||||||
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-Os -Wl,--gc-sections -mmcu=${MCU}")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} ${ARDUINO_CORE_SRC} ${SRC_FILES})
|
||||||
|
|
||||||
|
add_custom_target(flash
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} -j .text -j .data -O ihex ${PROJECT_NAME} ${PROJECT_NAME}.hex
|
||||||
|
COMMAND avrdude -F -p${MCU} -carduino -P${PORT} -b${PORT_SPEED} -D -Uflash:w:main.hex:i
|
||||||
|
DEPENDS ${PROJECT_NAME}
|
||||||
|
)
|
||||||
1
lib.h
1
lib.h
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
void uart_init() {
|
void uart_init() {
|
||||||
// Upper and lower bytes of the calculated prescaler value for baud.
|
// Upper and lower bytes of the calculated prescaler value for baud.
|
||||||
UBRR0H = UBRRH_VALUE;
|
UBRR0H = UBRRH_VALUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user