summaryrefslogtreecommitdiffhomepage
path: root/mrblib/CMakeLists.txt
blob: 30881c6116710b00def1d144012ff446c1b61213 (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
# build mrblib
# need custom commands 
# Compile C source from merged mruby source

file(GLOB MRBLIB_SRC_RB "*.rb")

# generate the a single rubu file from all the existing ones.
add_custom_command(OUTPUT mrblib.rbtmp
COMMAND cat ${MRBLIB_SRC_RB} > mrblib.rbtmp
DEPENDS ${MRBLIB_SRC_RB}
)

# generate the intermediate representation in C
add_custom_command(OUTPUT mrblib_irep.c 
COMMAND echo -B mrblib_irep -o mrblib_irep.c mrblib.rbtmp
COMMAND mrbc -Bmrblib_irep -omrblib_irep.c mrblib.rbtmp
DEPENDS mrblib.rbtmp
)

# finally generate the library's c file
add_custom_command(OUTPUT mrblib.c 
COMMAND cat init_mrblib.c mrblib_irep.c > mrblib.c
DEPENDS init_mrblib.c mrblib_irep.c
)

# only use this C file to generate mrblib.
set(MRBLIB_SRC_C mrblib.c)
# add_library(mrblib_static STATIC ${MRBLIB_SRC_C})
add_library(mrblib_object OBJECT ${MRBLIB_SRC_C})
# target_link_libraries(mrblib ritevm ${MRUBY_LIBS})
# target_link_libraries(mrblib_static ritevm_static ${MRUBY_LIBS})
# install(TARGETS mrblib mrblib_static
#         LIBRARY DESTINATION lib
#         ARCHIVE DESTINATION lib)