This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
146 lines (110 loc) · 4.01 KB
/
CMakeLists.txt
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.7)
project(mh)
set(CMAKE_C_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
if (NOT ${APPLE})
message( FATAL_ERROR "macOS only" )
endif()
if ("$ENV{BUILD_ARCH}")
set(BUILD_ARCH "$ENV{BUILD_ARCH}")
endif ()
if ("$ENV{IOS_JAILBREAK_ELECTRA}")
set(IOS_JAILBREAK_ELECTRA "$ENV{IOS_JAILBREAK_ELECTRA}")
endif()
if ("$ENV{LOCAL_SDK_ROOT}")
set(LOCAL_SDK_ROOT "$ENV{LOCAL_SDK_ROOT}")
endif()
if (EXISTS ${LOCAL_SDK_ROOT})
set(SDK_ROOT ${LOCAL_SDK_ROOT})
else()
set(SDK_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs")
endif()
execute_process(COMMAND echo "SDK_ROOT=${LOCAL_SDK_ROOT}")
execute_process(COMMAND echo "BUILD_ARCH=${BUILD_ARCH}")
if ("${BUILD_ARCH}" MATCHES "armv7s")
set(CMAKE_OSX_SYSROOT "${SDK_ROOT}/iPhoneOS10.3.sdk")
set(CMAKE_OSX_ARCHITECTURES "${BUILD_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_OS_IPHONE=1")
elseif ("${BUILD_ARCH}" MATCHES "armv7")
set(CMAKE_OSX_SYSROOT "${SDK_ROOT}/iPhoneOS10.3.sdk")
set(CMAKE_OSX_ARCHITECTURES "${BUILD_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_OS_IPHONE=1")
elseif ("${BUILD_ARCH}" MATCHES "arm64")
set(CMAKE_OSX_SYSROOT "${SDK_ROOT}/iPhoneOS11.2.sdk")
set(CMAKE_OSX_ARCHITECTURES "${BUILD_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_OS_IPHONE=1")
if ("${IOS_JAILBREAK_ELECTRA}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIOS_JAILBREAK_ELECTRA=1")
set(MISC_FILES
${CMAKE_SOURCE_DIR}/src/app/misc/jailbreak.c
)
execute_process(COMMAND echo "Jailbreak!")
endif()
elseif ("${BUILD_ARCH}" MATCHES "arm64e")
set(CMAKE_OSX_SYSROOT "${SDK_ROOT}/iPhoneOS12.2.sdk")
set(CMAKE_OSX_ARCHITECTURES "${BUILD_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_OS_IPHONE=1")
else ()
link_directories(/usr/lib)
endif ()
include_directories(src)
include_directories(${CMAKE_SOURCE_DIR}/deps/linenoise)
include_directories(${CMAKE_SOURCE_DIR}/deps/duktape)
set(LINENOISE_FILES
${CMAKE_SOURCE_DIR}/deps/linenoise/linenoise.c
)
if(EXISTS ${CMAKE_SOURCE_DIR}/deps/duktape/duktape.c)
set(DUKTAPE_FILES
${CMAKE_SOURCE_DIR}/deps/duktape/duk_config.h
${CMAKE_SOURCE_DIR}/deps/duktape/duktape.h
${CMAKE_SOURCE_DIR}/deps/duktape/duktape.c
${CMAKE_SOURCE_DIR}/deps/duktape/extras/console/duk_console.c
)
file(GLOB SCRIPT_FUNCTION_FILES ${CMAKE_SOURCE_DIR}/src/app/scripts/*.c)
set(SCRIPT_FILES
${SCRIPT_FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/src/app/scripts.c
${CMAKE_SOURCE_DIR}/src/app/commands/script.c
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DJAVASCRIPT_SUPPORT=1")
endif()
set(LIBRARY_FILES
${CMAKE_SOURCE_DIR}/src/mh/mh.c
${CMAKE_SOURCE_DIR}/src/mh/search.c
${CMAKE_SOURCE_DIR}/src/mh/utils.c
${CMAKE_SOURCE_DIR}/src/mh/result.c
)
#set(DEPENDENCY_FILES)
set(APP_FILES
${CMAKE_SOURCE_DIR}/src/app/config.h
${CMAKE_SOURCE_DIR}/src/app/app.h
${CMAKE_SOURCE_DIR}/src/app/misc.h
${CMAKE_SOURCE_DIR}/src/app/context.c
${CMAKE_SOURCE_DIR}/src/app/commands/commands.h
${CMAKE_SOURCE_DIR}/src/app/commands/help.c
${CMAKE_SOURCE_DIR}/src/app/commands/memory.c
${CMAKE_SOURCE_DIR}/src/app/commands/search.c
${CMAKE_SOURCE_DIR}/src/app/commands/open.c
${CMAKE_SOURCE_DIR}/src/app/commands/utils.c
${CMAKE_SOURCE_DIR}/src/app/commands/process.c
${MISC_FILES}
${SCRIPT_FILES}
)
add_executable(mh_cli
${CMAKE_SOURCE_DIR}/src/app/args.c
${CMAKE_SOURCE_DIR}/src/app/main.c
${APP_FILES}
${LIBRARY_FILES}
${DEPENDENCY_FILES}
${LINENOISE_FILES}
${DUKTAPE_FILES}
)
add_executable(mh_script
${CMAKE_SOURCE_DIR}/src/app/script-main.c
${APP_FILES}
${LIBRARY_FILES}
${DEPENDENCY_FILES}
${LINENOISE_FILES}
${DUKTAPE_FILES}
)
add_subdirectory(tests)