[PSEH3]
[reactos.git] / reactos / 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 widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
73 else()
74 export(TARGETS 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 # Do some cleanup
95 file(REMOVE
96 ${REACTOS_BINARY_DIR}/dependencies.graphml
97 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
98 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
99 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
100 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
101 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
102 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
103
104 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
105 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
106 endif()
107
108 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
109 include(${IMPORT_EXECUTABLES})
110
111 if(DBG)
112 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
113 else()
114 add_definitions(-DDBG=0)
115 endif()
116
117 if(KDBG)
118 add_definitions(-DKDBG=1)
119 endif()
120
121 if(_WINKD_)
122 add_definitions(-D_WINKD_=1)
123 endif()
124
125 if(USE_PSEH3)
126 add_definitions(-D_USE_PSEH3=1)
127 endif()
128
129 # Version Options
130 add_definitions(-DWINVER=0x502
131 -D_WIN32_IE=0x600
132 -D_WIN32_WINNT=0x502
133 -D_WIN32_WINDOWS=0x502
134 -D_SETUPAPI_VER=0x502)
135
136 # Arch Options
137 if(ARCH STREQUAL "i386")
138 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
139 elseif(ARCH STREQUAL "amd64")
140 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
141 elseif(ARCH STREQUAL "arm")
142 # _M_ARM is already defined by toolchain
143 add_definitions(-D_ARM_ -D__arm__)
144 endif()
145
146 # Other
147 if(ARCH STREQUAL "i386")
148 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
149 elseif(ARCH STREQUAL "amd64")
150 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
151 elseif(ARCH STREQUAL "arm")
152 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
153 endif()
154
155 # Activate support for assembly source files
156 enable_language(ASM)
157
158 # Activate language support for resource files
159 enable_language(RC)
160
161 # Localization definitions
162 include(cmake/localization.cmake)
163 set(I18N_DEFS "")
164 # This will set I18N_DEFS for later use
165 set_i18n_language(${I18N_LANG})
166
167 # Compiler specific definitions and macros
168 if(MSVC)
169 include(cmake/msvc.cmake)
170 else()
171 include(cmake/gcc.cmake)
172 endif()
173
174 # Generic macros
175 include(cmake/CMakeMacros.cmake)
176
177 # IDL macros for widl/midl
178 # We're using widl now for both MSVC and GCC builds
179 include(cmake/widl-support.cmake)
180
181 if(MSVC AND USE_WDK_HEADERS)
182 include_directories(
183 include
184 $ENV{SDK_INC_PATH}
185 include/dxsdk
186 ${REACTOS_BINARY_DIR}/include
187 ${REACTOS_BINARY_DIR}/include/dxsdk
188 ${REACTOS_BINARY_DIR}/include/psdk
189 ${REACTOS_BINARY_DIR}/include/reactos
190 $ENV{CRT_INC_PATH}
191 $ENV{DDK_INC_PATH}
192 include/ndk
193 include/reactos
194 include/reactos/libs)
195 else()
196 include_directories(
197 include
198 include/psdk
199 include/dxsdk
200 ${REACTOS_BINARY_DIR}/include
201 ${REACTOS_BINARY_DIR}/include/dxsdk
202 ${REACTOS_BINARY_DIR}/include/psdk
203 ${REACTOS_BINARY_DIR}/include/reactos
204 include/crt
205 include/ddk
206 include/ndk
207 include/reactos
208 include/reactos/libs)
209 endif()
210
211
212 if(ARCH STREQUAL "arm")
213 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
214 endif()
215
216 if(MSVC)
217 include_directories(include/crt/msc)
218 else()
219 include_directories(include/crt/mingw32)
220 endif()
221
222 add_dependency_header()
223
224 add_subdirectory(include/psdk)
225 add_subdirectory(include/dxsdk)
226 add_subdirectory(include/reactos/wine)
227 add_subdirectory(include/reactos/mc)
228 add_subdirectory(include/asm)
229
230 include(cmake/baseaddress.cmake)
231
232 #begin with boot so reactos_cab target is defined before all other modules
233 add_subdirectory(boot)
234 add_subdirectory(base)
235 add_subdirectory(dll)
236 add_subdirectory(drivers)
237 add_subdirectory(hal)
238 add_subdirectory(lib)
239 add_subdirectory(media)
240 add_subdirectory(modules)
241 add_subdirectory(ntoskrnl)
242 add_subdirectory(subsystems)
243 add_subdirectory(win32ss)
244
245 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
246
247 add_dependency_footer()
248 endif()