summaryrefslogtreecommitdiff
path: root/cmake/kicad.cmake
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-02-14 14:22:57 +0100
committerxengineering <me@xengineering.eu>2025-02-14 14:22:57 +0100
commiteae277aba525a3350729e63895d2aabc03a4ffa5 (patch)
tree08dd1ef796cc6a8aa3c256a890535a97e066abb0 /cmake/kicad.cmake
parentde8bc23e81c136b2153fe93d87e5a5ba9e518878 (diff)
downloadiot-contact-eae277aba525a3350729e63895d2aabc03a4ffa5.tar
iot-contact-eae277aba525a3350729e63895d2aabc03a4ffa5.tar.zst
iot-contact-eae277aba525a3350729e63895d2aabc03a4ffa5.zip
cmake: Add module with kicad_schematic_to_pdf
This CMake function integrates converting the schematic to PDF as part of the standard build.
Diffstat (limited to 'cmake/kicad.cmake')
-rw-r--r--cmake/kicad.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/kicad.cmake b/cmake/kicad.cmake
new file mode 100644
index 0000000..126d2e4
--- /dev/null
+++ b/cmake/kicad.cmake
@@ -0,0 +1,23 @@
+function(kicad_schematic_to_pdf source target)
+ get_filename_component(name ${source} NAME)
+ get_filename_component(dir ${source} DIRECTORY)
+ file(RELATIVE_PATH rel "${CMAKE_SOURCE_DIR}" "${dir}")
+ set(name_pdf "${name}.pdf")
+ set(pdf ${CMAKE_BINARY_DIR}/${rel}/${name_pdf})
+
+ add_custom_command(
+ OUTPUT
+ ${pdf}
+ COMMAND
+ kicad-cli sch export pdf --output ${pdf} ${source}
+ DEPENDS
+ ${source}
+ )
+
+ add_custom_target(
+ "${target}"
+ ALL
+ DEPENDS
+ ${pdf}
+ )
+endfunction()