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