summaryrefslogtreecommitdiff
path: root/fw/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'fw/cmake')
-rw-r--r--fw/cmake/doc.cmake6
-rw-r--r--fw/cmake/openocd_flash.cmake18
-rw-r--r--fw/cmake/toolchain.cmake15
3 files changed, 39 insertions, 0 deletions
diff --git a/fw/cmake/doc.cmake b/fw/cmake/doc.cmake
new file mode 100644
index 0000000..76336a8
--- /dev/null
+++ b/fw/cmake/doc.cmake
@@ -0,0 +1,6 @@
+add_custom_target (doc
+ COMMAND doxygen
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "output is generted in the ${CMAKE_SOURCE_DIR}/doc"
+ SOURCES Doxyfile
+)
diff --git a/fw/cmake/openocd_flash.cmake b/fw/cmake/openocd_flash.cmake
new file mode 100644
index 0000000..5c92c49
--- /dev/null
+++ b/fw/cmake/openocd_flash.cmake
@@ -0,0 +1,18 @@
+find_program (OOCD openocd DOC "openocd executable")
+
+set (OOCD_INTERFACE stlink-v2 CACHE STRING "interface config file used for openocd flashing")
+set (OOCD_BOARD stm32f4discovery CACHE STRING "board config file used for openocd flashing")
+if (OOCD)
+ message (STATUS "OpenOCD found: ${OOCD}")
+ message (STATUS "... interface: ${OOCD_INTERFACE}")
+ message (STATUS "... board: ${OOCD_BOARD}")
+ add_custom_target (flash
+ COMMAND sh -c '${OOCD} -f interface/${OOCD_INTERFACE}.cfg
+ -f board/${OOCD_BOARD}.cfg
+ -c "init" -c "reset init"
+ -c "flash write_image erase $<TARGET_FILE:demo>"
+ -c "reset"
+ -c "shutdown" '
+ DEPENDS demo
+ )
+endif (OOCD)
diff --git a/fw/cmake/toolchain.cmake b/fw/cmake/toolchain.cmake
new file mode 100644
index 0000000..8522d7a
--- /dev/null
+++ b/fw/cmake/toolchain.cmake
@@ -0,0 +1,15 @@
+set (_CMAKE_TOOLCHAIN_PREFIX "arm-none-eabi-" CACHE STRING "toolchain prefix")
+set (_CMAKE_TOOLCHAIN_LOCATION "" CACHE STRING "toolchain location hint")
+
+set (CMAKE_SYSTEM_NAME Generic)
+set (CMAKE_C_COMPILER_WORKS 1)
+set (CMAKE_CXX_COMPILER_WORKS 1)
+set (CMAKE_C_FLAGS "")
+set (CMAKE_CXX_FLAGS "")
+set (BUILD_SHARED_LIBS OFF)
+find_program (CMAKE_C_COMPILER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}gcc HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+find_program (CMAKE_CXX_COMPILER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}g++ HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+find_program (CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+find_program (CMAKE_SIZE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}size HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+
+