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