summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAmir Hammad <amir.hammad@hotmail.com>2016-09-09 18:36:38 +0200
committerAmir Hammad <amir.hammad@hotmail.com>2016-09-11 13:30:10 +0200
commited70a1efa3335b6bf64c8c6a6f5be4dc25bdd9b7 (patch)
tree7643a22adfa652fd33b973e06d603f896e60b7e3 /cmake
parent28ccd32608bb3daf0f8137eb1521f382f69d120d (diff)
downloadsecure-hid-ed70a1efa3335b6bf64c8c6a6f5be4dc25bdd9b7.tar.gz
secure-hid-ed70a1efa3335b6bf64c8c6a6f5be4dc25bdd9b7.tar.bz2
secure-hid-ed70a1efa3335b6bf64c8c6a6f5be4dc25bdd9b7.zip
Switch to cmake build system
* use tinyprintf * ability to configure project via ccmake Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/doc.cmake6
-rw-r--r--cmake/openocd_flash.cmake18
-rw-r--r--cmake/toolchain.cmake15
3 files changed, 39 insertions, 0 deletions
diff --git a/cmake/doc.cmake b/cmake/doc.cmake
new file mode 100644
index 0000000..76336a8
--- /dev/null
+++ b/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/cmake/openocd_flash.cmake b/cmake/openocd_flash.cmake
new file mode 100644
index 0000000..5c92c49
--- /dev/null
+++ b/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/cmake/toolchain.cmake b/cmake/toolchain.cmake
new file mode 100644
index 0000000..b6e2af7
--- /dev/null
+++ b/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_C_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})
+
+