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