[ROSAPPS][HOST-TOOLS]:
[reactos.git] / reactos / 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 cat 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 cat 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 # 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(CMAKE_VERSION MATCHES "ReactOS")
141 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
142 else()
143 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
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 if(NO_ROSSYM)
225 include(cmake/baseaddress_dwarf.cmake)
226 else()
227 include(cmake/baseaddress.cmake)
228 endif()
229
230 # For MSVC builds, this puts all debug symbols file in the same directory.
231 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
232
233 #begin with boot so reactos_cab target is defined before all other modules
234 add_subdirectory(boot)
235 add_subdirectory(base)
236 add_subdirectory(dll)
237 add_subdirectory(drivers)
238 add_subdirectory(hal)
239 add_subdirectory(lib)
240 add_subdirectory(media)
241 add_subdirectory(modules)
242 add_subdirectory(ntoskrnl)
243 add_subdirectory(subsystems)
244 add_subdirectory(tools/wpp)
245 add_subdirectory(win32ss)
246
247 # Create {bootcd, livecd, bootcdregtest}.lst
248 create_iso_lists()
249
250 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
251
252 add_dependency_footer()
253 endif()