[NTVDM]
[reactos.git] / CMakeLists.txt
1
2 cmake_minimum_required(VERSION 2.6)
3
4 if(POLICY CMP0017)
5 # Shadow cmake provided modules
6 cmake_policy(SET CMP0017 OLD)
7 endif()
8
9 project(REACTOS)
10
11 # Versioning
12 include(include/reactos/version.cmake)
13
14 # Don't escape preprocessor definition values added via add_definitions
15 cmake_policy(SET CMP0005 OLD)
16 cmake_policy(SET CMP0002 NEW)
17 if(POLICY CMP0018)
18 cmake_policy(SET CMP0018 OLD)
19 endif()
20
21 set(CMAKE_INCLUDE_CURRENT_DIR ON)
22 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
23 set(CMAKE_SHARED_LIBRARY_PREFIX "")
24 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
25 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
26 set(CMAKE_COLOR_MAKEFILE OFF)
27 #set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
28 set(CMAKE_SKIP_INSTALL_RULES ON)
29
30 if(NOT CMAKE_VERSION STREQUAL "2.8.12.1-ReactOS")
31 set(CMAKE_DISABLE_NINJA_DEPSLOG TRUE)
32 endif()
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(cmake/config.cmake)
47 elseif(ARCH STREQUAL "amd64")
48 include(cmake/config-amd64.cmake)
49 elseif(ARCH STREQUAL "arm")
50 include(cmake/config-arm.cmake)
51 endif()
52
53 # Compiler flags handling
54 include(cmake/compilerflags.cmake)
55
56 add_definitions(-D__REACTOS__)
57
58 if(NOT CMAKE_CROSSCOMPILING)
59
60 add_definitions(-DTARGET_${ARCH})
61
62 if(MSVC)
63 if(ARCH STREQUAL "i386")
64 add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
65 endif()
66 add_definitions(/Dinline=__inline)
67 else()
68 add_compile_flags("-fshort-wchar -Wno-multichar")
69 endif()
70
71 include_directories(include/host)
72
73 if(NOT MSVC)
74 add_subdirectory(dll/win32/dbghelp)
75 endif()
76 add_subdirectory(tools)
77 add_subdirectory(lib)
78
79 if(NOT MSVC)
80 export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
81 else()
82 export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
83 endif()
84
85 else()
86
87 # adjust the default behaviour of the FIND_XXX() commands:
88 # search headers and libraries in the target environment, search
89 # programs in the host environment
90 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
91 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
92 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
93
94 #useful stuff!
95 include(CMakeParseArguments)
96
97 if(ENABLE_CCACHE)
98 set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
99 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
100 endif()
101
102 # Default to Debug for the build type
103 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
104 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
105
106 # Do some cleanup
107 file(REMOVE
108 ${REACTOS_BINARY_DIR}/dependencies.graphml
109 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
110 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
111 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
112 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
113 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
114 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
115
116 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
117 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
118 endif()
119
120 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
121 include(${IMPORT_EXECUTABLES})
122
123 if(DBG)
124 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
125 else()
126 add_definitions(-DDBG=0)
127 endif()
128
129 if(KDBG)
130 add_definitions(-DKDBG=1)
131 endif()
132
133 if(_WINKD_)
134 add_definitions(-D_WINKD_=1)
135 endif()
136
137 if((NOT DEFINED PCH) AND (CMAKE_VERSION STREQUAL "2.8.12.1-ReactOS") AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
138 set(PCH 1)
139 else()
140 set(PCH 0)
141 endif()
142
143 # Version Options
144 add_definitions(-DWINVER=0x502
145 -D_WIN32_IE=0x600
146 -D_WIN32_WINNT=0x502
147 -D_WIN32_WINDOWS=0x502
148 -D_SETUPAPI_VER=0x502)
149
150 # Arch Options
151 if(ARCH STREQUAL "i386")
152 add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
153 elseif(ARCH STREQUAL "amd64")
154 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
155 elseif(ARCH STREQUAL "arm")
156 # _M_ARM is already defined by toolchain
157 add_definitions(-D_ARM_ -D__arm__)
158 endif()
159
160 # Other
161 if(ARCH STREQUAL "i386")
162 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
163 elseif(ARCH STREQUAL "amd64")
164 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
165 elseif(ARCH STREQUAL "arm")
166 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
167 endif()
168
169 # Activate support for assembly source files
170 enable_language(ASM)
171
172 # Activate language support for resource files
173 enable_language(RC)
174
175 # Localization definitions
176 include(cmake/localization.cmake)
177 set(I18N_DEFS "")
178 # This will set I18N_DEFS for later use
179 set_i18n_language(${I18N_LANG})
180
181 # Compiler specific definitions and macros
182 if(MSVC)
183 include(cmake/msvc.cmake)
184 else()
185 include(cmake/gcc.cmake)
186 endif()
187
188 # Generic macros
189 include(cmake/CMakeMacros.cmake)
190
191 # IDL macros for widl/midl
192 # We're using widl now for both MSVC and GCC builds
193 include(cmake/widl-support.cmake)
194
195 include_directories(
196 include
197 include/psdk
198 include/dxsdk
199 ${REACTOS_BINARY_DIR}/include
200 ${REACTOS_BINARY_DIR}/include/psdk
201 ${REACTOS_BINARY_DIR}/include/dxsdk
202 ${REACTOS_BINARY_DIR}/include/reactos
203 include/crt
204 include/ddk
205 include/ndk
206 include/reactos
207 include/reactos/libs)
208
209 if(ARCH STREQUAL "arm")
210 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
211 endif()
212
213 add_dependency_header()
214
215 add_subdirectory(include/psdk)
216 add_subdirectory(include/dxsdk)
217 add_subdirectory(include/reactos/wine)
218 add_subdirectory(include/reactos/mc)
219 add_subdirectory(include/asm)
220
221 include(cmake/baseaddress.cmake)
222
223 # For MSVC builds, this puts all debug symbols file in the same directory.
224 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
225
226 #begin with boot so reactos_cab target is defined before all other modules
227 add_subdirectory(boot)
228 add_subdirectory(base)
229 add_subdirectory(dll)
230 add_subdirectory(drivers)
231 add_subdirectory(hal)
232 add_subdirectory(lib)
233 add_subdirectory(media)
234 add_subdirectory(modules)
235 add_subdirectory(ntoskrnl)
236 add_subdirectory(subsystems)
237 add_subdirectory(tools/wpp)
238 add_subdirectory(win32ss)
239
240 # Create {bootcd, livecd, bootcdregtest}.lst
241 create_iso_lists()
242
243 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
244
245 add_dependency_footer()
246 endif()