FindPioasm.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. if (NOT Pioasm_FOUND)
  12. # todo we would like to use pckgconfig to look for it first
  13. # see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
  14. include(ExternalProject)
  15. set(PIOASM_SOURCE_DIR ${PICO_SDK_PATH}/tools/pioasm)
  16. set(PIOASM_BINARY_DIR ${CMAKE_BINARY_DIR}/pioasm)
  17. set(PioasmBuild_TARGET PioasmBuild)
  18. set(Pioasm_TARGET Pioasm)
  19. if (NOT TARGET ${PioasmBuild_TARGET})
  20. pico_message_debug("PIOASM will need to be built")
  21. # message("Adding external project ${PioasmBuild_Target} in ${CMAKE_CURRENT_LIST_DIR}}")
  22. ExternalProject_Add(${PioasmBuild_TARGET}
  23. PREFIX pioasm SOURCE_DIR ${PIOASM_SOURCE_DIR}
  24. BINARY_DIR ${PIOASM_BINARY_DIR}
  25. BUILD_ALWAYS 1 # force dependency checking
  26. INSTALL_COMMAND ""
  27. )
  28. endif()
  29. if (CMAKE_HOST_WIN32)
  30. set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm.exe)
  31. else()
  32. set(Pioasm_EXECUTABLE ${PIOASM_BINARY_DIR}/pioasm)
  33. endif()
  34. if(NOT TARGET ${Pioasm_TARGET})
  35. # message("Adding executable ${Pioasm_Target} in ${CMAKE_CURRENT_LIST_DIR}")
  36. add_executable(${Pioasm_TARGET} IMPORTED)
  37. endif()
  38. set_property(TARGET ${Pioasm_TARGET} PROPERTY IMPORTED_LOCATION
  39. ${Pioasm_EXECUTABLE})
  40. # message("EXE is ${Pioasm_EXECUTABLE}")
  41. add_dependencies(${Pioasm_TARGET} ${PioasmBuild_TARGET})
  42. set(Pioasm_FOUND 1)
  43. endif()