File: UseLemon.cmake

package info (click to toggle)
wireshark 4.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 351,436 kB
  • sloc: ansic: 3,103,613; cpp: 129,736; xml: 100,978; python: 56,510; perl: 24,575; sh: 5,874; lex: 4,383; pascal: 4,304; makefile: 164; ruby: 113; objc: 91; tcl: 35
file content (63 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
# Create macros for using the lemon parser generator.

# If we're cross-compiling and /usr/share/lemon/lempar.c exists, try to
# find the system lemon and use it. We need to build our own lemon
# otherwise.
if (CMAKE_CROSSCOMPILING AND EXISTS /usr/share/lemon/lempar.c)
	find_program(LEMON_EXECUTABLE lemon)
endif()

if(LEMON_EXECUTABLE)
	# Use system lemon
	macro(generate_lemon_file _out _in)
		add_custom_command(
			OUTPUT
				${_out}.c
				# These files are generated as side-effect
				${_out}.h
				${_out}.out
			COMMAND ${LEMON_EXECUTABLE}
				-T/usr/share/lemon/lempar.c
				-d.
				${_in}
			DEPENDS
				${_in}
		)
	endmacro()
	add_custom_target(lemon)
else()
	# Compile bundled lemon with support for -- to end options
	macro(generate_lemon_file _out _in)
		add_custom_command(
			OUTPUT
				${_out}.c
				# These files are generated as side-effect
				${_out}.h
				${_out}.out
			COMMAND $<TARGET_FILE:lemon>
				-T${CMAKE_SOURCE_DIR}/tools/lemon/lempar.c
				-d.
				--
				${_in}
			DEPENDS
				${_in}
				lemon
				${CMAKE_SOURCE_DIR}/tools/lemon/lempar.c
		)
	endmacro()
endif()

macro(ADD_LEMON_FILES _source _generated)

	foreach (_current_FILE ${ARGN})
		get_filename_component(_in ${_current_FILE} ABSOLUTE)
		get_filename_component(_basename ${_current_FILE} NAME_WE)

		set(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename})

		generate_lemon_file(${_out} ${_in})

		list(APPEND ${_source} ${_in})
		list(APPEND ${_generated} ${_out}.c)
	endforeach(_current_FILE)
endmacro(ADD_LEMON_FILES)