c76289b1f86d01a23d9f7f8c9c888ecc324d75db
[reactos.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(REACTOS)
3
4 # Compile options
5 include(config.cmake)
6
7 # Compiler specific definitions and macros
8 if(MSVC)
9 include(msc.cmake)
10 else()
11 include(gcc.cmake)
12 endif(MSVC)
13
14 # Generic macros
15 include(CMakeMacros.cmake)
16
17 set(CMAKE_INCLUDE_CURRENT_DIR ON)
18 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
19 set(CMAKE_SHARED_LIBRARY_PREFIX "")
20
21 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
22 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
23
24 add_definitions(-D__REACTOS__)
25
26 if(NOT CMAKE_CROSSCOMPILING)
27
28 add_definitions(-DTARGET_i386)
29
30 include_directories(${REACTOS_SOURCE_DIR}/tools/unicode)
31 include_directories(include)
32 include_directories(include/host)
33 include_directories(include/reactos)
34 include_directories(include/reactos/wine)
35 include_directories(${REACTOS_BINARY_DIR}/include)
36
37 add_subdirectory(tools)
38 add_subdirectory(lib)
39
40 if(NOT MSVC)
41 export(TARGETS widl winebuild nci buildno gendib cdmake FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
42 else()
43 export(TARGETS winebuild nci buildno gendib cdmake FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
44 endif()
45
46 else()
47
48 # Activate support for assembly source files
49 enable_language(ASM)
50
51 # Activate language support for resource files
52 enable_language(RC)
53
54 set(IMPORT_EXECUTABLES "${REACTOS_SOURCE_DIR}/build/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
55 include(${IMPORT_EXECUTABLES})
56
57 add_definitions(-DDBG=${DBG} -DKDBG=${KDBG})
58
59 if(DBG MATCHES 1)
60 add_definitions(-D_SEH_ENABLE_TRACE)
61 endif(DBG MATCHES 1)
62
63 if((DBG MATCHES 1) OR (KDBG MATCHES 1))
64 set(DBG_OR_KDBG true)
65 endif((DBG MATCHES 1) OR (KDBG MATCHES 1))
66
67 # Version Options
68 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
69
70 # Arch Options
71 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
72
73 # Other
74 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
75 add_definitions(-D_USE_32BIT_TIME_T)
76
77 include_directories(include)
78 include_directories(include/psdk)
79 include_directories(include/dxsdk)
80 include_directories(${REACTOS_BINARY_DIR}/include)
81 include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
82 include_directories(${REACTOS_BINARY_DIR}/include/psdk)
83 include_directories(${REACTOS_BINARY_DIR}/include/reactos)
84 include_directories(include/crt)
85 if(MSVC)
86 include_directories(include/crt/msc)
87 else()
88 include_directories(include/crt/mingw32)
89 endif(MSVC)
90 include_directories(include/ddk)
91 include_directories(include/ndk)
92 include_directories(include/reactos)
93 include_directories(include/reactos/libs)
94
95 include_directories(BEFORE lib/3rdparty/stlport/stlport)
96
97 add_subdirectory(include/psdk)
98 add_subdirectory(include/dxsdk)
99 add_subdirectory(include/reactos/idl)
100 add_subdirectory(include/reactos/mc)
101
102 add_subdirectory(base)
103 add_subdirectory(boot)
104 add_subdirectory(dll)
105 add_subdirectory(drivers)
106 add_subdirectory(hal)
107 add_subdirectory(lib)
108 add_subdirectory(ntoskrnl)
109 add_subdirectory(subsystems)
110
111 # nci generated intermediate files
112
113 list(APPEND nci_output
114 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
115 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
116 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
117 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
118 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
119 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
120
121 list(APPEND nci_folders
122 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
123 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
124 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
125 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
126 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
127 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include)
128
129 file(MAKE_DIRECTORY ${nci_folders})
130
131 add_custom_command(
132 OUTPUT ${nci_output}
133 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
134 DEPENDS native-nci ${nci_folders})
135
136 set_source_files_properties(${nci_output} PROPERTIES GENERATED TRUE)
137
138 add_custom_target(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
139 add_custom_target(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
140 add_custom_target(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
141 add_custom_target(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
142 add_custom_target(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
143 add_custom_target(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
144
145 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
146
147 add_custom_command(
148 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
149 COMMAND native-buildno ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
150 DEPENDS ${REACTOS_SOURCE_DIR}/include/reactos/version.h)
151
152 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
153
154 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
155
156 list(APPEND OUTPUT_FILES
157 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
158 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
159 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
160
161 add_custom_command(
162 OUTPUT ${OUTPUT_FILES}
163 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
164 DEPENDS native-gendib)
165
166 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
167
168 endif()
169