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