summaryrefslogtreecommitdiff
path: root/mech/mech.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'mech/mech.cmake')
-rw-r--r--mech/mech.cmake62
1 files changed, 62 insertions, 0 deletions
diff --git a/mech/mech.cmake b/mech/mech.cmake
new file mode 100644
index 0000000..2d2b979
--- /dev/null
+++ b/mech/mech.cmake
@@ -0,0 +1,62 @@
+function(openscad source_file)
+ if (NOT source_file)
+ message(FATAL_ERROR "Missing source_file argument in openscad function.")
+ endif()
+
+ get_filename_component(name "${source_file}" NAME_WE)
+
+ set(sink_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.stl")
+
+ add_custom_command(
+ OUTPUT
+ ${sink_file}
+ COMMAND
+ openscad
+ --hardwarnings
+ --export-format binstl
+ -o ${sink_file}
+ ${source_file}
+ DEPENDS
+ ${source_file}
+ )
+
+ add_custom_target(
+ "stl-${name}"
+ ALL
+ DEPENDS
+ ${sink_file}
+ )
+endfunction()
+
+function(prusa_slicer source_file printer_config)
+ if (NOT source_file)
+ message(FATAL_ERROR "Missing source_file argument in prusa-slicer function.")
+ endif()
+
+ if (NOT printer_config)
+ message(FATAL_ERROR "Missing printer_config argument in prusa-slicer function.")
+ endif()
+
+ get_filename_component(name "${source_file}" NAME_WE)
+
+ set(stl_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.stl")
+ set(sink_file "${CMAKE_CURRENT_BINARY_DIR}/${name}.gcode")
+
+ add_custom_command(
+ OUTPUT
+ ${sink_file}
+ COMMAND
+ prusa-slicer
+ --load ${printer_config}
+ --output ${sink_file}
+ --export-gcode ${stl_file}
+ DEPENDS
+ ${stl_file}
+ )
+ add_custom_target(
+ "gcode-${name}"
+ ALL
+ DEPENDS
+ ${sink_file}
+ )
+endfunction()