Squashed 'third_party/pico-sdk/' content from commit 2062372d2

Change-Id: Ic20f199d3ed0ea8d3a6a1bbf513f875ec7500cc6
git-subtree-dir: third_party/pico-sdk
git-subtree-split: 2062372d203b372849d573f252cf7c6dc2800c0a
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/tools/FindPioasm.cmake b/tools/FindPioasm.cmake
new file mode 100644
index 0000000..91b9021
--- /dev/null
+++ b/tools/FindPioasm.cmake
@@ -0,0 +1,50 @@
+# Finds (or builds) the Pioasm executable
+#
+# This will define the following variables
+#
+#    Pioasm_FOUND
+#
+# and the following imported targets
+#
+#     Pioasm
+#
+
+if (NOT Pioasm_FOUND)
+    # todo we would like to use pckgconfig to look for it first
+    # see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
+
+    include(ExternalProject)
+
+    set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm)
+    set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm)
+
+    set(PioasmBuild_TARGET PioasmBuild)
+    set(Pioasm_TARGET Pioasm)
+
+    if (NOT TARGET ${PioasmBuild_TARGET})
+        pico_message_debug("PIOASM will need to be built")
+#        message("Adding external project ${PioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}")
+        ExternalProject_Add(${PioasmBuild_TARGET}
+                PREFIX pioasm SOURCE_DIR ${PIOASM_SOURCE_DIR}
+                BINARY_DIR ${PIOASM_BINARY_DIR}
+                BUILD_ALWAYS 1 # force dependency checking
+                INSTALL_COMMAND ""
+                )
+    endif()
+
+    if (CMAKE_HOST_WIN32)
+        set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm.exe)
+    else()
+        set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm)
+    endif()
+    if(NOT TARGET ${Pioasm_TARGET})
+#        message("Adding executable ${Pioasm_Target} in ${CMAKE_CURRENT_LIST_DIR}")
+        add_executable(${Pioasm_TARGET} IMPORTED)
+    endif()
+    set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION
+            ${Pioasm_EXECUTABLE})
+
+#    message("EXE is ${Pioasm_EXECUTABLE}")
+    add_dependencies(${Pioasm_TARGET} ${PioasmBuild_TARGET})
+    set(Pioasm_FOUND 1)
+endif()