[USBPORT] Moving array CMASKS[] to start file.
[reactos.git] / CMakeLists.txt
1
2 cmake_minimum_required(VERSION 2.8.12)
3
4 if(POLICY CMP0017)
5 # Shadow cmake provided modules
6 cmake_policy(SET CMP0017 OLD)
7 endif()
8
9 if(POLICY CMP0026)
10 # Allow use of the LOCATION property
11 cmake_policy(SET CMP0026 OLD)
12 endif()
13
14 if(POLICY CMP0051)
15 # List TARGET_OBJECTS in SOURCES target property
16 cmake_policy(SET CMP0051 NEW)
17 endif()
18
19 if(POLICY CMP0058)
20 # Ninja requires custom command byproducts to be explicit
21 cmake_policy(SET CMP0058 OLD)
22 endif()
23
24 project(REACTOS)
25
26 # Versioning
27 include(sdk/include/reactos/version.cmake)
28
29 # Don't escape preprocessor definition values added via add_definitions
30 cmake_policy(SET CMP0005 OLD)
31 cmake_policy(SET CMP0002 NEW)
32 if(POLICY CMP0018)
33 cmake_policy(SET CMP0018 OLD)
34 endif()
35
36 set(CMAKE_INCLUDE_CURRENT_DIR ON)
37 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
38 set(CMAKE_SHARED_LIBRARY_PREFIX "")
39 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
40 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
41 set(CMAKE_COLOR_MAKEFILE OFF)
42 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
43
44 if(NOT DEFINED NEW_STYLE_BUILD)
45 set(NEW_STYLE_BUILD TRUE)
46 endif()
47
48 if(NOT ARCH)
49 set(ARCH i386)
50 endif()
51 # Now the ARCH variable will be in lowercase.
52 # It is needed because STREQUAL comparison
53 # is case-sensitive.
54 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
55 # for more information.
56 string(TOLOWER ${ARCH} ARCH)
57
58 # Compile options
59 if(ARCH STREQUAL "i386")
60 include(sdk/cmake/config.cmake)
61 elseif(ARCH STREQUAL "amd64")
62 include(sdk/cmake/config-amd64.cmake)
63 elseif(ARCH STREQUAL "arm")
64 include(sdk/cmake/config-arm.cmake)
65 endif()
66
67 # Compiler flags handling
68 include(sdk/cmake/compilerflags.cmake)
69
70 add_definitions(-D__REACTOS__)
71
72 if(MSVC_IDE)
73 add_compile_flags("/MP")
74 endif()
75
76 # We don't need CMake importlib handling.
77 # FIXME: Remove the MSVC_IDE condition when the upcoming RosBE lands.
78 if(NOT MSVC_IDE)
79 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
80 endif()
81
82 # Bison and Flex support
83 # include(sdk/cmake/bison-flex.cmake)
84
85 if(NOT CMAKE_CROSSCOMPILING)
86
87 if(NEW_STYLE_BUILD)
88 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
89 endif()
90
91 add_definitions(-DTARGET_${ARCH})
92
93 if(MSVC)
94 if(ARCH STREQUAL "i386")
95 add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
96 endif()
97 if(MSVC_VERSION GREATER 1699)
98 add_definitions(/D_ALLOW_KEYWORD_MACROS)
99 endif()
100 if(NOT USE_CLANG_CL)
101 # FIXME: Inspect
102 add_definitions(/Dinline=__inline)
103 endif()
104 endif()
105
106 include_directories(sdk/include/host)
107
108 if(NOT MSVC)
109 add_subdirectory(dll/win32/dbghelp)
110 endif()
111 add_subdirectory(sdk/tools)
112 add_subdirectory(sdk/lib)
113
114 if(NOT NEW_STYLE_BUILD)
115 if(NOT MSVC)
116 export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
117 else()
118 export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
119 endif()
120 endif()
121
122 else()
123
124 if(NEW_STYLE_BUILD)
125 include(sdk/cmake/host-tools.cmake)
126 endif()
127
128 # Print build type
129 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
130
131 # adjust the default behaviour of the FIND_XXX() commands:
132 # search headers and libraries in the target environment, search
133 # programs in the host environment
134 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
135 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
136 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
137
138 #useful stuff!
139 include(CMakeParseArguments)
140
141 # Do some cleanup
142 file(REMOVE
143 ${REACTOS_BINARY_DIR}/dependencies.graphml
144 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
145 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
146 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
147 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
148 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
149 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
150
151 if(NOT NEW_STYLE_BUILD)
152 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
153 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
154 endif()
155 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
156 include(${IMPORT_EXECUTABLES})
157 endif()
158
159 if(DBG)
160 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
161 else()
162 add_definitions(-DDBG=0)
163 endif()
164
165 if(KDBG)
166 add_definitions(-DKDBG=1)
167 endif()
168
169 if(_WINKD_)
170 add_definitions(-D_WINKD_=1)
171 endif()
172
173 if(CMAKE_VERSION MATCHES "ReactOS")
174 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
175 else()
176 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
177 endif()
178
179 # Version Options
180 add_definitions(-DWINVER=0x502
181 -D_WIN32_IE=0x600
182 -D_WIN32_WINNT=0x502
183 -D_WIN32_WINDOWS=0x502
184 -D_SETUPAPI_VER=0x502)
185
186 # Arch Options
187 if(ARCH STREQUAL "i386")
188 if(NOT USE_CLANG_CL)
189 add_definitions(-D_M_IX86)
190 endif()
191 add_definitions(-D_X86_ -D__i386__ -Di386)
192 elseif(ARCH STREQUAL "amd64")
193 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
194 elseif(ARCH STREQUAL "arm")
195 # _M_ARM is already defined by toolchain
196 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
197 if(SARCH STREQUAL "omap-zoom2")
198 add_definitions(-D_ZOOM2_)
199 endif()
200 endif()
201
202 # Other
203 if(ARCH STREQUAL "i386")
204 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
205 elseif(ARCH STREQUAL "amd64")
206 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
207 elseif(ARCH STREQUAL "arm")
208 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
209 endif()
210
211 # Activate support for assembly source files
212 enable_language(ASM)
213
214 # Activate language support for resource files
215 enable_language(RC)
216
217 # Localization definitions
218 include(sdk/cmake/localization.cmake)
219 set(I18N_DEFS "")
220 # This will set I18N_DEFS for later use
221 set_i18n_language(${I18N_LANG})
222
223 # Compiler specific definitions and macros
224 if(MSVC)
225 include(sdk/cmake/msvc.cmake)
226 else()
227 include(sdk/cmake/gcc.cmake)
228 endif()
229
230 # Generic macros
231 include(sdk/cmake/CMakeMacros.cmake)
232
233 # IDL macros for widl/midl
234 # We're using widl now for both MSVC and GCC builds
235 include(sdk/cmake/widl-support.cmake)
236
237 include_directories(
238 sdk/include
239 sdk/include/psdk
240 sdk/include/dxsdk
241 ${REACTOS_BINARY_DIR}/sdk/include
242 ${REACTOS_BINARY_DIR}/sdk/include/psdk
243 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
244 ${REACTOS_BINARY_DIR}/sdk/include/ddk
245 ${REACTOS_BINARY_DIR}/sdk/include/reactos
246 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
247 sdk/include/crt
248 sdk/include/ddk
249 sdk/include/ndk
250 sdk/include/reactos
251 sdk/include/reactos/libs)
252
253 if(ARCH STREQUAL "arm")
254 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
255 endif()
256
257 add_dependency_header()
258
259 add_subdirectory(sdk/include/ndk/tests)
260 add_subdirectory(sdk/include/xdk)
261 add_subdirectory(sdk/include/psdk)
262 add_subdirectory(sdk/include/dxsdk)
263 add_subdirectory(sdk/include/reactos/wine)
264 add_subdirectory(sdk/include/reactos/mc)
265 add_subdirectory(sdk/include/asm)
266
267 if(NO_ROSSYM)
268 include(sdk/cmake/baseaddress_dwarf.cmake)
269 elseif(MSVC)
270 include(sdk/cmake/baseaddress_msvc.cmake)
271 else()
272 include(sdk/cmake/baseaddress.cmake)
273 endif()
274
275 # For MSVC builds, this puts all debug symbols file in the same directory.
276 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
277
278 #begin with boot so reactos_cab target is defined before all other modules
279 add_subdirectory(boot)
280 add_subdirectory(base)
281 add_subdirectory(dll)
282 add_subdirectory(drivers)
283 add_subdirectory(hal)
284 add_subdirectory(sdk/lib)
285 add_subdirectory(media)
286 add_subdirectory(modules)
287 add_subdirectory(ntoskrnl)
288 add_subdirectory(subsystems)
289 add_subdirectory(sdk/tools/wpp)
290 add_subdirectory(win32ss)
291
292 # Create the registry hives
293 create_registry_hives()
294
295 # Create {bootcd, livecd, bootcdregtest}.lst
296 create_iso_lists()
297
298 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
299
300 add_dependency_footer()
301 endif()