[CMAKE]
[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(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 CMAKE_VERSION STREQUAL "2.8.12.1-ReactOS")
41 set(CMAKE_DISABLE_NINJA_DEPSLOG TRUE)
42 endif()
43
44 if(NOT DEFINED NEW_STYLE_BUILD)
45 set(NEW_STYLE_BUILD FALSE)
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(cmake/config.cmake)
61 elseif(ARCH STREQUAL "amd64")
62 include(cmake/config-amd64.cmake)
63 elseif(ARCH STREQUAL "arm")
64 include(cmake/config-arm.cmake)
65 endif()
66
67 # Compiler flags handling
68 include(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(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 add_definitions(/Dinline=__inline)
101 else()
102 add_compile_flags("-fshort-wchar -Wno-multichar")
103 endif()
104
105 include_directories(include/host)
106
107 if(NOT MSVC)
108 add_subdirectory(dll/win32/dbghelp)
109 endif()
110 add_subdirectory(tools)
111 add_subdirectory(lib)
112
113 if(NOT NEW_STYLE_BUILD)
114 if(NOT MSVC)
115 export(TARGETS bin2c widl gendib cabman cdmake hpp mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
116 else()
117 export(TARGETS bin2c widl gendib cabman cdmake hpp mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
118 endif()
119 endif()
120
121 else()
122
123 if(NEW_STYLE_BUILD)
124 include(cmake/host-tools.cmake)
125 endif()
126
127 # adjust the default behaviour of the FIND_XXX() commands:
128 # search headers and libraries in the target environment, search
129 # programs in the host environment
130 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
131 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
132 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
133
134 #useful stuff!
135 include(CMakeParseArguments)
136
137 # Do some cleanup
138 file(REMOVE
139 ${REACTOS_BINARY_DIR}/dependencies.graphml
140 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
141 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
142 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
143 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
144 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
145 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
146
147 if(NOT NEW_STYLE_BUILD)
148 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
149 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
150 endif()
151 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
152 include(${IMPORT_EXECUTABLES})
153 endif()
154
155 if(DBG)
156 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
157 else()
158 add_definitions(-DDBG=0)
159 endif()
160
161 if(KDBG)
162 add_definitions(-DKDBG=1)
163 endif()
164
165 if(_WINKD_)
166 add_definitions(-D_WINKD_=1)
167 endif()
168
169 if(CMAKE_VERSION MATCHES "ReactOS")
170 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
171 else()
172 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
173 endif()
174
175 # Version Options
176 add_definitions(-DWINVER=0x502
177 -D_WIN32_IE=0x600
178 -D_WIN32_WINNT=0x502
179 -D_WIN32_WINDOWS=0x502
180 -D_SETUPAPI_VER=0x502)
181
182 # Arch Options
183 if(ARCH STREQUAL "i386")
184 add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
185 elseif(ARCH STREQUAL "amd64")
186 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
187 elseif(ARCH STREQUAL "arm")
188 # _M_ARM is already defined by toolchain
189 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
190 if(SARCH STREQUAL "omap-zoom2")
191 add_definitions(-D_ZOOM2_)
192 endif()
193 endif()
194
195 # Other
196 if(ARCH STREQUAL "i386")
197 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
198 elseif(ARCH STREQUAL "amd64")
199 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
200 elseif(ARCH STREQUAL "arm")
201 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
202 endif()
203
204 # Activate support for assembly source files
205 enable_language(ASM)
206
207 # Activate language support for resource files
208 enable_language(RC)
209
210 # Localization definitions
211 include(cmake/localization.cmake)
212 set(I18N_DEFS "")
213 # This will set I18N_DEFS for later use
214 set_i18n_language(${I18N_LANG})
215
216 # Compiler specific definitions and macros
217 if(MSVC)
218 include(cmake/msvc.cmake)
219 else()
220 include(cmake/gcc.cmake)
221 endif()
222
223 # Generic macros
224 include(cmake/CMakeMacros.cmake)
225
226 # IDL macros for widl/midl
227 # We're using widl now for both MSVC and GCC builds
228 include(cmake/widl-support.cmake)
229
230 include_directories(
231 include
232 include/psdk
233 include/dxsdk
234 ${REACTOS_BINARY_DIR}/include
235 ${REACTOS_BINARY_DIR}/include/psdk
236 ${REACTOS_BINARY_DIR}/include/dxsdk
237 ${REACTOS_BINARY_DIR}/include/ddk
238 ${REACTOS_BINARY_DIR}/include/reactos
239 include/crt
240 include/ddk
241 include/ndk
242 include/reactos
243 include/reactos/libs)
244
245 if(ARCH STREQUAL "arm")
246 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
247 endif()
248
249 add_dependency_header()
250
251 add_subdirectory(include/xdk)
252 add_subdirectory(include/psdk)
253 add_subdirectory(include/dxsdk)
254 add_subdirectory(include/reactos/wine)
255 add_subdirectory(include/reactos/mc)
256 add_subdirectory(include/asm)
257
258 if(NO_ROSSYM)
259 include(cmake/baseaddress_dwarf.cmake)
260 elseif(MSVC)
261 include(cmake/baseaddress_msvc.cmake)
262 else()
263 include(cmake/baseaddress.cmake)
264 endif()
265
266 # For MSVC builds, this puts all debug symbols file in the same directory.
267 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
268
269 #begin with boot so reactos_cab target is defined before all other modules
270 add_subdirectory(boot)
271 add_subdirectory(base)
272 add_subdirectory(dll)
273 add_subdirectory(drivers)
274 add_subdirectory(hal)
275 add_subdirectory(lib)
276 add_subdirectory(media)
277 add_subdirectory(modules)
278 add_subdirectory(ntoskrnl)
279 add_subdirectory(subsystems)
280 add_subdirectory(tools/wpp)
281 add_subdirectory(win32ss)
282
283 # Create the registry hives
284 create_registry_hives()
285
286 # Create {bootcd, livecd, bootcdregtest}.lst
287 create_iso_lists()
288
289 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
290
291 add_dependency_footer()
292 endif()