[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}/boot/ros_livecd.txt
83 ${REACTOS_BINARY_DIR}/boot/ros_livecd_target.txt
84 ${REACTOS_BINARY_DIR}/boot/ros_minicd.txt
85 ${REACTOS_BINARY_DIR}/boot/ros_minicd_target.txt
86 ${REACTOS_BINARY_DIR}/boot/ros_cab.txt
87 ${REACTOS_BINARY_DIR}/boot/ros_cab_target.txt)
88
89 #Some useful variables
90 set(LIVECD_DIR "${REACTOS_BINARY_DIR}/boot/livecd")
91 set(BOOTCD_DIR "${REACTOS_BINARY_DIR}/boot/bootcd")
92
93 # Activate support for assembly source files
94 enable_language(ASM)
95
96 # Activate language support for resource files
97 enable_language(RC)
98
99 if(DBG)
100 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE)
101 endif()
102
103 if(KDBG)
104 add_definitions(-DKDBG=1)
105 endif()
106
107 if(_WINKD_)
108 add_definitions(-D_WINKD_=1)
109 endif()
110
111 # Version Options
112 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
113
114 # Arch Options
115 if(ARCH MATCHES i386)
116 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
117 elseif(ARCH MATCHES amd64)
118 add_definitions(-D_M_AMD64 -D_AMD64_ -D_M_AXP64 -D__x86_64__ -D_WIN64)
119 endif()
120
121 # Other
122 if(ARCH MATCHES i386)
123 add_definitions(-DUSE_COMPILER_EXCEPTIONS -D_USE_32BIT_TIME_T)
124 elseif(ARCH MATCHES amd64)
125 add_definitions(-DUSE_COMPILER_EXCEPTIONS -DNO_UNDERSCORE_PREFIX)
126 endif()
127
128 include_directories(
129 include
130 include/psdk
131 include/dxsdk
132 ${REACTOS_BINARY_DIR}/include
133 ${REACTOS_BINARY_DIR}/include/dxsdk
134 ${REACTOS_BINARY_DIR}/include/psdk
135 ${REACTOS_BINARY_DIR}/include/reactos
136 include/crt
137 include/ddk
138 include/ndk
139 include/reactos
140 include/reactos/libs)
141
142 if(MSVC)
143 include_directories(include/crt/msc)
144 else()
145 include_directories(include/crt/mingw32)
146 endif()
147
148 add_subdirectory(include/psdk)
149 add_subdirectory(include/dxsdk)
150 add_subdirectory(include/reactos/idl)
151 add_subdirectory(include/reactos/wine)
152 add_subdirectory(include/reactos/mc)
153 add_subdirectory(include/asm)
154
155 include(baseaddress.cmake)
156
157 add_subdirectory(base)
158 add_subdirectory(boot)
159 add_subdirectory(dll)
160 add_subdirectory(drivers)
161 add_subdirectory(hal)
162 add_subdirectory(lib)
163 add_subdirectory(media)
164 add_subdirectory(modules)
165 add_subdirectory(ntoskrnl)
166 add_subdirectory(subsystems)
167
168 # nci generated intermediate files
169
170 list(APPEND nci_output
171 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
172 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
173 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
174 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
175 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
176 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
177
178 list(APPEND nci_folders
179 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
180 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
181 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
182 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
183 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
184 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include)
185
186 file(MAKE_DIRECTORY ${nci_folders})
187
188 add_custom_command(
189 OUTPUT ${nci_output}
190 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
191 DEPENDS native-nci ${nci_folders})
192
193 set_source_files_properties(${nci_output} PROPERTIES GENERATED TRUE)
194
195 add_custom_target(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
196 add_custom_target(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
197 add_custom_target(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
198 add_custom_target(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
199 add_custom_target(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
200 add_custom_target(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
201
202 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
203
204 add_custom_command(
205 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
206 COMMAND native-buildno ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
207 DEPENDS ${REACTOS_SOURCE_DIR}/include/reactos/version.h)
208
209 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
210
211 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
212
213 list(APPEND OUTPUT_FILES
214 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
215 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
216 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
217
218 add_custom_command(
219 OUTPUT ${OUTPUT_FILES}
220 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
221 DEPENDS native-gendib)
222
223 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
224
225 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
226
227 #bootcd and livecd
228 include(ros_cd.cmake)
229
230 endif()