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