[CMAKE]
[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 set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
25
26 add_definitions(-D__REACTOS__)
27
28 if(NOT CMAKE_CROSSCOMPILING)
29
30 add_definitions(-DTARGET_i386)
31
32 include_directories(${REACTOS_SOURCE_DIR}/tools/unicode)
33 include_directories(include)
34 include_directories(include/host)
35 include_directories(include/reactos)
36 include_directories(include/reactos/wine)
37 include_directories(${REACTOS_BINARY_DIR}/include)
38
39 add_subdirectory(tools)
40 add_subdirectory(lib)
41
42 if(NOT MSVC)
43 export(TARGETS widl winebuild nci buildno gendib cdmake FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
44 else()
45 export(TARGETS winebuild nci buildno gendib cdmake FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
46 endif()
47
48 else()
49
50 # Activate support for assembly source files
51 enable_language(ASM)
52
53 # Activate language support for resource files
54 enable_language(RC)
55
56 set(IMPORT_EXECUTABLES "${REACTOS_SOURCE_DIR}/build/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
57 include(${IMPORT_EXECUTABLES})
58
59 add_definitions(-DDBG=${DBG} -DKDBG=${KDBG})
60
61 if(DBG MATCHES 1)
62 add_definitions(-D_SEH_ENABLE_TRACE)
63 endif(DBG MATCHES 1)
64
65 if((DBG MATCHES 1) OR (KDBG MATCHES 1))
66 set(DBG_OR_KDBG true)
67 endif((DBG MATCHES 1) OR (KDBG MATCHES 1))
68
69 # Version Options
70 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
71
72 # Arch Options
73 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
74
75 # Other
76 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
77 add_definitions(-D_USE_32BIT_TIME_T)
78
79 include_directories(include)
80 include_directories(include/psdk)
81 include_directories(include/dxsdk)
82 include_directories(${REACTOS_BINARY_DIR}/include)
83 include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
84 include_directories(${REACTOS_BINARY_DIR}/include/psdk)
85 include_directories(${REACTOS_BINARY_DIR}/include/reactos)
86 include_directories(include/crt)
87 if(MSVC)
88 include_directories(include/crt/msc)
89 else()
90 include_directories(include/crt/mingw32)
91 endif(MSVC)
92 include_directories(include/ddk)
93 include_directories(include/ndk)
94 include_directories(include/reactos)
95 include_directories(include/reactos/libs)
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