aboutsummaryrefslogtreecommitdiff
path: root/cmake/kicad_schematic_plot.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/kicad_schematic_plot.cmake')
-rw-r--r--cmake/kicad_schematic_plot.cmake46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmake/kicad_schematic_plot.cmake b/cmake/kicad_schematic_plot.cmake
new file mode 100644
index 0000000..d4b77f9
--- /dev/null
+++ b/cmake/kicad_schematic_plot.cmake
@@ -0,0 +1,46 @@
+function(kicad_schematic_plot)
+ set(options ALL)
+ set(one_value_args TARGET SCHEMATIC_FILE DIR)
+ set(multi_value_args)
+ cmake_parse_arguments(kicad_schematic_plot "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
+
+ if (NOT kicad_schematic_plot_SCHEMATIC_FILE)
+ message(SEND_ERROR "Missing required argument: SCHEMATIC_FILE")
+ return()
+ endif ()
+
+ set(schematic_file "${kicad_schematic_plot_SCHEMATIC_FILE}")
+ get_filename_component(schematic_file "${kicad_schematic_plot_SCHEMATIC_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+ get_filename_component(basename "${schematic_file}" NAME_WE)
+
+ if (NOT kicad_schematic_plot_TARGET)
+ set(target "${basename}-plots")
+ else ()
+ set(target "${kicad_schematic_plot_TARGET}")
+ endif ()
+
+ if (NOT kicad_schematic_plot_DIR)
+ message(SEND_ERROR "Missing required argument: DIR")
+ return()
+ endif ()
+
+ set(out_dir "${kicad_schematic_plot_DIR}")
+ set(pdf_prefix "${out_dir}/${basename}")
+
+ set(outputs
+ "${pdf_prefix}.pdf")
+
+ add_custom_command(
+ OUTPUT ${outputs}
+ COMMAND cmake -E make_directory "${out_dir}"
+ COMMAND "${KicadUtilsPyDir}/kicad_schematic_plot.py" "${schematic_file}" "${out_dir}"
+ MAIN_DEPENDENCY "${schematic_file}")
+
+ if (kicad_schematic_plot_ALL)
+ set(all ALL)
+ endif ()
+
+ add_custom_target(
+ ${target} ${all}
+ DEPENDS ${outputs})
+endfunction()