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