[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 set(CMAKE_INCLUDE_CURRENT_DIR ON)
12 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
13 set(CMAKE_SHARED_LIBRARY_PREFIX "")
14 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
15 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
16 set(CMAKE_COLOR_MAKEFILE OFF)
17 set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
18
19 if(NOT ARCH)
20 set(ARCH i386)
21 endif()
22 string(TOLOWER ${ARCH} ARCH)
23
24 # Compile options
25 if(ARCH MATCHES i386)
26 include(config.cmake)
27 elseif(ARCH MATCHES amd64)
28 include(config-amd64.cmake)
29 elseif(ARCH MATCHES arm)
30 include(config-arm.cmake)
31 endif()
32
33 add_definitions(-D__REACTOS__)
34
35 if(NOT CMAKE_CROSSCOMPILING)
36
37 add_definitions(-DTARGET_${ARCH})
38
39 if(MSVC)
40 add_definitions(-Dinline=__inline)
41 else()
42 add_definitions(-fshort-wchar)
43 endif()
44
45 include_directories(
46 ${REACTOS_SOURCE_DIR}/tools/unicode
47 include
48 include/host
49 include/reactos
50 include/reactos/wine
51 ${REACTOS_BINARY_DIR}/include)
52
53 add_subdirectory(tools)
54 add_subdirectory(lib)
55
56 if(NOT MSVC)
57 export(TARGETS widl nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
58 else()
59 export(TARGETS nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
60 endif()
61
62 else()
63
64 # Do some cleanup
65 file(REMOVE
66 ${REACTOS_BINARY_DIR}/dependencies.graphml
67 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
68 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
69 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
70 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
71 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
72 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
73
74 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
75 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
76 endif()
77
78 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
79 include(${IMPORT_EXECUTABLES})
80
81 # Compiler specific definitions and macros
82 if(MSVC)
83 include(msc.cmake)
84 else()
85 include(gcc.cmake)
86 endif()
87
88 # Generic macros
89 include(CMakeMacros.cmake)
90
91 # IDL macros for widl/midl
92 include(cmake/idl-support.cmake)
93
94 #Some useful variables
95 set(LIVECD_DIR "${REACTOS_BINARY_DIR}/boot/livecd")
96 set(BOOTCD_DIR "${REACTOS_BINARY_DIR}/boot/bootcd")
97
98 # Activate support for assembly source files
99 enable_language(ASM)
100
101 # Activate language support for resource files
102 enable_language(RC)
103
104 if(DBG)
105 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
106 endif()
107
108 if(KDBG)
109 add_definitions(-DKDBG=1)
110 endif()
111
112 if(_WINKD_)
113 add_definitions(-D_WINKD_=1)
114 endif()
115
116 # Version Options
117 add_definitions(-DWINVER=0x502
118 -D_WIN32_IE=0x600
119 -D_WIN32_WINNT=0x502
120 -D_WIN32_WINDOWS=0x502
121 -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__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()