iNav to INAV
[inav.git] / cmake / openocd_cfg.cmake
blob139302823ef96c0dfff11db681b0176a7b137943
1 # This is called from the targets that build the
2 # openocd.cfg file
3 if(NOT CMAKE_ARGC EQUAL 6)
4     message(FATAL_ERROR "usage: cmake -P openocd_cfg.cmake <target> <interface> <output>")
5 endif()
7 set(OPENOCD_TARGET ${CMAKE_ARGV3})
8 set(OPENOCD_INTERFACE ${CMAKE_ARGV4})
9 set(OUTPUT ${CMAKE_ARGV5})
11 set(opencd_cfg)
12 list(APPEND openocd_cfg "source [find interface/${OPENOCD_INTERFACE}.cfg]")
13 list(APPEND openocd_cfg "source [find target/${OPENOCD_TARGET}.cfg]")
14 list(APPEND openocd_cfg "init")
15 list(APPEND openocd_cfg "arm semihosting enable")
16 list(APPEND openocd_cfg "reset halt")
17 list(JOIN openocd_cfg "\n" contents)
18 set(contents "${contents}\n")
20 file(WRITE ${OUTPUT} ${contents})