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