2 cmake_minimum_required(VERSION 3.2.1)
3 cmake_policy(VERSION 3.2.1)
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...")
10 # Ninja requires custom command byproducts to be explicit
11 cmake_policy(SET CMP0058 NEW)
15 # Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property
16 cmake_policy(SET CMP0065 NEW)
22 include(sdk/include/reactos/version.cmake)
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)
37 # Now the ARCH variable will be in lowercase.
38 # It is needed because STREQUAL comparison
40 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
41 # for more information.
42 string(TOLOWER ${ARCH} ARCH)
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)
53 # Compiler flags handling
54 include(sdk/cmake/compilerflags.cmake)
56 add_definitions(-D__REACTOS__)
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}")
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]")
67 add_compile_flags("/MP")
70 # Bison and Flex support
71 # include(sdk/cmake/bison-flex.cmake)
73 if(NOT CMAKE_CROSSCOMPILING)
74 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
75 add_definitions(-DTARGET_${ARCH})
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)
83 if(MSVC_VERSION GREATER 1699)
84 add_definitions(/D_ALLOW_KEYWORD_MACROS)
88 add_definitions(/Dinline=__inline)
91 add_subdirectory(sdk/include/host)
94 add_subdirectory(dll/win32/dbghelp)
96 add_subdirectory(sdk/tools)
97 add_subdirectory(sdk/lib)
99 set(NATIVE_TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb)
101 list(APPEND NATIVE_TARGETS rsym pefixup)
104 export(TARGETS ${NATIVE_TARGETS} FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
105 configure_file(sdk/cmake/host-tools.in ${CMAKE_BINARY_DIR}/TargetList.cmake)
108 # Add host tools target
109 include(sdk/cmake/host-tools.cmake)
112 # We don't need CMake importlib handling.
113 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
116 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
118 # adjust the default behaviour of the FIND_XXX() commands:
119 # search headers and libraries in the target environment, search
120 # programs in the host environment
121 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
122 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
123 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
126 include(CMakeParseArguments)
129 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
131 add_definitions(-DDBG=0)
135 add_definitions(-DKDBG)
139 add_definitions(-D_WINKD_)
143 message(WARNING "-- Disabling precompiled headers support (ccache).")
144 option(PCH "Whether to use precompiled headers" OFF)
145 elseif(CMAKE_VERSION VERSION_LESS 3.16.0)
146 message(WARNING "-- Disabling precompiled headers support due to this unsupported CMake version: ${CMAKE_VERSION}.")
147 option(PCH "Whether to use precompiled headers" OFF)
149 message(WARNING "-- Disabling precompiled headers on GCC by default CORE-17108.")
150 option(PCH "Whether to use precompiled headers" OFF)
152 option(PCH "Whether to use precompiled headers" ON)
156 add_definitions(-DWINVER=0x502
159 -D_WIN32_WINDOWS=0x502
160 -D_SETUPAPI_VER=0x502
161 -DMINGW_HAS_SECURE_API=1)
164 if(ARCH STREQUAL "i386")
166 add_definitions(-D_M_IX86)
168 add_definitions(-D_X86_ -D__i386__ -Di386)
169 if(SARCH STREQUAL "xbox")
170 add_definitions(-DSARCH_XBOX)
171 elseif(SARCH STREQUAL "pc98")
172 add_definitions(-DSARCH_PC98)
174 elseif(ARCH STREQUAL "amd64")
175 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
176 elseif(ARCH STREQUAL "arm")
177 # _M_ARM is already defined by toolchain
178 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
179 if(SARCH STREQUAL "omap-zoom2")
180 add_definitions(-D_ZOOM2_)
185 add_definitions(-D_NEW_DELETE_OPERATORS_)
186 if(ARCH STREQUAL "i386")
187 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
188 elseif(ARCH STREQUAL "amd64")
189 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
190 elseif(ARCH STREQUAL "arm")
191 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
194 # Activate support for assembly source files
197 # Activate language support for resource files
200 # Localization definitions
201 include(sdk/cmake/localization.cmake)
203 # This will set I18N_DEFS for later use
204 set_i18n_language(${I18N_LANG})
206 # Compiler specific definitions and macros
208 include(sdk/cmake/msvc.cmake)
210 include(sdk/cmake/gcc.cmake)
214 include(sdk/cmake/CMakeMacros.cmake)
216 # IDL macros for widl/midl
217 # We're using widl now for both MSVC and GCC builds
218 include(sdk/cmake/widl-support.cmake)
224 ${REACTOS_BINARY_DIR}/sdk/include
225 ${REACTOS_BINARY_DIR}/sdk/include/psdk
226 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
227 ${REACTOS_BINARY_DIR}/sdk/include/ddk
228 ${REACTOS_BINARY_DIR}/sdk/include/reactos
229 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
234 sdk/include/reactos/libs)
236 if(ARCH STREQUAL "arm")
237 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
240 add_dependency_header()
242 add_subdirectory(sdk/include/ndk/tests)
243 add_subdirectory(sdk/include/xdk)
244 add_subdirectory(sdk/include/psdk)
245 add_subdirectory(sdk/include/dxsdk)
246 add_subdirectory(sdk/include/reactos/wine)
247 add_subdirectory(sdk/include/reactos/mc)
248 add_subdirectory(sdk/include/asm)
251 include(sdk/cmake/baseaddress_dwarf.cmake)
253 include(sdk/cmake/baseaddress_msvc.cmake)
255 include(sdk/cmake/baseaddress.cmake)
258 # For MSVC builds, this puts all debug symbols file in the same directory.
260 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
262 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols")
265 #begin with boot so reactos_cab target is defined before all other modules
266 add_subdirectory(boot)
267 add_subdirectory(base)
268 add_subdirectory(dll)
269 add_subdirectory(drivers)
270 add_subdirectory(hal)
271 add_subdirectory(sdk/lib)
272 add_subdirectory(media)
273 add_subdirectory(modules)
274 add_subdirectory(ntoskrnl)
275 add_subdirectory(subsystems)
276 add_subdirectory(sdk/tools/wpp)
277 add_subdirectory(win32ss)
279 # Create the registry hives
280 create_registry_hives()
282 # Create {bootcd, livecd, bootcdregtest}.lst
285 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/sdk/include/reactos)
287 add_dependency_footer()