- Added all HwStor Initialization Required Functions
[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 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(cmake/config.cmake)
57 elseif(ARCH STREQUAL "amd64")
58 include(cmake/config-amd64.cmake)
59 elseif(ARCH STREQUAL "arm")
60 include(cmake/config-arm.cmake)
61 endif()
62
63 # Compiler flags handling
64 include(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(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 else()
98 add_compile_flags("-fshort-wchar -Wno-multichar")
99 endif()
100
101 include_directories(sdk/include/host)
102
103 if(NOT MSVC)
104 add_subdirectory(dll/win32/dbghelp)
105 endif()
106 add_subdirectory(sdk/tools)
107 add_subdirectory(sdk/lib)
108
109 if(NOT NEW_STYLE_BUILD)
110 if(NOT MSVC)
111 export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive obj2bin spec2def geninc rsym mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
112 else()
113 export(TARGETS bin2c widl gendib cabman cdmake fatten hpp mkhive obj2bin spec2def geninc mkshelllink utf16le FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
114 endif()
115 endif()
116
117 else()
118
119 if(NEW_STYLE_BUILD)
120 include(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 # Do some cleanup
137 file(REMOVE
138 ${REACTOS_BINARY_DIR}/dependencies.graphml
139 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
140 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
141 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
142 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
143 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
144 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
145
146 if(NOT NEW_STYLE_BUILD)
147 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
148 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
149 endif()
150 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
151 include(${IMPORT_EXECUTABLES})
152 endif()
153
154 if(DBG)
155 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
156 else()
157 add_definitions(-DDBG=0)
158 endif()
159
160 if(KDBG)
161 add_definitions(-DKDBG=1)
162 endif()
163
164 if(_WINKD_)
165 add_definitions(-D_WINKD_=1)
166 endif()
167
168 if(CMAKE_VERSION MATCHES "ReactOS")
169 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
170 else()
171 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
172 endif()
173
174 # Version Options
175 add_definitions(-DWINVER=0x502
176 -D_WIN32_IE=0x600
177 -D_WIN32_WINNT=0x502
178 -D_WIN32_WINDOWS=0x502
179 -D_SETUPAPI_VER=0x502)
180
181 # Arch Options
182 if(ARCH STREQUAL "i386")
183 add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
184 elseif(ARCH STREQUAL "amd64")
185 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
186 elseif(ARCH STREQUAL "arm")
187 # _M_ARM is already defined by toolchain
188 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
189 if(SARCH STREQUAL "omap-zoom2")
190 add_definitions(-D_ZOOM2_)
191 endif()
192 endif()
193
194 # Other
195 if(ARCH STREQUAL "i386")
196 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
197 elseif(ARCH STREQUAL "amd64")
198 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
199 elseif(ARCH STREQUAL "arm")
200 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
201 endif()
202
203 # Activate support for assembly source files
204 enable_language(ASM)
205
206 # Activate language support for resource files
207 enable_language(RC)
208
209 # Localization definitions
210 include(cmake/localization.cmake)
211 set(I18N_DEFS "")
212 # This will set I18N_DEFS for later use
213 set_i18n_language(${I18N_LANG})
214
215 # Compiler specific definitions and macros
216 if(MSVC)
217 include(cmake/msvc.cmake)
218 else()
219 include(cmake/gcc.cmake)
220 endif()
221
222 # Generic macros
223 include(cmake/CMakeMacros.cmake)
224
225 # IDL macros for widl/midl
226 # We're using widl now for both MSVC and GCC builds
227 include(cmake/widl-support.cmake)
228
229 include_directories(
230 sdk/include
231 sdk/include/psdk
232 sdk/include/dxsdk
233 ${REACTOS_BINARY_DIR}/sdk/include
234 ${REACTOS_BINARY_DIR}/sdk/include/psdk
235 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
236 ${REACTOS_BINARY_DIR}/sdk/include/ddk
237 ${REACTOS_BINARY_DIR}/sdk/include/reactos
238 sdk/include/crt
239 sdk/include/ddk
240 sdk/include/ndk
241 sdk/include/reactos
242 sdk/include/reactos/libs)
243
244 if(ARCH STREQUAL "arm")
245 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
246 endif()
247
248 add_dependency_header()
249
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(cmake/baseaddress_dwarf.cmake)
259 elseif(MSVC)
260 include(cmake/baseaddress_msvc.cmake)
261 else()
262 include(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()