aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/KicadUtilsConfig.cmake2
-rw-r--r--cmake/kicad_generate_header.cmake24
-rw-r--r--cmake/kicad_pcb_plot.cmake65
3 files changed, 85 insertions, 6 deletions
diff --git a/cmake/KicadUtilsConfig.cmake b/cmake/KicadUtilsConfig.cmake
index 2302fe2..1cb682d 100644
--- a/cmake/KicadUtilsConfig.cmake
+++ b/cmake/KicadUtilsConfig.cmake
@@ -1,2 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/kicad_generate_header.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/kicad_pcb_plot.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/KicadUtilsTargets.cmake")
+set(KicadUtilsPyDir "${CMAKE_CURRENT_LIST_DIR}/../../../share/kicad-utils/py")
diff --git a/cmake/kicad_generate_header.cmake b/cmake/kicad_generate_header.cmake
index 930c5ed..85b1f9b 100644
--- a/cmake/kicad_generate_header.cmake
+++ b/cmake/kicad_generate_header.cmake
@@ -1,6 +1,6 @@
function(kicad_generate_header)
- set(options IN_SOURCE)
- set(oneValueArgs OUTPUT NET REF OUTPUT_DIR TEMPLATE TEMPLATE_LIB_LIST)
+ set(options IN_SOURCE ALL)
+ set(oneValueArgs OUTPUT NET REF OUTPUT_DIR TEMPLATE TEMPLATE_LIB_LIST TARGET)
cmake_parse_arguments(kicad_gen "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -42,16 +42,28 @@ function(kicad_generate_header)
endif ()
set(lib "-l;${CMAKE_CURRENT_SOURCE_DIR}")
- foreach(l IN LISTS kicad_gen_TEMPLATE_LIB_LIST)
- list(APPEND lib -l)
- list(APPEND lib "${l}")
+ foreach (l IN LISTS kicad_gen_TEMPLATE_LIB_LIST)
+ list(APPEND lib -l "${l}")
endforeach ()
- set(output_file "${output_dir}/${output}")
+ set(output_file "${output_dir}/${output}")
file(RELATIVE_PATH output_file_rel "${output_rel_dir}" ${output_file})
+ message("kicad_generate_header: output_file=${output_file}")
+ message("kicad_generate_header: output_file_rel=${output_file_rel}")
+
add_custom_command(OUTPUT "${output_file}"
COMMAND KicadUtils::generate-header -n ${NET} -r ${REF} -o ${output_file} ${t} ${template} ${lib}
MAIN_DEPENDENCY ${NET}
COMMENT "Generating ${output_file_rel}")
+
+ if (kicad_gen_TARGET)
+ set(target "${kicad_gen_TARGET}")
+ if (kicad_gen_ALL)
+ set(all ALL)
+ endif ()
+
+ add_custom_target("${target}" ${all} DEPENDS ${output_file})
+ endif ()
+
endfunction()
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()