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