Synchronize with trunk revision 59781.
[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/kdbg.c
367 kd/i386/kdmemsup.c
368 kd/wrappers/gdbstub.c)
369 if(KDBG)
370 list(APPEND ASM_SOURCE kdbg/i386/kdb_help.S)
371 list(APPEND SOURCE kdbg/i386/i386-dis.c)
372 endif()
373 elseif(ARCH STREQUAL "amd64")
374 list(APPEND SOURCE
375 kd/amd64/kd.c
376 kd/i386/kdbg.c # Use the x86 file
377 kd/amd64/kdmemsup.c)
378 if(KDBG)
379 list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
380 list(APPEND SOURCE
381 kdbg/amd64/i386-dis.c
382 kdbg/amd64/kdb.c)
383 endif()
384 elseif(ARCH STREQUAL "arm")
385 list(APPEND SOURCE kd/arm/kdbg.c)
386 elseif(ARCH STREQUAL "powerpc")
387 list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
388 endif()
389
390 if(KDBG)
391 list(APPEND SOURCE
392 kdbg/kdb.c
393 kdbg/kdb_cli.c
394 kdbg/kdb_expr.c
395 kdbg/kdb_keyboard.c
396 kdbg/kdb_serial.c)
397 endif()
398
399 if(DBG OR KDBG)
400 #list(APPEND SOURCE kdbg/kdb_symbols.cmake.c)
401 list(APPEND SOURCE kdbg/kdb_symbols.c)
402 endif()
403
404 list(APPEND SOURCE
405 kd/wrappers/bochs.c
406 kd/wrappers/kdbg.c
407 kd/kdinit.c
408 kd/kdio.c
409 kd/kdmain.c)
410
411 else() # _WINKD_
412
413 list(APPEND SOURCE
414 kd64/kdapi.c
415 kd64/kdbreak.c
416 kd64/kddata.c
417 kd64/kdinit.c
418 kd64/kdlock.c
419 kd64/kdprint.c
420 kd64/kdtrap.c)
421
422 if(ARCH STREQUAL "i386")
423 list(APPEND SOURCE kd64/i386/kdx86.c)
424 elseif(ARCH STREQUAL "amd64")
425 list(APPEND SOURCE kd64/amd64/kdx64.c)
426 elseif(ARCH STREQUAL "arm")
427 list(APPEND SOURCE kd64/arm/kdarm.c)
428 endif()
429
430 endif()
431
432 add_asm_files(ntoskrnl_asm ${ASM_SOURCE})
433
434 add_executable(ntoskrnl
435 ${ntoskrnl_asm}
436 ${SOURCE}
437 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
438
439 if(ARCH STREQUAL "i386")
440 set_entrypoint(ntoskrnl KiSystemStartup 4)
441 else()
442 set_entrypoint(ntoskrnl KiSystemStartup)
443 endif()
444 set_subsystem(ntoskrnl native)
445
446 if(MSVC)
447 set_image_base(ntoskrnl 0x00400000)
448 else()
449 set_image_base(ntoskrnl 0x80800000)
450 endif()
451
452 # Linker bug
453 if(NOT MSVC AND LTCG)
454 add_target_link_flags(ntoskrnl "-shared")
455 endif()
456
457 target_link_libraries(ntoskrnl
458 cportlib
459 csq
460 ${PSEH_LIB}
461 cmlib
462 rtl
463 rossym
464 libcntpr
465 wdmguid
466 ioevent)
467
468 add_importlibs(ntoskrnl hal kdcom bootvid)
469 add_pch(ntoskrnl include/ntoskrnl.h)
470 add_dependencies(ntoskrnl psdk bugcodes asm)
471 add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
472
473 if(BUILD_MP)
474 spec2def(ntkrnlmp.exe ntoskrnl.spec)
475
476 if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
477 set_source_files_properties(${ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "CONFIG_SMP")
478 endif()
479
480 add_asm_files(ntkrnlmp_asm ${ASM_SOURCE})
481
482 add_executable(ntkrnlmp
483 ${ntkrnlmp_asm}
484 ${SOURCE}
485 ${CMAKE_CURRENT_BINARY_DIR}/ntkrnlmp.def)
486
487 add_target_compile_definitions(ntkrnlmp CONFIG_SMP)
488
489 if(ARCH STREQUAL "i386")
490 set_entrypoint(ntkrnlmp KiSystemStartup 4)
491 else()
492 set_entrypoint(ntkrnlmp KiSystemStartup)
493 endif()
494 set_subsystem(ntkrnlmp native)
495
496 if(MSVC)
497 set_image_base(ntkrnlmp 0x00400000)
498 else()
499 set_image_base(ntkrnlmp 0x80800000)
500 endif()
501
502 # Linker bug
503 if(NOT MSVC AND LTCG)
504 add_target_link_flags(ntkrnlmp "-shared")
505 endif()
506
507 target_link_libraries(ntkrnlmp cportlib csq ${PSEH_LIB} cmlib rtl rossym libcntpr wdmguid ioevent)
508 add_importlibs(ntkrnlmp hal kdcom bootvid)
509 add_dependencies(ntkrnlmp psdk bugcodes asm)
510 add_cd_file(TARGET ntkrnlmp DESTINATION reactos/system32 NO_CAB FOR all)
511 endif()
512
513 add_asm_files(ntdllsys_asm ntdll.S)
514 add_library(ntdllsys ${ntdllsys_asm})
515 set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")