[CMD]: Documentation improvement: we actually support two types of filename completio...
[reactos.git] / reactos / 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 project(REACTOS)
20
21 # Versioning
22 include(sdk/include/reactos/version.cmake)
23
24 # Don't escape preprocessor definition values added via add_definitions
25 cmake_policy(SET CMP0005 OLD)
26 cmake_policy(SET CMP0002 NEW)
27 if(POLICY CMP0018)
28 cmake_policy(SET CMP0018 OLD)
29 endif()
30
31 set(CMAKE_INCLUDE_CURRENT_DIR ON)
32 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
33 set(CMAKE_SHARED_LIBRARY_PREFIX "")
34 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
35 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
36 set(CMAKE_COLOR_MAKEFILE OFF)
37 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
38 set(CMAKE_SKIP_INSTALL_RULES ON)
39
40 if(NOT DEFINED NEW_STYLE_BUILD)
41 set(NEW_STYLE_BUILD TRUE)
42 endif()
43
44 if(NOT ARCH)
45 set(ARCH i386)
46 endif()
47 # Now the ARCH variable will be in lowercase.
48 # It is needed because STREQUAL comparison
49 # is case-sensitive.
50 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
51 # for more information.
52 string(TOLOWER ${ARCH} ARCH)
53
54 # Compile options
55 if(ARCH STREQUAL "i386")
56 include(sdk/cmake/config.cmake)
57 elseif(ARCH STREQUAL "amd64")
58 include(sdk/cmake/config-amd64.cmake)
59 elseif(ARCH STREQUAL "arm")
60 include(sdk/cmake/config-arm.cmake)
61 endif()
62
63 # Compiler flags handling
64 include(sdk/cmake/compilerflags.cmake)
65
66 add_definitions(-D__REACTOS__)
67
68 if(MSVC_IDE)
69 add_compile_flags("/MP")
70 endif()
71
72 # We don't need CMake importlib handling.
73 # FIXME: Remove the MSVC_IDE condition when the upcoming RosBE lands.
74 if(NOT MSVC_IDE)
75 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
76 endif()
77
78 # Bison and Flex support
79 # include(sdk/cmake/bison-flex.cmake)
80
81 if(NOT CMAKE_CROSSCOMPILING)
82
83 if(NEW_STYLE_BUILD)
84 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
85 endif()
86
87 add_definitions(-DTARGET_${ARCH})
88
89 if(MSVC)
90 if(ARCH STREQUAL "i386")
91 add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
92 endif()
93 if(MSVC_VERSION GREATER 1699)
94 add_definitions(/D_ALLOW_KEYWORD_MACROS)
95 endif()
96 add_definitions(/Dinline=__inline)
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 cdmake fatten hpp mkhive obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
110 else()
111 export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
112 endif()
113 endif()
114
115 else()
116
117 if(NEW_STYLE_BUILD)
118 include(sdk/cmake/host-tools.cmake)
119 endif()
120
121 # Print build type
122 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
123
124 # adjust the default behaviour of the FIND_XXX() commands:
125 # search headers and libraries in the target environment, search
126 # programs in the host environment
127 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
128 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
129 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
130
131 #useful stuff!
132 include(CMakeParseArguments)
133
134 # Do some cleanup
135 file(REMOVE
136 ${REACTOS_BINARY_DIR}/dependencies.graphml
137 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
138 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
139 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
140 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
141 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
142 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
143
144 if(NOT NEW_STYLE_BUILD)
145 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
146 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
147 endif()
148 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
149 include(${IMPORT_EXECUTABLES})
150 endif()
151
152 if(DBG)
153 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
154 else()
155 add_definitions(-DDBG=0)
156 endif()
157
158 if(KDBG)
159 add_definitions(-DKDBG=1)
160 endif()
161
162 if(_WINKD_)
163 add_definitions(-D_WINKD_=1)
164 endif()
165
166 if(CMAKE_VERSION MATCHES "ReactOS")
167 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
168 else()
169 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
170 endif()
171
172 # Version Options
173 add_definitions(-DWINVER=0x502
174 -D_WIN32_IE=0x600
175 -D_WIN32_WINNT=0x502
176 -D_WIN32_WINDOWS=0x502
177 -D_SETUPAPI_VER=0x502)
178
179 # Arch Options
180 if(ARCH STREQUAL "i386")
181 add_definitions(-D_M_IX86 -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/xdk)
250 add_subdirectory(sdk/include/psdk)
251 add_subdirectory(sdk/include/dxsdk)
252 add_subdirectory(sdk/include/reactos/wine)
253 add_subdirectory(sdk/include/reactos/mc)
254 add_subdirectory(sdk/include/asm)
255
256 if(NO_ROSSYM)
257 include(sdk/cmake/baseaddress_dwarf.cmake)
258 elseif(MSVC)
259 include(sdk/cmake/baseaddress_msvc.cmake)
260 else()
261 include(sdk/cmake/baseaddress.cmake)
262 endif()
263
264 # For MSVC builds, this puts all debug symbols file in the same directory.
265 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
266
267 #begin with boot so reactos_cab target is defined before all other modules
268 add_subdirectory(boot)
269 add_subdirectory(base)
270 add_subdirectory(dll)
271 add_subdirectory(drivers)
272 add_subdirectory(hal)
273 add_subdirectory(sdk/lib)
274 add_subdirectory(media)
275 add_subdirectory(modules)
276 add_subdirectory(ntoskrnl)
277 add_subdirectory(subsystems)
278 add_subdirectory(sdk/tools/wpp)
279 add_subdirectory(win32ss)
280
281 # Create the registry hives
282 create_registry_hives()
283
284 # Create {bootcd, livecd, bootcdregtest}.lst
285 create_iso_lists()
286
287 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
288
289 add_dependency_footer()
290 endif()