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