[CMAKE]: Make simple rule for building ASM files.
[reactos.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(REACTOS)
3
4 add_definitions(-D__REACTOS__)
5
6 if(NOT CMAKE_CROSSCOMPILING)
7
8 add_definitions(-DTARGET_i386)
9 add_definitions(-fshort-wchar)
10
11 include_directories(${REACTOS_SOURCE_DIR}/tools/unicode)
12 include_directories(./include)
13 include_directories(./include/reactos)
14 include_directories(./include/reactos/wine)
15
16 add_subdirectory(tools)
17 add_subdirectory(lib)
18
19 export(TARGETS widl winebuild nci FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
20
21 else()
22
23 # Activate support for assembly source files
24 enable_language(ASM)
25
26 # Activate language support for resource files
27 enable_language(RC)
28
29 set(IMPORT_EXECUTABLES "${REACTOS_SOURCE_DIR}/build/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
30 include(${IMPORT_EXECUTABLES})
31
32 # Debug Options
33 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE -DKDBG=1)
34
35 # Version Options
36 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
37
38 # Arch Options
39 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
40
41 # Other
42 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
43 add_definitions(-D_USE_32BIT_TIME_T)
44
45 # Compiler Core
46 add_definitions(-pipe -fms-extensions -fno-set-stack-executable)
47
48 # Debugging (Note: DWARF-4 on 4.5.1 when we ship)
49 add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
50
51 # Tuning
52 add_definitions(-march=pentium -mtune=i686)
53
54 # Warnings
55 add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value)
56
57 # Optimizations
58 add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-optimize-sibling-calls)
59
60 include_directories(./include)
61 include_directories(./include/psdk)
62 include_directories(./include/dxsdk)
63 include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
64 include_directories(${REACTOS_BINARY_DIR}/include/psdk)
65 include_directories(${REACTOS_BINARY_DIR}/include/reactos)
66 include_directories(./include/crt)
67 include_directories(./include/crt/mingw32)
68 include_directories(./include/ddk)
69 include_directories(./include/ndk)
70 include_directories(./include/reactos)
71 include_directories(./include/reactos/libs)
72
73 add_subdirectory(include/psdk)
74 add_subdirectory(include/dxsdk)
75 add_subdirectory(include/reactos/mc)
76
77 add_subdirectory(base)
78 add_subdirectory(dll)
79 add_subdirectory(lib)
80
81 # nci generated intermediate files
82
83 set(nci_output
84 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
85 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
86 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
87 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
88 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
89 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec
90 )
91
92 # stupid nci tool can't create folders itself, se we're gonna create them for it
93 set(nci_folders
94 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
95 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
96 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
97 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
98 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
99 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include
100 )
101
102 file(MAKE_DIRECTORY ${nci_folders})
103
104 ADD_CUSTOM_COMMAND(
105 OUTPUT ${nci_output}
106 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
107 DEPENDS native-nci ${nci_folders}
108 )
109
110 SET_SOURCE_FILES_PROPERTIES(${nci_output} PROPERTIES GENERATED TRUE)
111
112 ADD_CUSTOM_TARGET(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
113 ADD_CUSTOM_TARGET(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
114 ADD_CUSTOM_TARGET(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
115 ADD_CUSTOM_TARGET(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
116 ADD_CUSTOM_TARGET(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
117 ADD_CUSTOM_TARGET(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
118
119 endif()
120