[SDK]
[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 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 set(CMAKE_SKIP_INSTALL_RULES ON)
44
45 if(NOT DEFINED USE_MKISOFS)
46 set(USE_MKISOFS TRUE)
47 endif()
48
49 if(NOT DEFINED NEW_STYLE_BUILD)
50 set(NEW_STYLE_BUILD TRUE)
51 endif()
52
53 if(NOT ARCH)
54 set(ARCH i386)
55 endif()
56 # Now the ARCH variable will be in lowercase.
57 # It is needed because STREQUAL comparison
58 # is case-sensitive.
59 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
60 # for more information.
61 string(TOLOWER ${ARCH} ARCH)
62
63 # Compile options
64 if(ARCH STREQUAL "i386")
65 include(sdk/cmake/config.cmake)
66 elseif(ARCH STREQUAL "amd64")
67 include(sdk/cmake/config-amd64.cmake)
68 elseif(ARCH STREQUAL "arm")
69 include(sdk/cmake/config-arm.cmake)
70 endif()
71
72 # Compiler flags handling
73 include(sdk/cmake/compilerflags.cmake)
74
75 add_definitions(-D__REACTOS__)
76
77 if(MSVC_IDE)
78 add_compile_flags("/MP")
79 endif()
80
81 # We don't need CMake importlib handling.
82 # FIXME: Remove the MSVC_IDE condition when the upcoming RosBE lands.
83 if(NOT MSVC_IDE)
84 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
85 endif()
86
87 # Bison and Flex support
88 # include(sdk/cmake/bison-flex.cmake)
89
90 if(NOT CMAKE_CROSSCOMPILING)
91
92 if(NEW_STYLE_BUILD)
93 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
94 endif()
95
96 add_definitions(-DTARGET_${ARCH})
97
98 if(MSVC)
99 if(ARCH STREQUAL "i386")
100 add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
101 endif()
102 if(MSVC_VERSION GREATER 1699)
103 add_definitions(/D_ALLOW_KEYWORD_MACROS)
104 endif()
105 add_definitions(/Dinline=__inline)
106 endif()
107
108 include_directories(sdk/include/host)
109
110 if(NOT MSVC)
111 add_subdirectory(dll/win32/dbghelp)
112 endif()
113 add_subdirectory(sdk/tools)
114 add_subdirectory(sdk/lib)
115
116 if(NOT NEW_STYLE_BUILD)
117 if(NOT MSVC)
118 export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
119 else()
120 export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
121 endif()
122 endif()
123
124 else()
125
126 if(NEW_STYLE_BUILD)
127 include(sdk/cmake/host-tools.cmake)
128 endif()
129
130 # Print build type
131 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
132
133 # adjust the default behaviour of the FIND_XXX() commands:
134 # search headers and libraries in the target environment, search
135 # programs in the host environment
136 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
137 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
138 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
139
140 #useful stuff!
141 include(CMakeParseArguments)
142
143 # Do some cleanup
144 file(REMOVE
145 ${REACTOS_BINARY_DIR}/dependencies.graphml
146 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
147 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
148 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
149 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
150 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
151 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
152
153 if(NOT NEW_STYLE_BUILD)
154 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
155 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
156 endif()
157 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
158 include(${IMPORT_EXECUTABLES})
159 endif()
160
161 if(DBG)
162 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
163 else()
164 add_definitions(-DDBG=0)
165 endif()
166
167 if(KDBG)
168 add_definitions(-DKDBG=1)
169 endif()
170
171 if(_WINKD_)
172 add_definitions(-D_WINKD_=1)
173 endif()
174
175 if(CMAKE_VERSION MATCHES "ReactOS")
176 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
177 else()
178 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
179 endif()
180
181 # Version Options
182 add_definitions(-DWINVER=0x502
183 -D_WIN32_IE=0x600
184 -D_WIN32_WINNT=0x502
185 -D_WIN32_WINDOWS=0x502
186 -D_SETUPAPI_VER=0x502)
187
188 # Arch Options
189 if(ARCH STREQUAL "i386")
190 add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
191 elseif(ARCH STREQUAL "amd64")
192 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
193 elseif(ARCH STREQUAL "arm")
194 # _M_ARM is already defined by toolchain
195 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
196 if(SARCH STREQUAL "omap-zoom2")
197 add_definitions(-D_ZOOM2_)
198 endif()
199 endif()
200
201 # Other
202 if(ARCH STREQUAL "i386")
203 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
204 elseif(ARCH STREQUAL "amd64")
205 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
206 elseif(ARCH STREQUAL "arm")
207 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
208 endif()
209
210 # Activate support for assembly source files
211 enable_language(ASM)
212
213 # Activate language support for resource files
214 enable_language(RC)
215
216 # Localization definitions
217 include(sdk/cmake/localization.cmake)
218 set(I18N_DEFS "")
219 # This will set I18N_DEFS for later use
220 set_i18n_language(${I18N_LANG})
221
222 # Compiler specific definitions and macros
223 if(MSVC)
224 include(sdk/cmake/msvc.cmake)
225 else()
226 include(sdk/cmake/gcc.cmake)
227 endif()
228
229 # Generic macros
230 include(sdk/cmake/CMakeMacros.cmake)
231
232 # IDL macros for widl/midl
233 # We're using widl now for both MSVC and GCC builds
234 include(sdk/cmake/widl-support.cmake)
235
236 include_directories(
237 sdk/include
238 sdk/include/psdk
239 sdk/include/dxsdk
240 ${REACTOS_BINARY_DIR}/sdk/include
241 ${REACTOS_BINARY_DIR}/sdk/include/psdk
242 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
243 ${REACTOS_BINARY_DIR}/sdk/include/ddk
244 ${REACTOS_BINARY_DIR}/sdk/include/reactos
245 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
246 sdk/include/crt
247 sdk/include/ddk
248 sdk/include/ndk
249 sdk/include/reactos
250 sdk/include/reactos/libs)
251
252 if(ARCH STREQUAL "arm")
253 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
254 endif()
255
256 add_dependency_header()
257
258 add_subdirectory(sdk/include/xdk)
259 add_subdirectory(sdk/include/psdk)
260 add_subdirectory(sdk/include/dxsdk)
261 add_subdirectory(sdk/include/reactos/wine)
262 add_subdirectory(sdk/include/reactos/mc)
263 add_subdirectory(sdk/include/asm)
264
265 if(NO_ROSSYM)
266 include(sdk/cmake/baseaddress_dwarf.cmake)
267 elseif(MSVC)
268 include(sdk/cmake/baseaddress_msvc.cmake)
269 else()
270 include(sdk/cmake/baseaddress.cmake)
271 endif()
272
273 # For MSVC builds, this puts all debug symbols file in the same directory.
274 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
275
276 #begin with boot so reactos_cab target is defined before all other modules
277 add_subdirectory(boot)
278 add_subdirectory(base)
279 add_subdirectory(dll)
280 add_subdirectory(drivers)
281 add_subdirectory(hal)
282 add_subdirectory(sdk/lib)
283 add_subdirectory(media)
284 add_subdirectory(modules)
285 add_subdirectory(ntoskrnl)
286 add_subdirectory(subsystems)
287 add_subdirectory(sdk/tools/wpp)
288 add_subdirectory(win32ss)
289
290 # Create the registry hives
291 create_registry_hives()
292
293 # Create {bootcd, livecd, bootcdregtest}.lst
294 create_iso_lists()
295
296 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
297
298 add_dependency_footer()
299 endif()