blob: 305ee2cdd0dcf7dea850887b7ca059cce29a9c38 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
find_package(Erlang REQUIRED)
macro(erl_target name)
parse_arguments(ARGS "HEADERS;OPTIONS" "" ${ARGN})
set(headers "")
set(out_files "")
foreach(header ${ARGS_HEADERS})
list(APPEND headers "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
endforeach(header ${ARGS_HEADERS})
set(deps "")
set(current "")
set(uses false)
foreach(src ${ARGS_DEFAULT_ARGS})
if(src STREQUAL "USING")
set(uses true)
else(src STREQUAL "USING")
if(uses)
list(APPEND deps "${CMAKE_CURRENT_BINARY_DIR}/${src}.beam")
set(uses false)
else(uses)
if(current)
set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${current}")
string(REPLACE ".erl" ".beam" current ${current})
set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${current}")
add_custom_command(
OUTPUT
${out_file}
COMMAND
${ERLC_EXECUTABLE}
"-o" ${CMAKE_CURRENT_BINARY_DIR}
"-pz" ${CMAKE_CURRENT_BINARY_DIR}
${ARGS_OPTIONS}
${in_file}
DEPENDS
${in_file}
${headers}
${deps}
)
list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${current}")
endif(current)
set(current ${src})
set(deps "")
endif(uses)
endif(src STREQUAL "USING")
endforeach(src ${ARGS_DEFAULT_ARGS})
set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${current}")
string(REPLACE ".erl" ".beam" current ${current})
set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${current}")
add_custom_command(
OUTPUT
${out_file}
COMMAND
${ERLC_EXECUTABLE}
"-o" ${CMAKE_CURRENT_BINARY_DIR}
"-pz" ${CMAKE_CURRENT_BINARY_DIR}
${ARGS_OPTIONS}
${in_file}
DEPENDS
${in_file}
${headers}
${deps}
)
list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${current}")
add_custom_target(
${name} ALL DEPENDS ${out_files}
)
endmacro(erl_target)
|