Sync up with trunk r61578.
[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/session.c
220 mm/ARM3/special.c
221 mm/ARM3/sysldr.c
222 mm/ARM3/syspte.c
223 mm/ARM3/vadnode.c
224 mm/ARM3/virtual.c
225 mm/ARM3/zeropage.c
226 mm/balance.c
227 mm/freelist.c
228 mm/marea.c
229 mm/mmfault.c
230 mm/mminit.c
231 mm/pagefile.c
232 mm/region.c
233 mm/rmap.c
234 mm/section.c
235 ob/obdir.c
236 ob/obhandle.c
237 ob/obinit.c
238 ob/oblife.c
239 ob/oblink.c
240 ob/obname.c
241 ob/obref.c
242 ob/obsdcach.c
243 ob/obsecure.c
244 ob/obwait.c
245 po/events.c
246 po/guid.c
247 po/poshtdwn.c
248 po/povolume.c
249 po/power.c
250 ps/debug.c
251 ps/job.c
252 ps/kill.c
253 ps/process.c
254 ps/psmgr.c
255 ps/psnotify.c
256 ps/query.c
257 ps/quota.c
258 ps/security.c
259 ps/state.c
260 ps/thread.c
261 ps/win32.c
262 rtl/libsupp.c
263 rtl/misc.c
264 se/access.c
265 se/acl.c
266 se/audit.c
267 se/lsa.c
268 se/priv.c
269 se/sd.c
270 se/semgr.c
271 se/sid.c
272 se/token.c
273 vf/driver.c
274 wmi/wmi.c
275 ntoskrnl.rc)
276
277 list(APPEND ASM_SOURCE ex/zw.S)
278
279 if(ARCH STREQUAL "i386")
280 list(APPEND ASM_SOURCE
281 ex/i386/fastinterlck_asm.S
282 ex/i386/ioport.S
283 ke/i386/ctxswitch.S
284 ke/i386/trap.s
285 ke/i386/usercall_asm.S
286 rtl/i386/stack.S)
287 list(APPEND SOURCE
288 config/i386/cmhardwr.c
289 ke/i386/abios.c
290 ke/i386/cpu.c
291 ke/i386/context.c
292 ke/i386/exp.c
293 ke/i386/irqobj.c
294 ke/i386/kiinit.c
295 ke/i386/ldt.c
296 ke/i386/mtrr.c
297 ke/i386/patpge.c
298 ke/i386/thrdini.c
299 ke/i386/traphdlr.c
300 ke/i386/usercall.c
301 ke/i386/v86vdm.c
302 mm/i386/page.c
303 mm/ARM3/i386/init.c
304 ps/i386/psctx.c
305 ps/i386/psldt.c
306 vdm/vdmmain.c
307 vdm/vdmexec.c)
308 elseif(ARCH STREQUAL "amd64")
309 list(APPEND ASM_SOURCE
310 ke/amd64/boot.S
311 ke/amd64/ctxswitch.S
312 ke/amd64/trap.S)
313 list(APPEND SOURCE
314 config/i386/cmhardwr.c
315 ke/amd64/context.c
316 ke/amd64/cpu.c
317 ke/amd64/except.c
318 ke/amd64/interrupt.c
319 ke/amd64/irql.c
320 ke/amd64/kiinit.c
321 ke/amd64/krnlinit.c
322 ke/amd64/spinlock.c
323 ke/amd64/stubs.c
324 ke/amd64/thrdini.c
325 mm/amd64/init.c
326 mm/amd64/page.c
327 ps/amd64/psctx.c)
328 elseif(ARCH STREQUAL "arm")
329 list(APPEND ASM_SOURCE
330 ke/arm/boot.s
331 ke/arm/ctxswtch.s
332 ke/arm/stubs_asm.s
333 ke/arm/trap.s)
334 list(APPEND SOURCE
335 config/arm/cmhardwr.c
336 ke/arm/cpu.c
337 ke/arm/exp.c
338 ke/arm/kiinit.c
339 ke/arm/thrdini.c
340 ke/arm/trapc.c
341 ke/arm/usercall.c
342 mm/arm/page.c
343 mm/ARM3/arm/init.c
344 ps/arm/psctx.c
345 rtl/arm/rtlexcpt.c)
346 elseif(ARCH STREQUAL "powerpc")
347 list(APPEND ASM_SOURCE
348 ke/powerpc/main_asm.S
349 ke/powerpc/ctxhelp.S)
350 list(APPEND SOURCE
351 config/powerpc/cmhardwr.c
352 ke/powerpc/cpu.c
353 ke/powerpc/exp.c
354 ke/powerpc/kiinit.c
355 ke/powerpc/ppc_irq.c
356 ke/powerpc/stubs.c
357 ke/powerpc/systimer.c
358 ke/powerpc/thrdini.c
359 ke/powerpc/ctxswitch.c
360 mm/powerpc/pfault.c
361 mm/powerpc/page.c)
362 endif()
363
364 if(NOT _WINKD_)
365 if(ARCH STREQUAL "i386")
366 list(APPEND SOURCE
367 kd/i386/kdbg.c
368 kd/i386/kdmemsup.c
369 kd/wrappers/gdbstub.c)
370 if(KDBG)
371 list(APPEND ASM_SOURCE kdbg/i386/kdb_help.S)
372 list(APPEND SOURCE kdbg/i386/i386-dis.c)
373 endif()
374 elseif(ARCH STREQUAL "amd64")
375 list(APPEND SOURCE
376 kd/amd64/kd.c
377 kd/i386/kdbg.c # Use the x86 file
378 kd/amd64/kdmemsup.c)
379 if(KDBG)
380 list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
381 list(APPEND SOURCE
382 kdbg/amd64/i386-dis.c
383 kdbg/amd64/kdb.c)
384 endif()
385 elseif(ARCH STREQUAL "arm")
386 list(APPEND SOURCE kd/arm/kdbg.c)
387 elseif(ARCH STREQUAL "powerpc")
388 list(APPEND SOURCE kd/wrappers/gdbstub_powerpc.c)
389 endif()
390
391 if(KDBG)
392 list(APPEND SOURCE
393 kdbg/kdb.c
394 kdbg/kdb_cli.c
395 kdbg/kdb_expr.c
396 kdbg/kdb_keyboard.c
397 kdbg/kdb_serial.c
398 kdbg/kdb_symbols.c)
399 endif()
400
401 list(APPEND SOURCE
402 kd/wrappers/bochs.c
403 kd/wrappers/kdbg.c
404 kd/kdinit.c
405 kd/kdio.c
406 kd/kdmain.c)
407
408 else() # _WINKD_
409
410 list(APPEND SOURCE
411 kd64/kdapi.c
412 kd64/kdbreak.c
413 kd64/kddata.c
414 kd64/kdinit.c
415 kd64/kdlock.c
416 kd64/kdprint.c
417 kd64/kdtrap.c)
418
419 if(ARCH STREQUAL "i386")
420 list(APPEND SOURCE kd64/i386/kdx86.c)
421 elseif(ARCH STREQUAL "amd64")
422 list(APPEND SOURCE kd64/amd64/kdx64.c)
423 elseif(ARCH STREQUAL "arm")
424 list(APPEND SOURCE kd64/arm/kdarm.c)
425 endif()
426
427 endif()
428
429 add_asm_files(ntoskrnl_asm ${ASM_SOURCE})
430
431 add_executable(ntoskrnl
432 ${ntoskrnl_asm}
433 ${SOURCE}
434 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
435
436 if(ARCH STREQUAL "i386")
437 set_entrypoint(ntoskrnl KiSystemStartup 4)
438 else()
439 set_entrypoint(ntoskrnl KiSystemStartup)
440 endif()
441 set_subsystem(ntoskrnl native)
442
443 if(MSVC)
444 set_image_base(ntoskrnl 0x00400000)
445 else()
446 set_image_base(ntoskrnl 0x80800000)
447 endif()
448
449 # Linker bug
450 if(NOT MSVC AND LTCG)
451 add_target_link_flags(ntoskrnl "-shared")
452 endif()
453
454 target_link_libraries(ntoskrnl
455 cportlib
456 csq
457 ${PSEH_LIB}
458 cmlib
459 rtl
460 ${ROSSYM_LIB}
461 libcntpr
462 wdmguid
463 ioevent)
464
465 add_importlibs(ntoskrnl hal kdcom bootvid)
466 add_pch(ntoskrnl include/ntoskrnl.h)
467 add_dependencies(ntoskrnl psdk bugcodes asm)
468 add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
469
470 if(BUILD_MP)
471 spec2def(ntkrnlmp.exe ntoskrnl.spec)
472
473 if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
474 set_source_files_properties(${ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "CONFIG_SMP")
475 endif()
476
477 add_asm_files(ntkrnlmp_asm ${ASM_SOURCE})
478
479 add_executable(ntkrnlmp
480 ${ntkrnlmp_asm}
481 ${SOURCE}
482 ${CMAKE_CURRENT_BINARY_DIR}/ntkrnlmp.def)
483
484 add_target_compile_definitions(ntkrnlmp CONFIG_SMP)
485
486 if(ARCH STREQUAL "i386")
487 set_entrypoint(ntkrnlmp KiSystemStartup 4)
488 else()
489 set_entrypoint(ntkrnlmp KiSystemStartup)
490 endif()
491 set_subsystem(ntkrnlmp native)
492
493 if(MSVC)
494 set_image_base(ntkrnlmp 0x00400000)
495 else()
496 set_image_base(ntkrnlmp 0x80800000)
497 endif()
498
499 # Linker bug
500 if(NOT MSVC AND LTCG)
501 add_target_link_flags(ntkrnlmp "-shared")
502 endif()
503
504 target_link_libraries(ntkrnlmp cportlib csq ${PSEH_LIB} cmlib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent)
505 add_importlibs(ntkrnlmp hal kdcom bootvid)
506 add_dependencies(ntkrnlmp psdk bugcodes asm)
507 add_cd_file(TARGET ntkrnlmp DESTINATION reactos/system32 NO_CAB FOR all)
508 endif()
509
510 add_asm_files(ntdllsys_asm ntdll.S)
511 add_library(ntdllsys ${ntdllsys_asm})
512 set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")