summaryrefslogtreecommitdiff
path: root/source/luametatex/source/luaoptional/cmake/mujs/CMakeLists.txt
blob: cfe2ee2bf0a6c87daa7e12fcfc53f7c9ba73bcf7 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# This file is made by Mojca and Hans and is subjected to changes
# as we proceed with luametatex and the contextgarden compile farm.

cmake_minimum_required(VERSION 3.7)

# Lucky us: only normal C is used:

project (mujs
	VERSION 1.0.6
	DESCRIPTION "MuJS embeddable Javascript interpreter"
	LANGUAGES C)

# The jsrepr.c is not needed and depends on utf.c as well has some function
# pointer cast issue (accessing unknown name field).

set (mujs_sources
	jsarray.c
	jsboolean.c
	jsbuiltin.c
	jscompile.c
	jsdate.c
	jsdtoa.c
	jsdump.c
	jserror.c
	jsfunction.c
	jsgc.c
	jsintern.c
	jslex.c
	jsmath.c
	jsnumber.c
	jsobject.c
	json.c
	jsparse.c
	jsproperty.c
	jsregexp.c
#	jsrepr.c
	jsrun.c
	jsstate.c
	jsstring.c
	jsvalue.c
	regexp.c
	utf.c
	utftype.c
)

set (mujs_headers
	jsbuiltin.h
	jscompile.h
	jsi.h
	jslex.h
	jsparse.h
	jsrun.h
	jsvalue.h
	mujs.h
	regexp.h
	utf.h
)

# We need this in order for msvc to export the symbols (which is default on
# gcc). Otherwise we need this dllexport stuff.

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# The previous one has to come before the next one!

if (MSVC)

	add_library(mujs SHARED ${mujs_headers} ${mujs_sources} )

else()

	# Is this hack still needed or does the above work ok.?

	add_library(mujs SHARED ${mujs_headers} one.c)

endif()

# As per make file.

set_property(TARGET mujs PROPERTY C_STANDARD 99)

# We want consistent and predictable names:

set_target_properties(mujs PROPERTIES OUTPUT_NAME "libmujs")

# Some options based on what's in upstream's make file.

if (NOT MSVC)

	target_compile_options(mujs
		PRIVATE
			-pedantic
			-Wall
			-Wextra
			-Wno-unused-parameter
		)

	if (CMAKE_C_COMPILER_ID STREQUAL "Clang")

		target_compile_options(mujs
			PRIVATE
				-Wunreachable-code
		)

	endif()

endif()