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