a9cb0d17ecc3abbd7a9ea9f90923d55440c22c10
[reactos.git] / CMakeLists.txt
1
2 cmake_minimum_required(VERSION 2.6)
3 project(REACTOS)
4
5 #versioning
6 include(include/reactos/version.cmake)
7
8 # Don't escape preprocessor definition values added via add_definitions
9 cmake_policy(SET CMP0005 OLD)
10
11 if(NOT ARCH)
12 set(ARCH i386)
13 endif()
14
15 # Compile options
16 if(ARCH MATCHES i386)
17 include(config.cmake)
18 elseif(ARCH MATCHES amd64)
19 include(config-amd64.cmake)
20 elseif(ARCH MATCHES arm)
21 include(config-arm.cmake)
22 endif()
23
24 if(NOT CMAKE_CROSSCOMPILING)
25
26 add_definitions(-DTARGET_${ARCH})
27
28 if(ARCH MATCHES i386)
29 if(MSVC)
30 add_definitions(-Dinline=__inline)
31 endif()
32 endif()
33
34 include_directories(
35 ${REACTOS_SOURCE_DIR}/tools/unicode
36 include
37 include/host
38 include/reactos
39 include/reactos/wine
40 ${REACTOS_BINARY_DIR}/include)
41
42 if(NOT MSVC)
43 add_definitions(-fshort-wchar)
44 endif()
45
46 add_subdirectory(tools)
47 add_subdirectory(lib)
48
49 if(NOT MSVC)
50 export(TARGETS widl nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
51 else()
52 export(TARGETS nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
53 endif()
54
55 else()
56
57 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
58 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
59 endif()
60
61 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
62 include(${IMPORT_EXECUTABLES})
63
64 endif()
65
66 # Compiler specific definitions and macros
67 if(MSVC)
68 include(msc.cmake)
69 else()
70 include(gcc.cmake)
71 endif()
72
73 # Generic macros
74 include(CMakeMacros.cmake)
75
76 set(CMAKE_INCLUDE_CURRENT_DIR ON)
77 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
78 set(CMAKE_SHARED_LIBRARY_PREFIX "")
79
80 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
81 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
82
83 set(CMAKE_COLOR_MAKEFILE OFF)
84
85 set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
86
87 add_definitions(-D__REACTOS__)
88
89 if(CMAKE_CROSSCOMPILING)
90
91 #Some cleanup
92 file(REMOVE
93 ${REACTOS_BINARY_DIR}/dependencies.graphml
94 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
95 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
96 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
97 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
98 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
99 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
100
101 #Some useful variables
102 set(LIVECD_DIR "${REACTOS_BINARY_DIR}/boot/livecd")
103 set(BOOTCD_DIR "${REACTOS_BINARY_DIR}/boot/bootcd")
104
105 # Activate support for assembly source files
106 enable_language(ASM)
107
108 # Activate language support for resource files
109 enable_language(RC)
110
111 if(DBG)
112 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
113 endif()
114
115 if(KDBG)
116 add_definitions(-DKDBG=1)
117 endif()
118
119 if(_WINKD_)
120 add_definitions(-D_WINKD_=1)
121 endif()
122
123 # Version Options
124 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
125
126 # Arch Options
127 if(ARCH MATCHES i386)
128 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
129 elseif(ARCH MATCHES amd64)
130 add_definitions(-D_M_AMD64 -D_AMD64_ -D_M_AXP64 -D__x86_64__ -D_WIN64)
131 elseif(ARCH MATCHES arm)
132 # _M_ARM is already defined by toolchain
133 add_definitions(-D_ARM_ -D__arm__)
134 endif()
135
136 # Other
137 if(ARCH MATCHES i386)
138 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
139 elseif(ARCH MATCHES amd64)
140 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
141 elseif(ARCH MATCHES arm)
142 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
143 endif()
144
145 include_directories(
146 include
147 include/psdk
148 include/dxsdk
149 ${REACTOS_BINARY_DIR}/include
150 ${REACTOS_BINARY_DIR}/include/dxsdk
151 ${REACTOS_BINARY_DIR}/include/psdk
152 ${REACTOS_BINARY_DIR}/include/reactos
153 include/crt
154 include/ddk
155 include/ndk
156 include/reactos
157 include/reactos/libs)
158
159 if(ARCH MATCHES arm)
160 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
161 endif()
162
163 if(MSVC)
164 include_directories(include/crt/msc)
165 else()
166 include_directories(include/crt/mingw32)
167 endif()
168
169 add_dependency_header()
170
171 add_subdirectory(include/psdk)
172 add_subdirectory(include/dxsdk)
173 add_subdirectory(include/reactos/idl)
174 add_subdirectory(include/reactos/wine)
175 add_subdirectory(include/reactos/mc)
176 add_subdirectory(include/asm)
177
178 include(baseaddress.cmake)
179
180 add_subdirectory(base)
181 add_subdirectory(boot)
182 add_subdirectory(dll)
183 add_subdirectory(drivers)
184 add_subdirectory(hal)
185 add_subdirectory(lib)
186 add_subdirectory(media)
187 add_subdirectory(modules)
188 add_subdirectory(ntoskrnl)
189 add_subdirectory(subsystems)
190
191 # nci generated intermediate files
192
193 list(APPEND nci_output
194 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
195 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
196 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
197 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
198 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
199 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
200
201 list(APPEND nci_folders
202 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
203 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
204 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
205 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
206 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
207 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include)
208
209 file(MAKE_DIRECTORY ${nci_folders})
210
211 add_custom_command(
212 OUTPUT ${nci_output}
213 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
214 DEPENDS native-nci ${nci_folders})
215
216 set_source_files_properties(${nci_output} PROPERTIES GENERATED TRUE)
217
218 add_custom_target(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
219 add_custom_target(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
220 add_custom_target(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
221 add_custom_target(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
222 add_custom_target(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
223 add_custom_target(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
224
225 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
226
227 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
228
229 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
230
231 list(APPEND OUTPUT_FILES
232 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
233 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
234 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
235
236 add_custom_command(
237 OUTPUT ${OUTPUT_FILES}
238 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
239 DEPENDS native-gendib)
240
241 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
242
243 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
244
245 #bootcd and livecd
246 include(ros_cd.cmake)
247
248 add_dependency_footer()
249
250 endif()