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