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 OLD)
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)
34 if(NOT DEFINED NEW_STYLE_BUILD)
35 set(NEW_STYLE_BUILD TRUE)
41 # Now the ARCH variable will be in lowercase.
42 # It is needed because STREQUAL comparison
44 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
45 # for more information.
46 string(TOLOWER ${ARCH} ARCH)
49 if(ARCH STREQUAL "i386")
50 include(sdk/cmake/config.cmake)
51 elseif(ARCH STREQUAL "amd64")
52 include(sdk/cmake/config-amd64.cmake)
53 elseif(ARCH STREQUAL "arm")
54 include(sdk/cmake/config-arm.cmake)
57 # Compiler flags handling
58 include(sdk/cmake/compilerflags.cmake)
60 add_definitions(-D__REACTOS__)
62 # Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
63 add_definitions(-DREACTOS_SOURCE_DIR="${REACTOS_SOURCE_DIR}")
64 add_definitions(-DREACTOS_BINARY_DIR="${REACTOS_BINARY_DIR}")
66 # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
67 file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
68 add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
71 add_compile_flags("/MP")
74 # Bison and Flex support
75 # include(sdk/cmake/bison-flex.cmake)
77 if(NOT CMAKE_CROSSCOMPILING)
80 set(TOOLS_FOLDER ${CMAKE_CURRENT_BINARY_DIR})
83 add_definitions(-DTARGET_${ARCH})
86 if(ARCH STREQUAL "i386")
87 add_definitions(/D_X86_ /D__i386__ /DWIN32 /D_WINDOWS)
88 elseif(ARCH STREQUAL "amd64")
89 add_definitions(-D_AMD64_ -D__x86_64__ /DWIN32 -D_WINDOWS)
91 if(MSVC_VERSION GREATER 1699)
92 add_definitions(/D_ALLOW_KEYWORD_MACROS)
96 add_definitions(/Dinline=__inline)
100 include_directories(sdk/include/host)
103 add_subdirectory(dll/win32/dbghelp)
105 add_subdirectory(sdk/tools)
106 add_subdirectory(sdk/lib)
108 if(NOT NEW_STYLE_BUILD)
110 export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc rsym mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
112 export(TARGETS bin2c widl gendib cabman fatten hpp isohybrid mkhive mkisofs obj2bin spec2def geninc mkshelllink utf16le xml2sdb FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
117 # We don't need CMake importlib handling.
118 unset(CMAKE_IMPORT_LIBRARY_SUFFIX)
121 include(sdk/cmake/host-tools.cmake)
125 message("-- Build Type: ${CMAKE_BUILD_TYPE}")
127 # adjust the default behaviour of the FIND_XXX() commands:
128 # search headers and libraries in the target environment, search
129 # programs in the host environment
130 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
131 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
132 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
135 include(CMakeParseArguments)
137 if(NOT NEW_STYLE_BUILD)
138 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
139 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
141 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
142 include(${IMPORT_EXECUTABLES})
146 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
148 add_definitions(-DDBG=0)
152 add_definitions(-DKDBG=1)
156 add_definitions(-D_WINKD_=1)
159 if(CMAKE_VERSION MATCHES "ReactOS")
160 set(PCH 1 CACHE BOOL "Whether to use precompiled headers")
162 set(PCH 0 CACHE BOOL "Whether to use precompiled headers")
166 add_definitions(-DWINVER=0x502
169 -D_WIN32_WINDOWS=0x502
170 -D_SETUPAPI_VER=0x502)
173 if(ARCH STREQUAL "i386")
175 add_definitions(-D_M_IX86)
177 add_definitions(-D_X86_ -D__i386__ -Di386)
178 elseif(ARCH STREQUAL "amd64")
179 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
180 elseif(ARCH STREQUAL "arm")
181 # _M_ARM is already defined by toolchain
182 add_definitions(-D_ARM_ -D__arm__ -DWIN32)
183 if(SARCH STREQUAL "omap-zoom2")
184 add_definitions(-D_ZOOM2_)
189 add_definitions(-D_NEW_DELETE_OPERATORS_)
190 if(ARCH STREQUAL "i386")
191 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
192 elseif(ARCH STREQUAL "amd64")
193 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
194 elseif(ARCH STREQUAL "arm")
195 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
198 # Activate support for assembly source files
201 # Activate language support for resource files
204 # Localization definitions
205 include(sdk/cmake/localization.cmake)
207 # This will set I18N_DEFS for later use
208 set_i18n_language(${I18N_LANG})
210 # Compiler specific definitions and macros
212 include(sdk/cmake/msvc.cmake)
214 include(sdk/cmake/gcc.cmake)
218 include(sdk/cmake/CMakeMacros.cmake)
220 # IDL macros for widl/midl
221 # We're using widl now for both MSVC and GCC builds
222 include(sdk/cmake/widl-support.cmake)
228 ${REACTOS_BINARY_DIR}/sdk/include
229 ${REACTOS_BINARY_DIR}/sdk/include/psdk
230 ${REACTOS_BINARY_DIR}/sdk/include/dxsdk
231 ${REACTOS_BINARY_DIR}/sdk/include/ddk
232 ${REACTOS_BINARY_DIR}/sdk/include/reactos
233 ${REACTOS_BINARY_DIR}/sdk/include/reactos/mc
238 sdk/include/reactos/libs)
240 if(ARCH STREQUAL "arm")
241 include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
244 add_dependency_header()
246 add_subdirectory(sdk/include/ndk/tests)
247 add_subdirectory(sdk/include/xdk)
248 add_subdirectory(sdk/include/psdk)
249 add_subdirectory(sdk/include/dxsdk)
250 add_subdirectory(sdk/include/reactos/wine)
251 add_subdirectory(sdk/include/reactos/mc)
252 add_subdirectory(sdk/include/asm)
255 include(sdk/cmake/baseaddress_dwarf.cmake)
257 include(sdk/cmake/baseaddress_msvc.cmake)
259 include(sdk/cmake/baseaddress.cmake)
262 # For MSVC builds, this puts all debug symbols file in the same directory.
263 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
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()