[CMAKE]
[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 string(TOLOWER ${ARCH} ARCH)
15
16 # Compile options
17 if(ARCH MATCHES i386)
18 include(config.cmake)
19 elseif(ARCH MATCHES amd64)
20 include(config-amd64.cmake)
21 elseif(ARCH MATCHES arm)
22 include(config-arm.cmake)
23 endif()
24
25 if(NOT CMAKE_CROSSCOMPILING)
26
27 add_definitions(-DTARGET_${ARCH})
28
29 if(MSVC)
30 add_definitions(-Dinline=__inline)
31 else()
32 add_definitions(-fshort-wchar)
33 endif()
34
35 include_directories(
36 ${REACTOS_SOURCE_DIR}/tools/unicode
37 include
38 include/host
39 include/reactos
40 include/reactos/wine
41 ${REACTOS_BINARY_DIR}/include)
42
43 add_subdirectory(tools)
44 add_subdirectory(lib)
45
46 if(NOT MSVC)
47 export(TARGETS widl nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
48 else()
49 export(TARGETS nci 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_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()