[PSDK] Update schannel.h. CORE-15682
[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 # Honor CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.
13 cmake_policy(SET CMP0018 OLD)
14
15 if(POLICY CMP0058)
16 # Ninja requires custom command byproducts to be explicit
17 cmake_policy(SET CMP0058 OLD)
18 endif()
19
20 project(REACTOS)
21
22 # Versioning
23 include(sdk/include/reactos/version.cmake)
24
25 set(CMAKE_INCLUDE_CURRENT_DIR ON)
26 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
27 set(CMAKE_SHARED_LIBRARY_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_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
32
33 if(NOT DEFINED NEW_STYLE_BUILD)
34 set(NEW_STYLE_BUILD TRUE)
35 endif()
36
37 if(NOT ARCH)
38 set(ARCH i386)
39 endif()
40 # Now the ARCH variable will be in lowercase.
41 # It is needed because STREQUAL comparison
42 # is case-sensitive.
43 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
44 # for more information.
45 string(TOLOWER ${ARCH} ARCH)
46
47 # Compile options
48 if(ARCH STREQUAL "i386")
49 include(sdk/cmake/config.cmake)
50 elseif(ARCH STREQUAL "amd64")
51 include(sdk/cmake/config-amd64.cmake)
52 elseif(ARCH STREQUAL "arm")
53 include(sdk/cmake/config-arm.cmake)
54 endif()
55
56 # Compiler flags handling
57 include(sdk/cmake/compilerflags.cmake)
58
59 add_definitions(-D__REACTOS__)
60
61 # Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
62 add_definitions(-DREACTOS_SOURCE_DIR="\\\"${REACTOS_SOURCE_DIR}\\\"")
63 add_definitions(-DREACTOS_BINARY_DIR="\\\"${REACTOS_BINARY_DIR}\\\"")
64
65 # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
66 file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
67 add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
68
69 if(MSVC_IDE)
70 add_compile_flags("/MP")
71 endif()
72
73 # Bison and Flex support
74 # include(sdk/cmake/bison-flex.cmake)
75
76 if(NOT CMAKE_CROSSCOMPILING)
77
78 if(NEW_STYLE_BUILD)
79 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
80 endif()
81
82 add_definitions(-DTARGET_${ARCH})
83
84 if(MSVC)
85 if(ARCH STREQUAL "i386")
86 add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
87 elseif(ARCH STREQUAL "amd64")
88 add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
89 endif()
90 if(MSVC_VERSION GREATER 1699)
91 add_definitions(/D_ALLOW_KEYWORD_MACROS)
92 endif()
93 if(NOT USE_CLANG_CL)
94 # FIXME: Inspect
95 add_definitions(/Dinline=__inline)
96 endif()
97 endif()
98
99 include_directories(sdk/include/host)
100
101 if(NOT MSVC)
102 add_subdirectory(dll/win32/dbghelp)
103 endif()
104 add_subdirectory(sdk/tools)
105 add_subdirectory(sdk/lib)
106
107 if(NOT NEW_STYLE_BUILD)
108 if(NOT MSVC)
109 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- )
110 else()
111 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- )
112 endif()
113 endif()
114
115 else()
116 # We don't need CMake importlib handling.
117 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
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()