[CMAKE]
[reactos.git] / CMakeLists.txt
1
2 cmake_minimum_required(VERSION 2.6)
3 project(REACTOS)
4
5 #versioning
6 include(include/reactos/version.cmake)
7
8 # Don't escape preprocessor definition values added via add_definitions
9 cmake_policy(SET CMP0005 OLD)
10 # Shadow cmake provided modules
11 cmake_policy(SET CMP0017 OLD)
12
13 set(CMAKE_INCLUDE_CURRENT_DIR ON)
14 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
15 set(CMAKE_SHARED_LIBRARY_PREFIX "")
16 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
17 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
18 set(CMAKE_COLOR_MAKEFILE OFF)
19 set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
20
21 if(NOT ARCH)
22 set(ARCH i386)
23 endif()
24 string(TOLOWER ${ARCH} ARCH)
25
26 # Compile options
27 if(ARCH MATCHES i386)
28 include(config.cmake)
29 elseif(ARCH MATCHES amd64)
30 include(config-amd64.cmake)
31 elseif(ARCH MATCHES arm)
32 include(config-arm.cmake)
33 endif()
34
35 add_definitions(-D__REACTOS__)
36
37 if(NOT CMAKE_CROSSCOMPILING)
38
39 add_definitions(-DTARGET_${ARCH})
40
41 if(MSVC)
42 add_definitions(-Dinline=__inline)
43 else()
44 add_definitions(-fshort-wchar)
45 endif()
46
47 include_directories(
48 ${REACTOS_SOURCE_DIR}/tools/unicode
49 include
50 include/host
51 ${REACTOS_BINARY_DIR}/include)
52
53 add_subdirectory(tools)
54 add_subdirectory(lib)
55
56 if(NOT MSVC)
57 export(TARGETS widl gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
58 else()
59 export(TARGETS gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
60 endif()
61
62 else()
63
64 # adjust the default behaviour of the FIND_XXX() commands:
65 # search headers and libraries in the target environment, search
66 # programs in the host environment
67 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
68 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
69 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
70
71 # Do some cleanup
72 file(REMOVE
73 ${REACTOS_BINARY_DIR}/dependencies.graphml
74 ${REACTOS_BINARY_DIR}/boot/ros_livecd.txt
75 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
76 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
77 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
78 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
79 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
80
81 if(NOT DEFINED REACTOS_BUILD_TOOLS_DIR)
82 set(REACTOS_BUILD_TOOLS_DIR ${REACTOS_SOURCE_DIR}/build)
83 endif()
84
85 set(IMPORT_EXECUTABLES "${REACTOS_BUILD_TOOLS_DIR}/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
86 include(${IMPORT_EXECUTABLES})
87
88 # Compiler specific definitions and macros
89 if(MSVC)
90 include(msc.cmake)
91 else()
92 include(gcc.cmake)
93 endif()
94
95 # Generic macros
96 include(CMakeMacros.cmake)
97
98 # IDL macros for widl/midl
99 include(cmake/idl-support.cmake)
100
101 #Some useful variables
102 set(LIVECD_DIR "${REACTOS_BINARY_DIR}/boot/livecd")
103 set(BOOTCD_DIR "${REACTOS_BINARY_DIR}/boot/bootcd")
104
105 # Activate support for assembly source files
106 enable_language(ASM)
107
108 # Activate language support for resource files
109 enable_language(RC)
110
111 if(DBG)
112 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
113 endif()
114
115 if(KDBG)
116 add_definitions(-DKDBG=1)
117 endif()
118
119 if(_WINKD_)
120 add_definitions(-D_WINKD_=1)
121 endif()
122
123 # Version Options
124 add_definitions(-DWINVER=0x502
125 -D_WIN32_IE=0x600
126 -D_WIN32_WINNT=0x502
127 -D_WIN32_WINDOWS=0x502
128 -D_SETUPAPI_VER=0x502)
129
130 # Arch Options
131 if(ARCH MATCHES i386)
132 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
133 elseif(ARCH MATCHES amd64)
134 add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
135 elseif(ARCH MATCHES arm)
136 # _M_ARM is already defined by toolchain
137 add_definitions(-D_ARM_ -D__arm__)
138 endif()
139
140 # Other
141 if(ARCH MATCHES i386)
142 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
143 elseif(ARCH MATCHES amd64)
144 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
145 elseif(ARCH MATCHES arm)
146 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
147 endif()
148
149 include_directories(
150 include
151 include/psdk
152 include/dxsdk
153 ${REACTOS_BINARY_DIR}/include
154 ${REACTOS_BINARY_DIR}/include/dxsdk
155 ${REACTOS_BINARY_DIR}/include/psdk
156 ${REACTOS_BINARY_DIR}/include/reactos
157 include/crt
158 include/ddk
159 include/ndk
160 include/reactos
161 include/reactos/libs)
162
163 if(ARCH MATCHES arm)
164 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/arm)
165 endif()
166
167 if(MSVC)
168 include_directories(include/crt/msc)
169 else()
170 include_directories(include/crt/mingw32)
171 endif()
172
173 add_dependency_header()
174
175 add_subdirectory(include/psdk)
176 add_subdirectory(include/dxsdk)
177 add_subdirectory(include/reactos/idl)
178 add_subdirectory(include/reactos/wine)
179 add_subdirectory(include/reactos/mc)
180 add_subdirectory(include/asm)
181
182 include(baseaddress.cmake)
183
184 add_subdirectory(base)
185 add_subdirectory(boot)
186 add_subdirectory(dll)
187 add_subdirectory(drivers)
188 add_subdirectory(hal)
189 add_subdirectory(lib)
190 add_subdirectory(media)
191 add_subdirectory(modules)
192 add_subdirectory(ntoskrnl)
193 add_subdirectory(subsystems)
194
195 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
196
197 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
198
199 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
200
201 list(APPEND OUTPUT_FILES
202 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
203 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
204 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
205
206 add_custom_command(
207 OUTPUT ${OUTPUT_FILES}
208 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
209 DEPENDS native-gendib)
210
211 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
212
213 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
214
215 #bootcd and livecd
216 include(ros_cd.cmake)
217
218 add_dependency_footer()
219
220 endif()