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