xref: /reactos/ntoskrnl/CMakeLists.txt (revision 9393fc32)
1
2PROJECT(NTOS)
3
4if (GCC)
5    # Enable this again. CORE-17637
6    add_compile_options(-Wunused-result)
7endif()
8
9include(ntos.cmake)
10
11if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
12    # Make sure we don't duplicate some symbols
13    add_compile_options(-fno-common)
14endif()
15
16set(NTOSKRNL_SOURCE ${SOURCE})
17set(NTOSKRNL_ASM_SOURCE ${ASM_SOURCE})
18
19set(NTKRNLMP_SOURCE ${SOURCE})
20set(NTKRNLMP_ASM_SOURCE ${ASM_SOURCE})
21
22spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB)
23
24# Embed RTC libs
25if (STACK_PROTECTOR)
26    target_sources(libntoskrnl PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>)
27endif()
28
29add_asm_files(ntoskrnl_asm ${NTOSKRNL_ASM_SOURCE})
30
31if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
32    # Clang optimises strcmp calls to memcmp.
33    target_sources(libntoskrnl PRIVATE $<TARGET_OBJECTS:memcmp>)
34endif()
35
36list(APPEND PCH_SKIP_SOURCE
37    guid.c)
38
39add_executable(ntoskrnl
40    ${ntoskrnl_asm}
41    ${NTOSKRNL_SOURCE}
42    ${PCH_SKIP_SOURCE}
43    ntoskrnl.rc
44    ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
45set_module_type(ntoskrnl kernel)
46
47source_group(TREE ${REACTOS_SOURCE_DIR}/ntoskrnl PREFIX "Source Files" FILES ${NTOSKRNL_SOURCE})
48
49target_link_libraries(ntoskrnl cportlib csq ${PSEH_LIB} arbiter cmlib ntlsalib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent)
50
51if(STACK_PROTECTOR)
52    target_sources(ntoskrnl PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>)
53endif()
54
55add_importlibs(ntoskrnl hal kdcom bootvid)
56add_pch(ntoskrnl ${REACTOS_SOURCE_DIR}/ntoskrnl/include/ntoskrnl.h "${PCH_SKIP_SOURCE}")
57add_dependencies(ntoskrnl psdk asm)
58add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
59
60if(BUILD_MP)
61    add_subdirectory(ntkrnlmp)
62endif()
63
64add_asm_files(ntdllsys_asm ntdll.S)
65add_library(ntdllsys ${ntdllsys_asm})
66set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")
67add_dependencies(ntdllsys asm)
68