[FASTFAT] Properly check for buffer size on dir enumeration.
[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 NEW)
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 if(NOT NEW_STYLE_BUILD)
142 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
143 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
144 endif()
145 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
146 include(${IMPORT_EXECUTABLES})
147 endif()
148
149 if(DBG)
150 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
151 else()
152 add_definitions(-DDBG=0)
153 endif()
154
155 if(KDBG)
156 add_definitions(-DKDBG=1)
157 endif()
158
159 if(_WINKD_)
160 add_definitions(-D_WINKD_=1)
161 endif()
162
163 if(CMAKE_VERSION MATCHES "ReactOS")
164 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
165 else()
166 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
167 endif()
168
169 # Version Options
170 add_definitions(-DWINVER=0x502
171 -D_WIN32_IE=0x600
172 -D_WIN32_WINNT=0x502
173 -D_WIN32_WINDOWS=0x502
174 -D_SETUPAPI_VER=0x502)
175
176 # Arch Options
177 if(ARCH STREQUAL "i386")
178 if(NOT USE_CLANG_CL)
179 add_definitions(-D_M_IX86)
180 endif()
181 add_definitions(-D_X86_ -D__i386__ -Di386)
182 elseif(ARCH STREQUAL "amd64")
183 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
184 elseif(ARCH STREQUAL "arm")
185 # _M_ARM is already defined by toolchain
186 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
187 if(SARCH STREQUAL "omap-zoom2")
188 add_definitions(-D_ZOOM2_)
189 endif()
190 endif()
191
192 # Other
193 if(ARCH STREQUAL "i386")
194 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
195 elseif(ARCH STREQUAL "amd64")
196 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
197 elseif(ARCH STREQUAL "arm")
198 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
199 endif()
200
201 # Activate support for assembly source files
202 enable_language(ASM)
203
204 # Activate language support for resource files
205 enable_language(RC)
206
207 # Localization definitions
208 include(sdk/cmake/localization.cmake)
209 set(I18N_DEFS "")
210 # This will set I18N_DEFS for later use
211 set_i18n_language(${I18N_LANG})
212
213 # Compiler specific definitions and macros
214 if(MSVC)
215 include(sdk/cmake/msvc.cmake)
216 else()
217 include(sdk/cmake/gcc.cmake)
218 endif()
219
220 # Generic macros
221 include(sdk/cmake/CMakeMacros.cmake)
222
223 # IDL macros for widl/midl
224 # We're using widl now for both MSVC and GCC builds
225 include(sdk/cmake/widl-support.cmake)
226
227 include_directories(
228 sdk/include
229 sdk/include/psdk
230 sdk/include/dxsdk
231 ${REACTOS_BINARY_DIR}/sdk/include
232 ${REACTOS_BINARY_DIR}/sdk/include/psdk
233 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
234 ${REACTOS_BINARY_DIR}/sdk/include/ddk
235 ${REACTOS_BINARY_DIR}/sdk/include/reactos
236 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
237 sdk/include/crt
238 sdk/include/ddk
239 sdk/include/ndk
240 sdk/include/reactos
241 sdk/include/reactos/libs)
242
243 if(ARCH STREQUAL "arm")
244 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
245 endif()
246
247 add_dependency_header()
248
249 add_subdirectory(sdk/include/ndk/tests)
250 add_subdirectory(sdk/include/xdk)
251 add_subdirectory(sdk/include/psdk)
252 add_subdirectory(sdk/include/dxsdk)
253 add_subdirectory(sdk/include/reactos/wine)
254 add_subdirectory(sdk/include/reactos/mc)
255 add_subdirectory(sdk/include/asm)
256
257 if(NO_ROSSYM)
258 include(sdk/cmake/baseaddress_dwarf.cmake)
259 elseif(MSVC)
260 include(sdk/cmake/baseaddress_msvc.cmake)
261 else()
262 include(sdk/cmake/baseaddress.cmake)
263 endif()
264
265 # For MSVC builds, this puts all debug symbols file in the same directory.
266 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
267
268 #begin with boot so reactos_cab target is defined before all other modules
269 add_subdirectory(boot)
270 add_subdirectory(base)
271 add_subdirectory(dll)
272 add_subdirectory(drivers)
273 add_subdirectory(hal)
274 add_subdirectory(sdk/lib)
275 add_subdirectory(media)
276 add_subdirectory(modules)
277 add_subdirectory(ntoskrnl)
278 add_subdirectory(subsystems)
279 add_subdirectory(sdk/tools/wpp)
280 add_subdirectory(win32ss)
281
282 # Create the registry hives
283 create_registry_hives()
284
285 # Create {bootcd, livecd, bootcdregtest}.lst
286 create_iso_lists()
287
288 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
289
290 add_dependency_footer()
291 endif()