[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 # 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 #begin with boot so reactos_cab target is defined before all other modules
189 add_subdirectory(boot)
190 add_subdirectory(base)
191 add_subdirectory(dll)
192 add_subdirectory(drivers)
193 add_subdirectory(hal)
194 add_subdirectory(lib)
195 add_subdirectory(media)
196 add_subdirectory(modules)
197 add_subdirectory(ntoskrnl)
198 add_subdirectory(subsystems)
199
200 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
201
202 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/importlibs)
203
204 add_dependency_footer()
205
206 endif()