[TXTSETUP] Revert an accidental change
[reactos.git] / CMakeLists.txt
1
2 cmake_minimum_required(VERSION 3.2.1)
3 cmake_policy(VERSION 3.2.1)
4
5 if(NOT CMAKE_VERSION MATCHES "ReactOS")
6 message(WARNING "Building with \"${CMAKE_COMMAND}\", which is not the custom CMake included in RosBE, might cause build issues...")
7 endif()
8
9 if(POLICY CMP0058)
10 # Ninja requires custom command byproducts to be explicit
11 cmake_policy(SET CMP0058 OLD)
12 endif()
13
14 if(POLICY CMP0065)
15 # Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property
16 cmake_policy(SET CMP0065 NEW)
17 endif()
18
19 project(REACTOS)
20
21 # Versioning
22 include(sdk/include/reactos/version.cmake)
23
24 set(CMAKE_INCLUDE_CURRENT_DIR ON)
25 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
26 set(CMAKE_SHARED_LIBRARY_PREFIX "")
27 set(CMAKE_SHARED_MODULE_PREFIX "")
28 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
29 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
30 set(CMAKE_COLOR_MAKEFILE OFF)
31 set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
32 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
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(sdk/cmake/config.cmake)
47 elseif(ARCH STREQUAL "amd64")
48 include(sdk/cmake/config-amd64.cmake)
49 elseif(ARCH STREQUAL "arm")
50 include(sdk/cmake/config-arm.cmake)
51 endif()
52
53 # Compiler flags handling
54 include(sdk/cmake/compilerflags.cmake)
55
56 add_definitions(-D__REACTOS__)
57
58 # Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
59 add_definitions(-DREACTOS_SOURCE_DIR="${REACTOS_SOURCE_DIR}")
60 add_definitions(-DREACTOS_BINARY_DIR="${REACTOS_BINARY_DIR}")
61
62 # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
63 file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
64 add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
65
66 if(MSVC_IDE)
67 add_compile_flags("/MP")
68 endif()
69
70 # Bison and Flex support
71 # include(sdk/cmake/bison-flex.cmake)
72
73 if(NOT CMAKE_CROSSCOMPILING)
74 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
75 add_definitions(-DTARGET_${ARCH})
76
77 if(MSVC)
78 if(ARCH STREQUAL "i386")
79 add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
80 elseif(ARCH STREQUAL "amd64")
81 add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
82 endif()
83 if(MSVC_VERSION GREATER 1699)
84 add_definitions(/D_ALLOW_KEYWORD_MACROS)
85 endif()
86 if(NOT USE_CLANG_CL)
87 # FIXME: Inspect
88 add_definitions(/Dinline=__inline)
89 endif()
90 endif()
91
92 include_directories(sdk/include/host)
93
94 if(NOT MSVC)
95 add_subdirectory(dll/win32/dbghelp)
96 endif()
97 add_subdirectory(sdk/tools)
98 add_subdirectory(sdk/lib)
99
100 set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
101 if(NOT MSVC)
102 list(APPEND NATIVE_TARGETS rsym)
103 endif()
104
105 export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
106 configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
107
108 else()
109 # Add host tools target
110 include(sdk/cmake/host-tools.cmake)
111 setup_host_tools()
112
113 # We don't need CMake importlib handling.
114 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
115
116 # Print build type
117 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
118
119 # adjust the default behaviour of the FIND_XXX() commands:
120 # search headers and libraries in the target environment, search
121 # programs in the host environment
122 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
123 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
124 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
125
126 #useful stuff!
127 include(CMakeParseArguments)
128
129 if(DBG)
130 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
131 else()
132 add_definitions(-DDBG=0)
133 endif()
134
135 if(KDBG)
136 add_definitions(-DKDBG)
137 endif()
138
139 if(_WINKD_)
140 add_definitions(-D_WINKD_)
141 endif()
142
143 if(CMAKE_VERSION MATCHES "ReactOS")
144 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
145 else()
146 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
147 endif()
148
149 # Version Options
150 add_definitions(-DWINVER=0x502
151 -D_WIN32_IE=0x600
152 -D_WIN32_WINNT=0x502
153 -D_WIN32_WINDOWS=0x502
154 -D_SETUPAPI_VER=0x502
155 -DMINGW_HAS_SECURE_API=1)
156
157 # Arch Options
158 if(ARCH STREQUAL "i386")
159 if(NOT USE_CLANG_CL)
160 add_definitions(-D_M_IX86)
161 endif()
162 add_definitions(-D_X86_ -D__i386__ -Di386)
163 elseif(ARCH STREQUAL "amd64")
164 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
165 elseif(ARCH STREQUAL "arm")
166 # _M_ARM is already defined by toolchain
167 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
168 if(SARCH STREQUAL "omap-zoom2")
169 add_definitions(-D_ZOOM2_)
170 endif()
171 endif()
172
173 # Other
174 add_definitions(-D_NEW_DELETE_OPERATORS_)
175 if(ARCH STREQUAL "i386")
176 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
177 elseif(ARCH STREQUAL "amd64")
178 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
179 elseif(ARCH STREQUAL "arm")
180 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
181 endif()
182
183 # Activate support for assembly source files
184 enable_language(ASM)
185
186 # Activate language support for resource files
187 enable_language(RC)
188
189 # Localization definitions
190 include(sdk/cmake/localization.cmake)
191 set(I18N_DEFS "")
192 # This will set I18N_DEFS for later use
193 set_i18n_language(${I18N_LANG})
194
195 # Compiler specific definitions and macros
196 if(MSVC)
197 include(sdk/cmake/msvc.cmake)
198 else()
199 include(sdk/cmake/gcc.cmake)
200 endif()
201
202 # Generic macros
203 include(sdk/cmake/CMakeMacros.cmake)
204
205 # IDL macros for widl/midl
206 # We're using widl now for both MSVC and GCC builds
207 include(sdk/cmake/widl-support.cmake)
208
209 include_directories(
210 sdk/include
211 sdk/include/psdk
212 sdk/include/dxsdk
213 ${REACTOS_BINARY_DIR}/sdk/include
214 ${REACTOS_BINARY_DIR}/sdk/include/psdk
215 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
216 ${REACTOS_BINARY_DIR}/sdk/include/ddk
217 ${REACTOS_BINARY_DIR}/sdk/include/reactos
218 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
219 sdk/include/crt
220 sdk/include/ddk
221 sdk/include/ndk
222 sdk/include/reactos
223 sdk/include/reactos/libs)
224
225 if(ARCH STREQUAL "arm")
226 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
227 endif()
228
229 add_dependency_header()
230
231 add_subdirectory(sdk/include/ndk/tests)
232 add_subdirectory(sdk/include/xdk)
233 add_subdirectory(sdk/include/psdk)
234 add_subdirectory(sdk/include/dxsdk)
235 add_subdirectory(sdk/include/reactos/wine)
236 add_subdirectory(sdk/include/reactos/mc)
237 add_subdirectory(sdk/include/asm)
238
239 if(NO_ROSSYM)
240 include(sdk/cmake/baseaddress_dwarf.cmake)
241 elseif(MSVC)
242 include(sdk/cmake/baseaddress_msvc.cmake)
243 else()
244 include(sdk/cmake/baseaddress.cmake)
245 endif()
246
247 # For MSVC builds, this puts all debug symbols file in the same directory.
248 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
249
250 #begin with boot so reactos_cab target is defined before all other modules
251 add_subdirectory(boot)
252 add_subdirectory(base)
253 add_subdirectory(dll)
254 add_subdirectory(drivers)
255 add_subdirectory(hal)
256 add_subdirectory(sdk/lib)
257 add_subdirectory(media)
258 add_subdirectory(modules)
259 add_subdirectory(ntoskrnl)
260 add_subdirectory(subsystems)
261 add_subdirectory(sdk/tools/wpp)
262 add_subdirectory(win32ss)
263
264 # Create the registry hives
265 create_registry_hives()
266
267 # Create {bootcd, livecd, bootcdregtest}.lst
268 create_iso_lists()
269
270 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
271
272 add_dependency_footer()
273 endif()