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