[CMAKE]: Use some nice options which will make makefiles simpler regarding includes.
[reactos.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(REACTOS)
3
4 set(CMAKE_INCLUDE_CURRENT_DIR ON)
5 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
6
7 add_definitions(-D__REACTOS__)
8
9 if(NOT CMAKE_CROSSCOMPILING)
10
11 add_definitions(-DTARGET_i386)
12 add_definitions(-fshort-wchar)
13
14 include_directories(${REACTOS_SOURCE_DIR}/tools/unicode)
15 include_directories(./include)
16 include_directories(./include/reactos)
17 include_directories(./include/reactos/wine)
18
19 add_subdirectory(tools)
20 add_subdirectory(lib)
21
22 export(TARGETS widl winebuild nci FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
23
24 else()
25
26 # Activate support for assembly source files
27 enable_language(ASM)
28
29 # Activate language support for resource files
30 enable_language(RC)
31
32 set(IMPORT_EXECUTABLES "${REACTOS_SOURCE_DIR}/build/ImportExecutables.cmake" CACHE FILEPATH "Host executables")
33 include(${IMPORT_EXECUTABLES})
34
35 # Debug Options
36 add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE -DKDBG=1)
37
38 # Version Options
39 add_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502 -D_WIN32_WINDOWS=0x502 -D_SETUPAPI_VER=0x502)
40
41 # Arch Options
42 add_definitions(-D_M_IX86 -D_X86_ -D__i386__)
43
44 # Other
45 add_definitions(-DUSE_COMPILER_EXCEPTIONS)
46 add_definitions(-D_USE_32BIT_TIME_T)
47
48 # Compiler Core
49 add_definitions(-pipe -fms-extensions -fno-set-stack-executable)
50
51 # Debugging (Note: DWARF-4 on 4.5.1 when we ship)
52 add_definitions(-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types)
53
54 # Tuning
55 add_definitions(-march=pentium -mtune=i686)
56
57 # Warnings
58 add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value)
59
60 # Optimizations
61 add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer -mpreferred-stack-boundary=2 -fno-optimize-sibling-calls)
62
63 include_directories(./include)
64 include_directories(./include/psdk)
65 include_directories(./include/dxsdk)
66 include_directories(${REACTOS_BINARY_DIR}/include/dxsdk)
67 include_directories(${REACTOS_BINARY_DIR}/include/psdk)
68 include_directories(${REACTOS_BINARY_DIR}/include/reactos)
69 include_directories(./include/crt)
70 include_directories(./include/crt/mingw32)
71 include_directories(./include/ddk)
72 include_directories(./include/ndk)
73 include_directories(./include/reactos)
74 include_directories(./include/reactos/libs)
75
76 add_subdirectory(include/psdk)
77 add_subdirectory(include/dxsdk)
78 add_subdirectory(include/reactos/mc)
79
80 add_subdirectory(base)
81 add_subdirectory(dll)
82 add_subdirectory(lib)
83
84 # nci generated intermediate files
85
86 set(nci_output
87 ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h
88 ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h
89 ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S
90 ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S
91 ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S
92 ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec
93 )
94
95 # stupid nci tool can't create folders itself, se we're gonna create them for it
96 set(nci_folders
97 ${CMAKE_CURRENT_BINARY_DIR}/dll/ntdll/def
98 ${CMAKE_CURRENT_BINARY_DIR}/lib/ntdllsys/ntdll
99 ${CMAKE_CURRENT_BINARY_DIR}/lib/win32ksys
100 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/include/internal
101 ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl/ex
102 ${CMAKE_CURRENT_BINARY_DIR}/subsystems/win32/win32k/include
103 )
104
105 file(MAKE_DIRECTORY ${nci_folders})
106
107 ADD_CUSTOM_COMMAND(
108 OUTPUT ${nci_output}
109 COMMAND native-nci -arch ${ARCH} ${REACTOS_SOURCE_DIR}/ntoskrnl/sysfuncs.lst ${REACTOS_SOURCE_DIR}/subsystems/win32/win32k/w32ksvc.db ${nci_output}
110 DEPENDS native-nci ${nci_folders}
111 )
112
113 SET_SOURCE_FILES_PROPERTIES(${nci_output} PROPERTIES GENERATED TRUE)
114
115 ADD_CUSTOM_TARGET(ntdll_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/ntdllsys/ntdll.S)
116 ADD_CUSTOM_TARGET(win32k_S ALL DEPENDS ${REACTOS_BINARY_DIR}/lib/win32ksys/win32k.S)
117 ADD_CUSTOM_TARGET(ntsys_pspec ALL DEPENDS ${REACTOS_BINARY_DIR}/dll/ntdll/def/ntsys.pspec)
118 ADD_CUSTOM_TARGET(kernel_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/include/internal/napi.h)
119 ADD_CUSTOM_TARGET(subsystem_napi ALL DEPENDS ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/include/napi.h)
120 ADD_CUSTOM_TARGET(kernel_zw ALL DEPENDS ${REACTOS_BINARY_DIR}/ntoskrnl/ex/zw.S)
121
122 endif()
123