blob: 0cc9fe44c3dab5bcf06981b2b29978280a50fd0d [file] [log] [blame]
Austin Schuh208337d2022-01-01 14:29:11 -08001# 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
12if (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 ""
Ravago Jonesd208ae72023-02-13 02:24:07 -080032 CMAKE_CACHE_ARGS "-DPIOASM_EXTRA_SOURCE_FILES:STRING=${PIOASM_EXTRA_SOURCE_FILES}"
Austin Schuh208337d2022-01-01 14:29:11 -080033 )
34 endif()
35
36 if (CMAKE_HOST_WIN32)
37 set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm.exe)
38 else()
39 set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm)
40 endif()
41 if(NOT TARGET ${Pioasm_TARGET})
42# message("Adding executable ${Pioasm_Target} in ${CMAKE_CURRENT_LIST_DIR}")
43 add_executable(${Pioasm_TARGET} IMPORTED)
44 endif()
45 set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION
46 ${Pioasm_EXECUTABLE})
47
48# message("EXE is ${Pioasm_EXECUTABLE}")
49 add_dependencies(${Pioasm_TARGET} ${PioasmBuild_TARGET})
50 set(Pioasm_FOUND 1)
51endif()