[CMAKE]
[reactos.git] / boot / freeldr / freeldr / CMakeLists.txt
1
2 include_directories(BEFORE include)
3 include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include)
4
5 if(ARCH MATCHES arm)
6 if(SARCH MATCHES omap-zoom2)
7 add_definitions(-D_ZOOM2_)
8 endif()
9 endif()
10
11 if(ARCH MATCHES i386)
12 if(MSVC)
13 list(APPEND FREELDR_BASE64K_SOURCE
14 arch/i386/realmode.S)
15 else()
16 list(APPEND FREELDR_STARTUP_SOURCE
17 arch/i386/fathelp.S
18 arch/i386/arch.S)
19 endif()
20 elseif(ARCH MATCHES amd64)
21 list(APPEND FREELDR_STARTUP_SOURCE
22 arch/i386/fathelp.S
23 arch/amd64/arch.S)
24 endif()
25
26 if(ARCH MATCHES i386)
27 if(NOT MSVC)
28 list(APPEND FREELDR_BASE64K_SOURCE
29 arch/i386/boot.S
30 arch/i386/drvmap.S
31 arch/i386/i386cpu.S
32 arch/i386/i386idt.S
33 arch/i386/i386pnp.S
34 arch/i386/i386pxe.S
35 arch/i386/i386trap.S
36 arch/i386/int386.S
37 arch/i386/linux.S
38 arch/i386/mb.S
39 arch/i386/i386bug.c)
40 endif()
41 elseif(ARCH MATCHES amd64)
42 list(APPEND FREELDR_BASE64K_SOURCE
43 arch/i386/drvmap.S
44 arch/i386/i386cpu.S
45 arch/i386/i386idt.S
46 arch/i386/i386trap.S
47 arch/amd64/mb.S)
48 endif()
49
50 set_source_files_properties(${FREELDR_BASE64K_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_")
51
52 include_directories(${REACTOS_SOURCE_DIR}/lib/cmlib)
53
54 list(APPEND FREELDR_BASE_SOURCE
55 arcemul/mm.c
56 arcemul/time.c
57 cache/blocklist.c
58 cache/cache.c
59 comm/rs232.c
60 disk/disk.c
61 disk/partition.c
62 disk/ramdisk.c
63 disk/scsiport.c
64 fs/ext2.c
65 fs/fat.c
66 fs/fs.c
67 fs/iso.c
68 fs/ntfs.c
69 fs/pxe.c
70 inifile/ini_init.c
71 inifile/inifile.c
72 inifile/parse.c
73 mm/meminit.c
74 mm/mm.c
75 reactos/registry.c
76 reactos/arcname.c
77 reactos/archwsup.c
78 reactos/binhive.c
79 reactos/reactos.c
80 reactos/imageldr.c
81 rtl/bget.c
82 rtl/libsupp.c
83 ui/directui.c
84 ui/gui.c
85 ui/minitui.c
86 ui/noui.c
87 ui/tui.c
88 ui/tuimenu.c
89 ui/ui.c
90 video/fade.c
91 video/palette.c
92 video/video.c
93 windows/conversion.c
94 windows/peloader.c
95 windows/winldr.c
96 windows/wlmemory.c
97 windows/wlregistry.c
98 freeldr.c
99 debug.c
100 version.c
101 cmdline.c
102 machine.c
103 options.c
104 linuxboot.c
105 oslist.c)
106
107 if(ARCH MATCHES i386)
108 list(APPEND FREELDR_BASE_SOURCE
109 windows/headless.c
110 disk/scsiport.c)
111 endif()
112
113 set_source_files_properties(${FREELDR_BASE_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
114
115 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/libs)
116 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/elf)
117
118 if(ARCH MATCHES i386)
119 list(APPEND FREELDR_ARCH_SOURCE
120 arch/i386/archmach.c
121 arch/i386/custom.c
122 arch/i386/drivemap.c
123 arch/i386/halstub.c
124 arch/i386/hardware.c
125 arch/i386/hwacpi.c
126 arch/i386/hwapm.c
127 arch/i386/hwpci.c
128 arch/i386/i386disk.c
129 arch/i386/i386rtl.c
130 arch/i386/i386vid.c
131 arch/i386/loader.c
132 arch/i386/machpc.c
133 arch/i386/miscboot.c
134 arch/i386/ntoskrnl.c
135 arch/i386/pccons.c
136 arch/i386/pcdisk.c
137 arch/i386/pcmem.c
138 arch/i386/pcrtc.c
139 arch/i386/pcvideo.c
140 arch/i386/machxbox.c
141 arch/i386/xboxcons.c
142 arch/i386/xboxdisk.c
143 arch/i386/xboxfont.c
144 arch/i386/xboxhw.c
145 arch/i386/xboxi2c.c
146 arch/i386/xboxmem.c
147 arch/i386/xboxrtc.c
148 arch/i386/xboxvideo.c
149 windows/i386/ntsetup.c
150 windows/i386/wlmemory.c)
151 else()
152 #TBD
153 endif()
154
155 set_source_files_properties(${FREELDR_ARCH_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_NTHAL_;_BLDR_;_NTSYSTEM_")
156 add_library(freeldr_arch ${FREELDR_ARCH_SOURCE})
157
158 list(APPEND FREELDR_SOURCE
159 bootmgr.c
160 ${FREELDR_STARTUP_SOURCE}
161 ${FREELDR_BASE64K_SOURCE}
162 ${FREELDR_BASE_SOURCE}
163 )
164
165 add_library(freeldr SHARED
166 ${CMAKE_CURRENT_BINARY_DIR}/freeldr_freeldr.h.gch
167 ${FREELDR_SOURCE})
168
169 if(NOT MSVC)
170 set_target_properties(freeldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys")
171 set_image_base(freeldr 0x8000)
172 else()
173 set_target_properties(freeldr PROPERTIES LINK_FLAGS "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION" SUFFIX ".sys")
174 set_image_base(freeldr 0x10000)
175 endif()
176
177 set_subsystem(freeldr native)
178 set_entrypoint(freeldr mainCRTStartup)
179
180 if(ARCH MATCHES i386)
181 target_link_libraries(freeldr mini_hal)
182 endif()
183
184 target_link_libraries(freeldr
185 freeldr_arch
186 cportlib
187 rossym
188 cmlib
189 rtl
190 libcntpr)
191
192 add_pch(freeldr ${CMAKE_CURRENT_SOURCE_DIR}/include/freeldr.h ${FREELDR_SOURCE})
193 add_dependencies(freeldr asm)
194
195 add_cd_file(TARGET freeldr DESTINATION loader NO_CAB FOR all)
196
197 list(APPEND SETUPLDR_MAIN_SOURCE
198 bootmgr.c
199 inffile/inffile.c
200 reactos/setupldr.c)
201
202 if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
203 list(APPEND SETUPLDR_MAIN_SOURCE windows/setupldr2.c)
204 endif()
205
206 if(NOT MSVC)
207 set_source_files_properties(${SETUPLDR_MAIN_SOURCE} PROPERTIES COMPILE_FLAGS "-ffreestanding -fno-builtin -fno-inline -fno-zero-initialized-in-bss")
208 endif()
209
210 list(APPEND SETUPLDR_SOURCE
211 ${FREELDR_STARTUP_SOURCE}
212 ${FREELDR_BASE64K_SOURCE}
213 ${FREELDR_BASE_SOURCE}
214 ${SETUPLDR_MAIN_SOURCE})
215
216 add_library(setupldr SHARED ${SETUPLDR_SOURCE})
217
218 if(NOT MSVC)
219 set_target_properties(setupldr PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
220 set_image_base(setupldr 0x8000)
221 else()
222 set_target_properties(setupldr PROPERTIES LINK_FLAGS "/DRIVER /SECTION:.text,ERWP,ALIGN=0x1000" SUFFIX ".sys" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
223 endif()
224
225 set_subsystem(setupldr native)
226 set_entrypoint(setupldr mainCRTStartup)
227
228 if(ARCH MATCHES i386)
229 target_link_libraries(setupldr mini_hal)
230 endif()
231
232 target_link_libraries(setupldr
233 freeldr_arch
234 cportlib
235 rossym
236 cmlib
237 rtl
238 libcntpr)
239
240 add_dependencies(setupldr asm)
241
242 add_cd_file(TARGET setupldr DESTINATION loader NO_CAB FOR all)
243