From 84b38921ee2cc79ed46287c03133b5eb92597748 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 15 Aug 2016 23:33:46 +0200 Subject: o Adding new command: kicad_pcb_plot to plot a PCB. --- cmake/kicad_pcb_plot.cmake | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 cmake/kicad_pcb_plot.cmake (limited to 'cmake/kicad_pcb_plot.cmake') diff --git a/cmake/kicad_pcb_plot.cmake b/cmake/kicad_pcb_plot.cmake new file mode 100644 index 0000000..562004e --- /dev/null +++ b/cmake/kicad_pcb_plot.cmake @@ -0,0 +1,65 @@ +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}-CuBottom.pdf" + "${pdf_prefix}-CuTop.pdf" + "${pdf_prefix}-EdgeCuts.pdf" + "${pdf_prefix}-Layout.pdf" + "${pdf_prefix}-MaskBottom.pdf" + "${pdf_prefix}-MaskTop.pdf" + "${pdf_prefix}-PasteBottom.pdf" + "${pdf_prefix}-PasteTop.pdf" + "${pdf_prefix}-SilkBottom.pdf" + "${pdf_prefix}-Silk.pdf" + "${pdf_prefix}-SilkTop.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() -- cgit v1.2.3