-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
259 lines (232 loc) · 5.77 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# Nous voulons un cmake "récent" pour utiliser les dernières fonctionnalités
cmake_minimum_required(VERSION 3.0)
# Notre projet est étiqueté shell
project(binsh)
set(CMAKE_C_FLAGS "-std=c99 -D_XOPEN_SOURCE=600 -Wl,--no-as-needed -ldl -pthread -lm")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin )
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib )
# Crée des variables avec les fichiers à compiler
file(GLOB SRC
"src/*.c"
"src/commands/*.c"
)
file(GLOB HEADER
"include/*.h"
"include/commands/*.h"
)
# On indique que l'on veut un exécutable "shell" compilé à partir des fichiers décrits par les variables SRCS et HEADERS
add_executable(shell ${SRC} ${HEADER})
# building command executables
# ls
file(GLOB SRC_LS
"src/commands/ls.c"
"src/utils.c"
"src/main/ls.c"
)
file(GLOB HEADER_LS
"include/commands/ls.h"
)
add_executable(ls ${SRC_LS} ${HEADER_LS})
add_library(ls_lib SHARED ${SRC_LS})
set_target_properties(ls_lib PROPERTIES OUTPUT_NAME "ls")
# cd
file(GLOB SRC_CD
"src/commands/cd.c"
"src/main/cd.c"
)
file(GLOB HEADER_CD
"include/commands/cd.h"
)
add_executable(cd ${SRC_CD} ${HEADER_CD})
# cat
file(GLOB SRC_CAT
"src/commands/cat.c"
"src/utils.c"
"src/main/cat.c"
)
file(GLOB HEADER_CAT
"include/commands/cat.h"
)
add_executable(cat ${SRC_CAT} ${HEADER_CAT})
add_library(cat_lib SHARED ${SRC_CAT})
set_target_properties(cat_lib PROPERTIES OUTPUT_NAME "cat")
# echo
file(GLOB SRC_ECHO
"src/commands/echo.c"
"src/utils.c"
"src/main/echo.c"
)
file(GLOB HEADER_ECHO
"include/commands/echo.h"
)
add_executable(echo ${SRC_ECHO} ${HEADER_ECHO})
add_library(echo_lib SHARED ${SRC_ECHO})
set_target_properties(echo_lib PROPERTIES OUTPUT_NAME "echo")
# mv
file(GLOB SRC_MV
"src/commands/mv.c"
"src/utils.c"
"src/main/mv.c"
)
file(GLOB HEADER_MV
"include/commands/mv.h"
)
add_executable(mv ${SRC_MV} ${HEADER_MV})
add_library(mv_lib SHARED ${SRC_MV})
set_target_properties(mv_lib PROPERTIES OUTPUT_NAME "mv")
# pwd
file(GLOB SRC_PWD
"src/commands/pwd.c"
"src/utils.c"
"src/main/pwd.c"
)
file(GLOB HEADER_PWD
"include/commands/pwd.h"
)
add_executable(pwd ${SRC_PWD} ${HEADER_PWD})
add_library(pwd_lib SHARED ${SRC_PWD})
set_target_properties(pwd_lib PROPERTIES OUTPUT_NAME "pwd")
# mkdir
file(GLOB SRC_MKDIR
"src/commands/mkdir.c"
"src/utils.c"
"src/main/mkdir.c"
)
file(GLOB HEADER_MKDIR
"include/commands/mkdir.h"
)
add_executable(mkdir ${SRC_MKDIR} ${HEADER_MKDIR})
add_library(mkdir_lib SHARED ${SRC_MKDIR})
set_target_properties(mkdir_lib PROPERTIES OUTPUT_NAME "mkdir")
# connect
file(GLOB SRC_CONNECT
"src/commands/connect.c"
"src/utils.c"
"src/main/connect.c"
)
file(GLOB HEADER_CONNECT
"include/commands/connect.h"
)
add_executable(connect ${SRC_CONNECT} ${HEADER_CONNECT})
add_library(connect_lib SHARED ${SRC_CONNECT})
set_target_properties(connect_lib PROPERTIES OUTPUT_NAME "connect")
# du
file(GLOB SRC_DU
"src/commands/du.c"
"src/utils.c"
"src/main/du.c"
)
file(GLOB HEADER_DU
"include/commands/du.h"
)
add_executable(du ${SRC_DU} ${HEADER_DU})
add_library(du_lib SHARED ${SRC_DU})
set_target_properties(du_lib PROPERTIES OUTPUT_NAME "du")
# rm
file(GLOB SRC_RM
"src/commands/rm.c"
"src/utils.c"
"src/main/rm.c"
)
file(GLOB HEADER_RM
"include/commands/rm.h"
)
add_executable(rm ${SRC_RM} ${HEADER_RM})
add_library(rm_lib SHARED ${SRC_RM})
set_target_properties(rm_lib PROPERTIES OUTPUT_NAME "rm")
# cp
file(GLOB SRC_CP
"src/commands/cp.c"
"src/utils.c"
"src/main/cp.c"
)
file(GLOB HEADER_CP
"include/commands/cp.h"
)
add_executable(cp ${SRC_CP} ${HEADER_CP})
add_library(cp_lib SHARED ${SRC_CP})
set_target_properties(cp_lib PROPERTIES OUTPUT_NAME "cp")
# chmod
file(GLOB SRC_CHMOD
"src/commands/chmod.c"
"src/utils.c"
"src/main/chmod.c"
)
file(GLOB HEADER_CHMOD
"include/commands/chmod.h"
)
add_executable(chmod ${SRC_CHMOD} ${HEADER_CHMOD})
add_library(chmod_lib SHARED ${SRC_CHMOD})
set_target_properties(chmod_lib PROPERTIES OUTPUT_NAME "chmod")
# chown
file(GLOB SRC_CHOWN
"src/commands/chown.c"
"src/utils.c"
"src/main/chown.c"
)
file(GLOB HEADER_CHOWN
"include/commands/chown.h"
)
add_executable(chown ${SRC_CHOWN} ${HEADER_CHOWN})
add_library(chown_lib SHARED ${SRC_CHOWN})
set_target_properties(chown_lib PROPERTIES OUTPUT_NAME "chown")
# chgrp
file(GLOB SRC_CHGRP
"src/commands/chgrp.c"
"src/utils.c"
"src/main/chgrp.c"
)
file(GLOB HEADER_CHGRP
"include/commands/chgrp.h"
)
add_executable(chgrp ${SRC_CHGRP} ${HEADER_CHGRP})
add_library(chgrp_lib SHARED ${SRC_CHGRP})
set_target_properties(chgrp_lib PROPERTIES OUTPUT_NAME "chgrp")
# more
file(GLOB SRC_MORE
"src/commands/more.c"
"src/utils.c"
"src/main/more.c"
)
file(GLOB HEADER_MORE
"include/commands/more.h"
)
add_executable(more ${SRC_MORE} ${HEADER_MORE})
add_library(more_lib SHARED ${SRC_MORE})
set_target_properties(more_lib PROPERTIES OUTPUT_NAME "more")
# ps
file(GLOB SRC_PS
"src/commands/ps.c"
"src/utils.c"
"src/main/ps.c"
)
file(GLOB HEADER_PS
"include/commands/ps.h"
)
add_executable(ps ${SRC_PS} ${HEADER_PS})
add_library(ps_lib SHARED ${SRC_PS})
set_target_properties(ps_lib PROPERTIES OUTPUT_NAME "ps")
# top
file(GLOB SRC_TOP
"src/commands/top.c"
"src/utils.c"
"src/main/top.c"
)
file(GLOB HEADER_TOP
"include/commands/top.h"
)
add_executable(top ${SRC_TOP} ${HEADER_TOP})
add_library(top_lib SHARED ${SRC_TOP})
set_target_properties(top_lib PROPERTIES OUTPUT_NAME "top")
# clear
file(GLOB SRC_CLEAR
"src/commands/clear.c"
"src/utils.c"
"src/main/clear.c"
)
file(GLOB HEADER_CLEAR
"include/commands/clear.h"
)
add_executable(clear ${SRC_CLEAR} ${HEADER_CLEAR})
add_library(clear_lib SHARED ${SRC_CLEAR})
set_target_properties(clear_lib PROPERTIES OUTPUT_NAME "clear")