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