summaryrefslogtreecommitdiff
path: root/mech/CMakeLists.txt
blob: de24ff22be4218614738141a5740c9531fb0b920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
set(parts
	assembly
	production
	#pcb_case/tolerance_tests
)

foreach(part ${parts})
	set(source "${CMAKE_CURRENT_SOURCE_DIR}/${part}.scad")
	set(intermediate "${CMAKE_CURRENT_BINARY_DIR}/${part}.stl")
	set(sink "${CMAKE_CURRENT_BINARY_DIR}/${part}.gcode")

	add_custom_command(
		OUTPUT
			${intermediate}
		COMMAND
			openscad
			--hardwarnings
			--export-format binstl
			-o ${intermediate}
			${source}
		DEPENDS
			${source}
	)

	set(printer_config "${CMAKE_CURRENT_SOURCE_DIR}/prusa-slicer/anycubic_i3_mega_s.ini")
	add_custom_target(
		"mech-stl-${part}"
		ALL
		DEPENDS
			${intermediate}
	)

	add_custom_command(
		OUTPUT
			${sink}
		COMMAND
			prusa-slicer
			--load ${printer_config}
			--output ${sink}
			--export-gcode ${intermediate}
		DEPENDS
			${intermediate}
	)
	add_custom_target(
		"mech-gcode-${part}"
		ALL
		DEPENDS
			${sink}
	)
endforeach()