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