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