[CMAKE]
[reactos.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(REACTOS)
3
4 include(CMakeMacros.cmake)
5
6 set(CMAKE_INCLUDE_CURRENT_DIR ON)
7 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
8 set(CMAKE_SHARED_LIBRARY_PREFIX "")
9
10 set(CMAKE_SKIP_PREPROCESSED_SOURCE_RULES TRUE)
11 set(CMAKE_SKIP_ASSEMBLY_SOURCE_RULES TRUE)
12
13 add_definitions(-D__REACTOS__)
14
15 if(NOT CMAKE_CROSSCOMPILING)
16
17 add_definitions(-DTARGET_i386)
18 add_definitions(-fshort-wchar)
19
20 include_directories(${REACTOS_SOURCE_DIR}/tools/unicode)
21 include_directories(include)
22 include_directories(include/reactos)
23 include_directories(include/reactos/wine)
24 include_directories(${REACTOS_BINARY_DIR}/include)
25
26 add_subdirectory(tools)
27 add_subdirectory(lib)
28
29 export(TARGETS widl winebuild nci buildno gendib cdmake FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
30
31 else()
32
33 # Linking
34 link_directories("${REACTOS_SOURCE_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3rdparty/mingw)
35 set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
36 set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,-T,${REACTOS_SOURCE_DIR}/global.lds")
37
38 # Activate support for assembly source files
39 enable_language(ASM)
40
41 # Activate language support for resource files
42 enable_language(RC)
43
44 set(IMPORT_EXECUTABLES "${REACTOS_SOURCE_DIR}/build/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
45 include(${IMPORT_EXECUTABLES})
46
47 # Debug Options
48 set(_WINKD_ 0)
49 set(KDBG 1)
50 set(DBG 1)
51
52 add_definitions(-DDBG=${DBG} -DKDBG=${KDBG})
53
54 if(DBG MATCHES 1)
55 add_definitions(-D_SEH_ENABLE_TRACE)
56 endif(DBG MATCHES 1)
57
58 if((DBG MATCHES 1) OR (KDBG MATCHES 1))
59 set(DBG_OR_KDBG true)
60 endif((DBG MATCHES 1) OR (KDBG MATCHES 1))
61
62 # Version Options
63 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
64
65 # Arch Options
66 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
67
68 # Other
69 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
70 add_definitions(-D_USE_32BIT_TIME_T)
71
72 # Compiler Core
73 add_definitions(-pipe -fms-extensions)
74
75 # Debugging (Note: DWARF-4 on 4.5.1 when we ship)
76 add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
77
78 # Tuning
79 add_definitions(-march=pentium -mtune=i686)
80
81 # Warnings
82 add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
83
84 # Optimizations
85 add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)
86
87 # C++ Flags
88 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
89
90 include_directories(include)
91 include_directories(include/psdk)
92 include_directories(include/dxsdk)
93 include_directories(${REACTOS_BINARY_DIR}/include)
94 include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
95 include_directories(${REACTOS_BINARY_DIR}/include/psdk)
96 include_directories(${REACTOS_BINARY_DIR}/include/reactos)
97 include_directories(include/crt)
98 include_directories(include/crt/mingw32)
99 include_directories(include/ddk)
100 include_directories(include/ndk)
101 include_directories(include/reactos)
102 include_directories(include/reactos/libs)
103
104 add_subdirectory(include/psdk)
105 add_subdirectory(include/dxsdk)
106 add_subdirectory(include/reactos/idl)
107 add_subdirectory(include/reactos/mc)
108
109 add_subdirectory(base)
110 add_subdirectory(boot)
111 add_subdirectory(dll)
112 add_subdirectory(drivers)
113 add_subdirectory(hal)
114 add_subdirectory(lib)
115 add_subdirectory(ntoskrnl)
116 add_subdirectory(subsystems)
117
118 # nci generated intermediate files
119
120 list(APPEND nci_output
121 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
122 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
123 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
124 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
125 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
126 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
127
128 list(APPEND nci_folders
129 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
130 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
131 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
132 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
133 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
134 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include)
135
136 file(MAKE_DIRECTORY ${nci_folders})
137
138 add_custom_command(
139 OUTPUT ${nci_output}
140 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
141 DEPENDS native-nci ${nci_folders})
142
143 set_source_files_properties(${nci_output} PROPERTIES GENERATED TRUE)
144
145 add_custom_target(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
146 add_custom_target(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
147 add_custom_target(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
148 add_custom_target(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
149 add_custom_target(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
150 add_custom_target(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
151
152 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
153
154 add_custom_command(
155 OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
156 COMMAND native-buildno ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
157 DEPENDS ${REACTOS_SOURCE_DIR}/include/reactos/version.h)
158
159 add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
160
161 file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
162
163 list(APPEND OUTPUT_FILES
164 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib8gen.c
165 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib16gen.c
166 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib/dib32gen.c)
167
168 add_custom_command(
169 OUTPUT ${OUTPUT_FILES}
170 COMMAND native-gendib ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib
171 DEPENDS native-gendib)
172
173 add_custom_target(gendib_generated ALL DEPENDS ${OUTPUT_FILES})
174
175 endif()