diff --git i/tools/uf2tool/CMakeLists.txt w/tools/uf2tool/CMakeLists.txt index edc15429..03a6efff 100644 --- i/tools/uf2tool/CMakeLists.txt +++ w/tools/uf2tool/CMakeLists.txt @@ -22,23 +22,32 @@ cmake_minimum_required (VERSION 3.13) project (UF2Tool) set(UF2TOOL_PATH "" CACHE PATH "Path to UF2Tool source tree. If unset, hex package will be used") +set(UF2TOOL_BIN "" CACHE PATH "Path to UF2Tool bin. If unset, package will be built.") -if(NOT UF2TOOL_PATH STREQUAL "") - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_checkouts) - file(CREATE_LINK ${UF2TOOL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/_checkouts/uf2tool SYMBOLIC) +if(UF2TOOL_BIN STREQUAL "") + if(NOT UF2TOOL_PATH STREQUAL "") + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_checkouts) + file(CREATE_LINK ${UF2TOOL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/_checkouts/uf2tool SYMBOLIC) + endif() + + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/rebar.config + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + ) + + add_custom_command( + OUTPUT uf2tool + COMMAND rebar3 escriptize && cp _build/default/bin/uf2tool . + VERBATIM + ) + add_custom_target( + UF2Tool ALL + DEPENDS uf2tool + ) +else() + file(CREATE_LINK ${UF2TOOL_BIN} ${CMAKE_CURRENT_BINARY_DIR}/uf2tool SYMBOLIC) + add_custom_target( + UF2Tool ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/uf2tool + ) endif() -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/rebar.config - DESTINATION ${CMAKE_CURRENT_BINARY_DIR} -) - -add_custom_command( - OUTPUT uf2tool - COMMAND rebar3 escriptize && cp _build/default/bin/uf2tool . - VERBATIM -) - -add_custom_target( - UF2Tool ALL - DEPENDS uf2tool -)