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