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