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