diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/doc.cmake | 6 | ||||
-rw-r--r-- | cmake/openocd_flash.cmake | 18 | ||||
-rw-r--r-- | cmake/toolchain.cmake | 15 |
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}) + + |