[SHELL/EXPERIMENTS]
[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
29 if(NOT ARCH)
30 set(ARCH i386)
31 endif()
32 # Now the ARCH variable will be in lowercase.
33 # It is needed because STREQUAL comparison
34 # is case-sensitive.
35 # See http://cmake.3232098.n2.nabble.com/Case-insensitive-string-compare-td7580269.html
36 # for more information.
37 string(TOLOWER ${ARCH} ARCH)
38
39 # Compile options
40 if(ARCH STREQUAL "i386")
41 include(cmake/config.cmake)
42 elseif(ARCH STREQUAL "amd64")
43 include(cmake/config-amd64.cmake)
44 elseif(ARCH STREQUAL "arm")
45 include(cmake/config-arm.cmake)
46 endif()
47
48 # Compiler flags handling
49 include(cmake/compilerflags.cmake)
50
51 add_definitions(-D__REACTOS__)
52
53 if(NOT CMAKE_CROSSCOMPILING)
54
55 add_definitions(-DTARGET_${ARCH})
56
57 if(MSVC)
58 if(ARCH STREQUAL "i386")
59 add_definitions(/D_X86_ /DWIN32 /D_WINDOWS)
60 endif()
61 add_definitions(/Dinline=__inline)
62 else()
63 add_compile_flags("-fshort-wchar -Wno-multichar")
64 endif()
65
66 include_directories(include/host)
67
68 if(NOT MSVC)
69 add_subdirectory(dll/win32/dbghelp)
70 endif()
71 add_subdirectory(tools)
72 add_subdirectory(lib)
73
74 if(NOT MSVC)
75 export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc rsym mkshelllink FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
76 else()
77 export(TARGETS bin2c widl gendib cabman cdmake mkhive obj2bin spec2def geninc mkshelllink FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
78 endif()
79
80 else()
81
82 # adjust the default behaviour of the FIND_XXX() commands:
83 # search headers and libraries in the target environment, search
84 # programs in the host environment
85 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
86 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
87 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
88
89 #useful stuff!
90 include(CMakeParseArguments)
91
92 if(ENABLE_CCACHE)
93 set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
94 set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
95 endif()
96
97 # Default to Debug for the build type
98 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
99 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
100
101 # Do some cleanup
102 file(REMOVE
103 ${REACTOS_BINARY_DIR}/dependencies.graphml
104 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
105 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
106 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
107 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
108 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
109 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
110
111 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
112 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
113 endif()
114
115 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
116 include(${IMPORT_EXECUTABLES})
117
118 if(DBG)
119 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
120 else()
121 add_definitions(-DDBG=0)
122 endif()
123
124 if(KDBG)
125 add_definitions(-DKDBG=1)
126 endif()
127
128 if(_WINKD_)
129 add_definitions(-D_WINKD_=1)
130 endif()
131
132 # Version Options
133 add_definitions(-DWINVER=0x502
134 -D_WIN32_IE=0x600
135 -D_WIN32_WINNT=0x502
136 -D_WIN32_WINDOWS=0x502
137 -D_SETUPAPI_VER=0x502)
138
139 # Arch Options
140 if(ARCH STREQUAL "i386")
141 add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
142 elseif(ARCH STREQUAL "amd64")
143 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
144 elseif(ARCH STREQUAL "arm")
145 # _M_ARM is already defined by toolchain
146 add_definitions(-D_ARM_ -D__arm__)
147 endif()
148
149 # Other
150 if(ARCH STREQUAL "i386")
151 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
152 elseif(ARCH STREQUAL "amd64")
153 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
154 elseif(ARCH STREQUAL "arm")
155 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
156 endif()
157
158 # Activate support for assembly source files
159 enable_language(ASM)
160
161 # Activate language support for resource files
162 enable_language(RC)
163
164 # Localization definitions
165 include(cmake/localization.cmake)
166 set(I18N_DEFS "")
167 # This will set I18N_DEFS for later use
168 set_i18n_language(${I18N_LANG})
169
170 # Compiler specific definitions and macros
171 if(MSVC)
172 include(cmake/msvc.cmake)
173 else()
174 include(cmake/gcc.cmake)
175 endif()
176
177 # Generic macros
178 include(cmake/CMakeMacros.cmake)
179
180 # IDL macros for widl/midl
181 # We're using widl now for both MSVC and GCC builds
182 include(cmake/widl-support.cmake)
183
184 include_directories(
185 include
186 include/psdk
187 include/dxsdk
188 ${REACTOS_BINARY_DIR}/include
189 ${REACTOS_BINARY_DIR}/include/psdk
190 ${REACTOS_BINARY_DIR}/include/dxsdk
191 ${REACTOS_BINARY_DIR}/include/reactos
192 include/crt
193 include/ddk
194 include/ndk
195 include/reactos
196 include/reactos/libs)
197
198 if(ARCH STREQUAL "arm")
199 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
200 endif()
201
202 add_dependency_header()
203
204 add_subdirectory(include/psdk)
205 add_subdirectory(include/dxsdk)
206 add_subdirectory(include/reactos/wine)
207 add_subdirectory(include/reactos/mc)
208 add_subdirectory(include/asm)
209
210 include(cmake/baseaddress.cmake)
211
212 # For MSVC builds, this puts all debug symbols file in the same directory.
213 set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
214
215 #begin with boot so reactos_cab target is defined before all other modules
216 add_subdirectory(boot)
217 add_subdirectory(base)
218 add_subdirectory(dll)
219 add_subdirectory(drivers)
220 add_subdirectory(hal)
221 add_subdirectory(lib)
222 add_subdirectory(media)
223 add_subdirectory(modules)
224 add_subdirectory(ntoskrnl)
225 add_subdirectory(subsystems)
226 add_subdirectory(tools/wpp)
227 add_subdirectory(win32ss)
228
229 # Create {bootcd, livecd, bootcdregtest}.lst
230 create_iso_lists()
231
232 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
233
234 add_dependency_footer()
235 endif()