Austin Schuh | 208337d | 2022-01-01 14:29:11 -0800 | [diff] [blame^] | 1 | # Finds (or builds) the Pioasm executable |
| 2 | # |
| 3 | # This will define the following variables |
| 4 | # |
| 5 | # Pioasm_FOUND |
| 6 | # |
| 7 | # and the following imported targets |
| 8 | # |
| 9 | # Pioasm |
| 10 | # |
| 11 | |
| 12 | if (NOT Pioasm_FOUND) |
| 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 | |
| 21 | set(PioasmBuild_TARGET PioasmBuild) |
| 22 | set(Pioasm_TARGET Pioasm) |
| 23 | |
| 24 | if (NOT TARGET ${PioasmBuild_TARGET}) |
| 25 | pico_message_debug("PIOASM will need to be built") |
| 26 | # message("Adding external project ${PioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}") |
| 27 | ExternalProject_Add(${PioasmBuild_TARGET} |
| 28 | PREFIX pioasm SOURCE_DIR ${PIOASM_SOURCE_DIR} |
| 29 | BINARY_DIR ${PIOASM_BINARY_DIR} |
| 30 | BUILD_ALWAYS 1 # force dependency checking |
| 31 | INSTALL_COMMAND "" |
| 32 | ) |
| 33 | endif() |
| 34 | |
| 35 | if (CMAKE_HOST_WIN32) |
| 36 | set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm.exe) |
| 37 | else() |
| 38 | set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm) |
| 39 | endif() |
| 40 | if(NOT TARGET ${Pioasm_TARGET}) |
| 41 | # message("Adding executable ${Pioasm_Target} in ${CMAKE_CURRENT_LIST_DIR}") |
| 42 | add_executable(${Pioasm_TARGET} IMPORTED) |
| 43 | endif() |
| 44 | set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION |
| 45 | ${Pioasm_EXECUTABLE}) |
| 46 | |
| 47 | # message("EXE is ${Pioasm_EXECUTABLE}") |
| 48 | add_dependencies(${Pioasm_TARGET} ${PioasmBuild_TARGET}) |
| 49 | set(Pioasm_FOUND 1) |
| 50 | endif() |