[CMAKE]
[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 cdmake mkhive FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
44 else()
45 export(TARGETS winebuild nci buildno gendib 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_command(
112 OUTPUT ${REACTOS_BINARY_DIR}/minicd.iso
113 COMMAND native-cdmake -v -j -m -b ${CMAKE_CURRENT_BINARY_DIR}/boot/freeldr/bootsect/isoboot.bin ${BOOTCD_DIR} REACTOS ${REACTOS_BINARY_DIR}/minicd.iso
114 DEPENDS native-cdmake)
115 add_custom_target(minicd DEPENDS ${REACTOS_BINARY_DIR}/minicd.iso)
116 add_minicd(${REACTOS_SOURCE_DIR}/boot/bootdata/bootcd.ini "" freeldr.ini)
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}/reactos")
124 file(MAKE_DIRECTORY "${LIVECD_DIR}/reactos/fonts")
125 file(MAKE_DIRECTORY "${LIVECD_DIR}/reactos/system32")
126 file(MAKE_DIRECTORY "${LIVECD_DIR}/reactos/system32/config")
127
128
129
130 add_custom_command(
131 OUTPUT ${REACTOS_BINARY_DIR}/livecd.iso
132 COMMAND native-cdmake -v -j -m -b ${CMAKE_CURRENT_BINARY_DIR}/boot/freeldr/bootsect/isoboot.bin ${LIVECD_DIR} REACTOS ${REACTOS_BINARY_DIR}/livecd.iso
133 DEPENDS native-cdmake)
134 add_custom_target(livecd DEPENDS ${REACTOS_BINARY_DIR}/livecd.iso)
135 add_livecd(${REACTOS_SOURCE_DIR}/boot/bootdata/livecd.ini "" freeldr.ini)
136
137 add_subdirectory(base)
138 add_subdirectory(boot)
139 add_subdirectory(dll)
140 add_subdirectory(drivers)
141 add_subdirectory(hal)
142 add_subdirectory(lib)
143 add_subdirectory(media)
144 add_subdirectory(ntoskrnl)
145 add_subdirectory(subsystems)
146
147 # nci generated intermediate files
148
149 list(APPEND nci_output
150 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
151 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
152 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
153 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
154 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
155 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
156
157 list(APPEND nci_folders
158 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
159 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
160 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
161 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
162 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
163 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include)
164
165 file(MAKE_DIRECTORY ${nci_folders})
166
167 add_custom_command(
168 OUTPUT ${nci_output}
169 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
170 DEPENDS native-nci ${nci_folders})
171
172 set_source_files_properties(${nci_output} PROPERTIES GENERATED TRUE)
173
174 add_custom_target(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
175 add_custom_target(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
176 add_custom_target(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
177 add_custom_target(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
178 add_custom_target(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
179 add_custom_target(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
180
181 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
182
183 add_custom_command(
184 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
185 COMMAND native-buildno ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
186 DEPENDS ${REACTOS_SOURCE_DIR}/include/reactos/version.h)
187
188 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
189
190 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
191
192 list(APPEND OUTPUT_FILES
193 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
194 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
195 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
196
197 add_custom_command(
198 OUTPUT ${OUTPUT_FILES}
199 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
200 DEPENDS native-gendib)
201
202 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
203
204 endif()
205