function(kicad_pcb_plot) set(options ALL) set(one_value_args TARGET PCB_FILE DIR) set(multi_value_args) cmake_parse_arguments(kicad_pcb_plot "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) if (NOT kicad_pcb_plot_PCB_FILE) message(SEND_ERROR "Missing required argument: PCB_FILE") return() endif () set(pcb_file "${kicad_pcb_plot_PCB_FILE}") get_filename_component(pcb_file "${kicad_pcb_plot_PCB_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component(basename "${pcb_file}" NAME_WE) if (NOT kicad_pcb_plot_TARGET) set(target "${basename}-plots") else () set(target "${kicad_pcb_plot_TARGET}") endif () if (NOT kicad_pcb_plot_DIR) message(SEND_ERROR "Missing required argument: DIR") return() endif () set(out_dir "${kicad_pcb_plot_DIR}") set(pdf_prefix "${out_dir}/${basename}") set(outputs "${pdf_prefix}-Assembly.pdf" "${pdf_prefix}-AssyOutlinesTop.pdf" "${pdf_prefix}-AssyTop.pdf" "${pdf_prefix}-B.Cu.pdf" "${pdf_prefix}-B.Mask.pdf" "${pdf_prefix}-B.Paste.pdf" "${pdf_prefix}-B.Silk.pdf" "${pdf_prefix}-Cmts.User.pdf" "${pdf_prefix}-Edge.Cuts.pdf" "${pdf_prefix}-F.Cu.pdf" "${pdf_prefix}-F.Mask.pdf" "${pdf_prefix}-F.Paste.pdf" "${pdf_prefix}-F.Silk.pdf" "${pdf_prefix}-Layout.pdf" "${pdf_prefix}-Silk.pdf") # message(STATUS "kicad_pcb_plot: pcb_file: ${pcb_file}") # message(STATUS "kicad_pcb_plot: out_dir: ${out_dir}") # message(STATUS "kicad_pcb_plot: pdf_prefix: ${pdf_prefix}") # message(STATUS "kicad_pcb_plot: outputs: ${outputs}") # message(STATUS "kicad_pcb_plot: target: ${target}") add_custom_command( OUTPUT ${outputs} COMMAND cmake -E make_directory "${out_dir}" COMMAND "${KicadUtilsPyDir}/kicad_pcb_plot.py" "${pcb_file}" "${out_dir}" MAIN_DEPENDENCY "${pcb_file}") if (kicad_pcb_plot_ALL) set(all ALL) endif () add_custom_target( ${target} ${all} DEPENDS ${outputs}) endfunction()