2 cmake_minimum_required(VERSION 3.17.0)
4 if(NOT CMAKE_VERSION MATCHES "ReactOS")
5 message(WARNING "Building with \"${CMAKE_COMMAND}\", which is not the custom CMake included in RosBE, might cause build issues...")
11 include(sdk/include/reactos/version.cmake)
13 set(CMAKE_INCLUDE_CURRENT_DIR ON)
14 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
15 set(CMAKE_SHARED_LIBRARY_PREFIX "")
16 set(CMAKE_SHARED_MODULE_PREFIX "")
17 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
18 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
19 set(CMAKE_COLOR_MAKEFILE OFF)
20 set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
21 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
26 # Now the ARCH variable will be in lowercase.
27 # It is needed because STREQUAL comparison
29 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
30 # for more information.
31 string(TOLOWER ${ARCH} ARCH)
34 if(ARCH STREQUAL "i386")
35 include(sdk/cmake/config.cmake)
36 elseif(ARCH STREQUAL "amd64")
37 include(sdk/cmake/config-amd64.cmake)
38 elseif(ARCH STREQUAL "arm")
39 include(sdk/cmake/config-arm.cmake)
42 # Compiler flags handling
43 include(sdk/cmake/compilerflags.cmake)
45 add_definitions(-D__REACTOS__)
47 # Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
48 add_definitions(-DREACTOS_SOURCE_DIR="${REACTOS_SOURCE_DIR}")
49 add_definitions(-DREACTOS_BINARY_DIR="${REACTOS_BINARY_DIR}")
51 # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
52 file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
53 add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
56 add_compile_flags("/MP")
59 # Bison and Flex support
60 # include(sdk/cmake/bison-flex.cmake)
62 if(NOT CMAKE_CROSSCOMPILING)
63 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
64 add_definitions(-DTARGET_${ARCH})
67 if(ARCH STREQUAL "i386")
68 add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
69 elseif(ARCH STREQUAL "amd64")
70 add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
72 if(MSVC_VERSION GREATER 1699)
73 add_definitions(/D_ALLOW_KEYWORD_MACROS)
77 add_definitions(/Dinline=__inline)
80 add_subdirectory(sdk/include/host)
83 add_subdirectory(dll/win32/dbghelp)
85 add_subdirectory(sdk/tools)
86 add_subdirectory(sdk/lib)
88 set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
90 list(APPEND NATIVE_TARGETS rsym pefixup)
93 export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
94 configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
97 # Add host tools target
98 include(sdk/cmake/host-tools.cmake)
101 # We don't need CMake importlib handling.
102 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
105 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
107 # adjust the default behaviour of the FIND_XXX() commands:
108 # search headers and libraries in the target environment, search
109 # programs in the host environment
110 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
111 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
112 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
115 include(CMakeParseArguments)
118 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
120 add_definitions(-DDBG=0)
124 add_definitions(-DKDBG)
128 add_definitions(-D_WINKD_)
132 message(WARNING "-- Disabling precompiled headers support (ccache).")
133 option(PCH "Whether to use precompiled headers" OFF)
134 elseif(CMAKE_VERSION VERSION_LESS 3.16.0)
135 message(WARNING "-- Disabling precompiled headers support due to this unsupported CMake version: ${CMAKE_VERSION}.")
136 option(PCH "Whether to use precompiled headers" OFF)
138 message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.")
139 option(PCH "Whether to use precompiled headers" OFF)
141 option(PCH "Whether to use precompiled headers" ON)
145 add_definitions(-DWINVER=0x502
148 -D_WIN32_WINDOWS=0x502
149 -D_SETUPAPI_VER=0x502
150 -DMINGW_HAS_SECURE_API=1)
153 if(ARCH STREQUAL "i386")
155 add_definitions(-D_M_IX86)
157 add_definitions(-D_X86_ -D__i386__ -Di386)
158 if(SARCH STREQUAL "xbox")
159 add_definitions(-DSARCH_XBOX)
160 elseif(SARCH STREQUAL "pc98")
161 add_definitions(-DSARCH_PC98)
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_)
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)
183 # Activate support for assembly source files
186 # Activate language support for resource files
189 # Localization definitions
190 include(sdk/cmake/localization.cmake)
192 # This will set I18N_DEFS for later use
193 set_i18n_language(${I18N_LANG})
195 # Compiler specific definitions and macros
197 include(sdk/cmake/msvc.cmake)
199 include(sdk/cmake/gcc.cmake)
203 include(sdk/cmake/CMakeMacros.cmake)
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)
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
223 sdk/include/reactos/libs)
225 if(ARCH STREQUAL "arm")
226 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
229 add_dependency_header()
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)
240 include(sdk/cmake/baseaddress_dwarf.cmake)
242 include(sdk/cmake/baseaddress_msvc.cmake)
244 include(sdk/cmake/baseaddress.cmake)
247 # For MSVC builds, this puts all debug symbols file in the same directory.
249 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
251 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols")
254 #begin with boot so reactos_cab target is defined before all other modules
255 add_subdirectory(boot)
256 add_subdirectory(base)
257 add_subdirectory(dll)
258 add_subdirectory(drivers)
259 add_subdirectory(hal)
260 add_subdirectory(sdk/lib)
261 add_subdirectory(media)
262 add_subdirectory(modules)
263 add_subdirectory(ntoskrnl)
264 add_subdirectory(subsystems)
265 add_subdirectory(sdk/tools/wpp)
266 add_subdirectory(win32ss)
268 # Create the registry hives
269 create_registry_hives()
271 # Create {bootcd, livecd, bootcdregtest}.lst
274 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
276 add_dependency_footer()