|
| 1 | +# Finds (or builds) the pioasm executable |
| 2 | +# |
| 3 | +# This will define the following imported targets |
| 4 | +# |
| 5 | +# pioasm |
| 6 | +# |
| 7 | + |
| 8 | +# This is a temporary patched copy of pico-sdk file Findpioasm.cmake to work around |
| 9 | +# a host toolchain issue with GCC 15.1: |
| 10 | +# https://github.com/raspberrypi/pico-sdk/issues/2448 |
| 11 | + |
| 12 | +if (NOT TARGET pioasm) |
| 13 | + # todo we would like to use pckgconfig to look for it first |
| 14 | + # see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ |
| 15 | + |
| 16 | + include(ExternalProject) |
| 17 | + |
| 18 | + set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm) |
| 19 | + set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm) |
| 20 | + set(PIOASM_INSTALL_DIR ${CMAKE_BINARY_DIR}/pioasm-install CACHE PATH "Directory where pioasm has been installed" FORCE) |
| 21 | + |
| 22 | + set(pioasmBuild_TARGET pioasmBuild) |
| 23 | + set(pioasm_TARGET pioasm) |
| 24 | + |
| 25 | + if (NOT TARGET ${pioasmBuild_TARGET}) |
| 26 | + pico_message_debug("PIOASM will need to be built") |
| 27 | +# message("Adding external project ${pioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}") |
| 28 | + ExternalProject_Add(${pioasmBuild_TARGET} |
| 29 | + PREFIX pioasm |
| 30 | + SOURCE_DIR ${PIOASM_SOURCE_DIR} |
| 31 | + BINARY_DIR ${PIOASM_BINARY_DIR} |
| 32 | + INSTALL_DIR ${PIOASM_INSTALL_DIR} |
| 33 | + CMAKE_ARGS |
| 34 | + "--no-warn-unused-cli" |
| 35 | + "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}" |
| 36 | + "-DPIOASM_FLAT_INSTALL=1" |
| 37 | + "-DCMAKE_INSTALL_PREFIX=${PIOASM_INSTALL_DIR}" |
| 38 | + "-DCMAKE_RULE_MESSAGES=OFF" # quieten the build |
| 39 | + "-DCMAKE_INSTALL_MESSAGE=NEVER" # quieten the install |
| 40 | + # Toolchain workaround follows |
| 41 | + "-DCMAKE_CXX_FLAGS=-include cstdint" |
| 42 | + CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}" |
| 43 | + BUILD_ALWAYS 1 # force dependency checking |
| 44 | + EXCLUDE_FROM_ALL TRUE |
| 45 | + ) |
| 46 | + endif() |
| 47 | + |
| 48 | + if (CMAKE_HOST_WIN32) |
| 49 | + set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm.exe) |
| 50 | + else() |
| 51 | + set(pioasm_EXECUTABLE ${PIOASM_INSTALL_DIR}/pioasm/pioasm) |
| 52 | + endif() |
| 53 | + add_executable(${pioasm_TARGET} IMPORTED GLOBAL) |
| 54 | + set_property(TARGET ${pioasm_TARGET} PROPERTY IMPORTED_LOCATION |
| 55 | + ${pioasm_EXECUTABLE}) |
| 56 | + |
| 57 | + add_dependencies(${pioasm_TARGET} ${pioasmBuild_TARGET}) |
| 58 | +endif() |
0 commit comments