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()