[LT2013]
[reactos.git] / ntoskrnl / CMakeLists.txt
1
2 PROJECT(NTOS)
3
4 spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB)
5
6 include_directories(
7 ${REACTOS_SOURCE_DIR}
8 ${REACTOS_SOURCE_DIR}/lib/cmlib
9 include
10 ${CMAKE_CURRENT_BINARY_DIR}/include
11 ${CMAKE_CURRENT_BINARY_DIR}/include/internal
12 ${REACTOS_SOURCE_DIR}/include/reactos/drivers)
13
14 add_definitions(
15 -D__NTOSKRNL__
16 -D_NTOSKRNL_
17 -D_NTSYSTEM_
18 -D_IN_KERNEL_
19 -DNTDDI_VERSION=0x05020400)
20
21 if(NOT DEFINED NEWCC)
22 set(NEWCC FALSE)
23 endif()
24
25 if(NEWCC)
26 add_definitions(-DNEWCC)
27 list(APPEND SOURCE
28 cache/cachesub.c
29 cache/copysup.c
30 cache/fssup.c
31 cache/lazyrite.c
32 cache/logsup.c
33 cache/mdlsup.c
34 cache/pinsup.c)
35 else()
36 list(APPEND SOURCE
37 cc/cacheman.c
38 cc/copy.c
39 cc/fs.c
40 cc/mdl.c
41 cc/pin.c
42 cc/view.c)
43 endif()
44
45 list(APPEND SOURCE
46 cache/section/io.c
47 cache/section/data.c
48 cache/section/fault.c
49 cache/section/reqtools.c
50 cache/section/sptab.c
51 cache/section/swapout.c
52 config/cmalloc.c
53 config/cmapi.c
54 config/cmboot.c
55 config/cmcheck.c
56 config/cmconfig.c
57 config/cmcontrl.c
58 config/cmdata.c
59 config/cmdelay.c
60 config/cmhook.c
61 config/cmhvlist.c
62 config/cmindex.c
63 config/cminit.c
64 config/cmkcbncb.c
65 config/cmkeydel.c
66 config/cmlazy.c
67 config/cmmapvw.c
68 config/cmname.c
69 config/cmnotify.c
70 config/cmparse.c
71 config/cmquota.c
72 config/cmse.c
73 config/cmsecach.c
74 config/cmsysini.c
75 config/cmvalche.c
76 config/cmvalue.c
77 config/cmwraprs.c
78 config/ntapi.c
79 dbgk/dbgkobj.c
80 dbgk/dbgkutil.c
81 ex/atom.c
82 ex/callback.c
83 ex/dbgctrl.c
84 ex/efi.c
85 ex/event.c
86 ex/evtpair.c
87 ex/exintrin.c
88 ex/fmutex.c
89 ex/handle.c
90 ex/harderr.c
91 ex/hdlsterm.c
92 ex/init.c
93 ex/interlocked.c
94 ex/keyedevt.c
95 ex/locale.c
96 ex/lookas.c
97 ex/mutant.c
98 ex/profile.c
99 ex/pushlock.c
100 ex/resource.c
101 ex/rundown.c
102 ex/sem.c
103 ex/shutdown.c
104 ex/sysinfo.c
105 ex/time.c
106 ex/timer.c
107 ex/uuid.c
108 ex/win32k.c
109 ex/work.c
110 ex/xipdisp.c
111 ex/zone.c
112 fsrtl/dbcsname.c
113 fsrtl/fastio.c
114 fsrtl/faulttol.c
115 fsrtl/filelock.c
116 fsrtl/filter.c
117 fsrtl/filtrctx.c
118 fsrtl/fsfilter.c
119 fsrtl/fsrtlpc.c
120 fsrtl/largemcb.c
121 fsrtl/mcb.c
122 fsrtl/name.c
123 fsrtl/notify.c
124 fsrtl/oplock.c
125 fsrtl/pnp.c
126 fsrtl/stackovf.c
127 fsrtl/tunnel.c
128 fsrtl/unc.c
129 fstub/disksup.c
130 fstub/fstubex.c
131 fstub/halstub.c
132 fstub/translate.c
133 inbv/inbv.c
134 inbv/inbvport.c
135 io/iomgr/adapter.c
136 io/iomgr/arcname.c
137 io/iomgr/bootlog.c
138 io/iomgr/controller.c
139 io/iomgr/device.c
140 io/iomgr/deviface.c
141 io/iomgr/driver.c
142 io/iomgr/error.c
143 io/iomgr/file.c
144 io/iomgr/iocomp.c
145 io/iomgr/ioevent.c
146 io/iomgr/iofunc.c
147 io/iomgr/iomdl.c
148 io/iomgr/iomgr.c
149 io/iomgr/iorsrce.c
150 io/iomgr/iotimer.c
151 io/iomgr/iowork.c
152 io/iomgr/irp.c
153 io/iomgr/irq.c
154 io/iomgr/ramdisk.c
155 io/iomgr/rawfs.c
156 io/iomgr/remlock.c
157 io/iomgr/symlink.c
158 io/iomgr/util.c
159 io/iomgr/volume.c
160 io/pnpmgr/plugplay.c
161 io/pnpmgr/pnpdma.c
162 io/pnpmgr/pnpinit.c
163 io/pnpmgr/pnpmgr.c
164 io/pnpmgr/pnpnotify.c
165 io/pnpmgr/pnpreport.c
166 io/pnpmgr/pnpres.c
167 io/pnpmgr/pnproot.c
168 io/pnpmgr/pnputil.c
169 ke/apc.c
170 ke/balmgr.c
171 ke/bug.c
172 ke/clock.c
173 ke/config.c
174 ke/devqueue.c
175 ke/dpc.c
176 ke/eventobj.c
177 ke/except.c
178 ke/freeze.c
179 ke/gate.c
180 ke/gmutex.c
181 ke/ipi.c
182 ke/krnlinit.c
183 ke/mutex.c
184 ke/procobj.c
185 ke/profobj.c
186 ke/queue.c
187 ke/semphobj.c
188 ke/spinlock.c
189 ke/thrdobj.c
190 ke/thrdschd.c
191 ke/time.c
192 ke/timerobj.c
193 ke/wait.c
194 lpc/close.c
195 lpc/complete.c
196 lpc/connect.c
197 lpc/create.c
198 lpc/listen.c
199 lpc/port.c
200 lpc/reply.c
201 lpc/send.c
202 mm/ARM3/contmem.c
203 mm/ARM3/drvmgmt.c
204 mm/ARM3/dynamic.c
205 mm/ARM3/expool.c
206 mm/ARM3/hypermap.c
207 mm/ARM3/iosup.c
208 mm/ARM3/largepag.c
209 mm/ARM3/mdlsup.c
210 mm/ARM3/mmdbg.c
211 mm/ARM3/mminit.c
212 mm/ARM3/mmsup.c
213 mm/ARM3/ncache.c
214 mm/ARM3/pagfault.c
215 mm/ARM3/pfnlist.c
216 mm/ARM3/pool.c
217 mm/ARM3/procsup.c
218 mm/ARM3/section.c
219 mm/ARM3/special.c
220 mm/ARM3/sysldr.c
221 mm/ARM3/syspte.c
222 mm/ARM3/vadnode.c
223 mm/ARM3/virtual.c
224 mm/ARM3/zeropage.c
225 mm/balance.c
226 mm/freelist.c
227 mm/marea.c
228 mm/mmfault.c
229 mm/mminit.c
230 mm/pagefile.c
231 mm/region.c
232 mm/rmap.c
233 mm/section.c
234 ob/obdir.c
235 ob/obhandle.c
236 ob/obinit.c
237 ob/oblife.c
238 ob/oblink.c
239 ob/obname.c
240 ob/obref.c
241 ob/obsdcach.c
242 ob/obsecure.c
243 ob/obwait.c
244 po/events.c
245 po/guid.c
246 po/poshtdwn.c
247 po/povolume.c
248 po/power.c
249 ps/debug.c
250 ps/job.c
251 ps/kill.c
252 ps/process.c
253 ps/psmgr.c
254 ps/psnotify.c
255 ps/query.c
256 ps/quota.c
257 ps/security.c
258 ps/state.c
259 ps/thread.c
260 ps/win32.c
261 rtl/libsupp.c
262 rtl/misc.c
263 se/access.c
264 se/acl.c
265 se/audit.c
266 se/lsa.c
267 se/priv.c
268 se/sd.c
269 se/semgr.c
270 se/sid.c
271 se/token.c
272 vf/driver.c
273 wmi/wmi.c
274 ntoskrnl.rc)
275
276 list(APPEND ASM_SOURCE ex/zw.S)
277
278 if(ARCH STREQUAL "i386")
279 list(APPEND ASM_SOURCE
280 ex/i386/fastinterlck_asm.S
281 ex/i386/ioport.S
282 ke/i386/ctxswitch.S
283 ke/i386/trap.s
284 ke/i386/usercall_asm.S
285 rtl/i386/stack.S)
286 list(APPEND SOURCE
287 config/i386/cmhardwr.c
288 ke/i386/abios.c
289 ke/i386/cpu.c
290 ke/i386/context.c
291 ke/i386/exp.c
292 ke/i386/irqobj.c
293 ke/i386/kiinit.c
294 ke/i386/ldt.c
295 ke/i386/mtrr.c
296 ke/i386/patpge.c
297 ke/i386/thrdini.c
298 ke/i386/traphdlr.c
299 ke/i386/usercall.c
300 ke/i386/v86vdm.c
301 mm/i386/page.c
302 mm/ARM3/i386/init.c
303 ps/i386/psctx.c
304 ps/i386/psldt.c
305 vdm/vdmmain.c
306 vdm/vdmexec.c)
307 elseif(ARCH STREQUAL "amd64")
308 list(APPEND ASM_SOURCE
309 ke/amd64/boot.S
310 ke/amd64/ctxswitch.S
311 ke/amd64/trap.S)
312 list(APPEND SOURCE
313 config/i386/cmhardwr.c
314 ke/amd64/context.c
315 ke/amd64/cpu.c
316 ke/amd64/except.c
317 ke/amd64/interrupt.c
318 ke/amd64/irql.c
319 ke/amd64/kiinit.c
320 ke/amd64/krnlinit.c
321 ke/amd64/spinlock.c
322 ke/amd64/stubs.c
323 ke/amd64/thrdini.c
324 mm/amd64/init.c
325 mm/amd64/page.c
326 ps/amd64/psctx.c)
327 elseif(ARCH STREQUAL "arm")
328 list(APPEND ASM_SOURCE
329 ke/arm/boot.s
330 ke/arm/ctxswtch.s
331 ke/arm/stubs_asm.s
332 ke/arm/trap.s)
333 list(APPEND SOURCE
334 config/arm/cmhardwr.c
335 ke/arm/cpu.c
336 ke/arm/exp.c
337 ke/arm/kiinit.c
338 ke/arm/thrdini.c
339 ke/arm/trapc.c
340 ke/arm/usercall.c
341 mm/arm/page.c
342 mm/ARM3/arm/init.c
343 ps/arm/psctx.c
344 rtl/arm/rtlexcpt.c)
345 elseif(ARCH STREQUAL "powerpc")
346 list(APPEND ASM_SOURCE
347 ke/powerpc/main_asm.S
348 ke/powerpc/ctxhelp.S)
349 list(APPEND SOURCE
350 config/powerpc/cmhardwr.c
351 ke/powerpc/cpu.c
352 ke/powerpc/exp.c
353 ke/powerpc/kiinit.c
354 ke/powerpc/ppc_irq.c
355 ke/powerpc/stubs.c
356 ke/powerpc/systimer.c
357 ke/powerpc/thrdini.c
358 ke/powerpc/ctxswitch.c
359 mm/powerpc/pfault.c
360 mm/powerpc/page.c)
361 endif()
362
363 if(NOT _WINKD_)
364 if(ARCH STREQUAL "i386")
365 list(APPEND SOURCE
366 kd/i386/kdmemsup.c
367 kd/wrappers/gdbstub.c)
368 if(KDBG)
369 list(APPEND ASM_SOURCE kdbg/i386/kdb_help.S)
370 list(APPEND SOURCE kdbg/i386/i386-dis.c)
371 endif()
372 elseif(ARCH STREQUAL "amd64")
373 list(APPEND SOURCE
374 kd/amd64/kd.c
375 kd/amd64/kdmemsup.c)
376 if(KDBG)
377 list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
378 list(APPEND SOURCE
379 kdbg/amd64/i386-dis.c
380 kdbg/amd64/kdb.c)
381 endif()
382 elseif(ARCH STREQUAL "powerpc")
383 list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
384 endif()
385
386 if(KDBG)
387 list(APPEND SOURCE
388 kdbg/kdb.c
389 kdbg/kdb_cli.c
390 kdbg/kdb_expr.c
391 kdbg/kdb_keyboard.c
392 kdbg/kdb_serial.c)
393 endif()
394
395 if(DBG OR KDBG)
396 #list(APPEND SOURCE kdbg/kdb_symbols.cmake.c)
397 list(APPEND SOURCE kdbg/kdb_symbols.c)
398 endif()
399
400 list(APPEND SOURCE
401 kd/wrappers/bochs.c
402 kd/wrappers/kdbg.c
403 kd/kdinit.c
404 kd/kdio.c
405 kd/kdmain.c)
406
407 else() # _WINKD_
408
409 list(APPEND SOURCE
410 kd64/kdapi.c
411 kd64/kdbreak.c
412 kd64/kddata.c
413 kd64/kdinit.c
414 kd64/kdlock.c
415 kd64/kdprint.c
416 kd64/kdtrap.c)
417
418 if(ARCH STREQUAL "i386")
419 list(APPEND SOURCE kd64/i386/kdx86.c)
420 elseif(ARCH STREQUAL "amd64")
421 list(APPEND SOURCE kd64/amd64/kdx64.c)
422 elseif(ARCH STREQUAL "arm")
423 list(APPEND SOURCE kd64/arm/kdarm.c)
424 endif()
425
426 endif()
427
428 add_asm_files(ntoskrnl_asm ${ASM_SOURCE})
429
430 add_executable(ntoskrnl
431 ${ntoskrnl_asm}
432 ${SOURCE}
433 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
434
435 if(ARCH STREQUAL "i386")
436 set_entrypoint(ntoskrnl KiSystemStartup 4)
437 else()
438 set_entrypoint(ntoskrnl KiSystemStartup)
439 endif()
440 set_subsystem(ntoskrnl native)
441
442 if(MSVC)
443 set_image_base(ntoskrnl 0x00400000)
444 else()
445 set_image_base(ntoskrnl 0x80800000)
446 endif()
447
448 # Linker bug
449 if(NOT MSVC AND LTCG)
450 add_target_link_flags(ntoskrnl "-shared")
451 endif()
452
453 target_link_libraries(ntoskrnl
454 cportlib
455 csq
456 ${PSEH_LIB}
457 cmlib
458 rtl
459 rossym
460 libcntpr
461 wdmguid
462 ioevent)
463
464 add_importlibs(ntoskrnl hal kdcom bootvid)
465 add_pch(ntoskrnl include/ntoskrnl.h)
466 add_dependencies(ntoskrnl psdk bugcodes asm)
467 add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
468
469 if(BUILD_MP)
470 spec2def(ntkrnlmp.exe ntoskrnl.spec)
471
472 if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
473 set_source_files_properties(${ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "CONFIG_SMP")
474 endif()
475
476 add_asm_files(ntkrnlmp_asm ${ASM_SOURCE})
477
478 add_executable(ntkrnlmp
479 ${ntkrnlmp_asm}
480 ${SOURCE}
481 ${CMAKE_CURRENT_BINARY_DIR}/ntkrnlmp.def)
482
483 add_target_compile_definitions(ntkrnlmp CONFIG_SMP)
484
485 if(ARCH STREQUAL "i386")
486 set_entrypoint(ntkrnlmp KiSystemStartup 4)
487 else()
488 set_entrypoint(ntkrnlmp KiSystemStartup)
489 endif()
490 set_subsystem(ntkrnlmp native)
491
492 if(MSVC)
493 set_image_base(ntkrnlmp 0x00400000)
494 else()
495 set_image_base(ntkrnlmp 0x80800000)
496 endif()
497
498 # Linker bug
499 if(NOT MSVC AND LTCG)
500 add_target_link_flags(ntkrnlmp "-shared")
501 endif()
502
503 target_link_libraries(ntkrnlmp cportlib csq ${PSEH_LIB} cmlib rtl rossym libcntpr wdmguid ioevent)
504 add_importlibs(ntkrnlmp hal kdcom bootvid)
505 add_dependencies(ntkrnlmp psdk bugcodes asm)
506 add_cd_file(TARGET ntkrnlmp DESTINATION reactos/system32 NO_CAB FOR all)
507 endif()
508
509 add_asm_files(ntdllsys_asm ntdll.S)
510 add_library(ntdllsys ${ntdllsys_asm})
511 set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")