[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / libc / src / stdio / CMakeLists.txt
blob380474ce271180448debc38d5c077f86f38e9f93
1 # Helper function that creates an alias if a target specific implementation
2 # exists, otherwise it uses a generic one.
3 function(add_stdio_entrypoint_object name)
4   if(TARGET libc.src.stdio.${LIBC_TARGET_OS}.${name})
5     add_entrypoint_object(
6       ${name}
7       ALIAS
8       DEPENDS
9         .${LIBC_TARGET_OS}.${name}
10     )
11   elseif(TARGET libc.src.stdio.generic.${name})
12     add_entrypoint_object(
13       ${name}
14       ALIAS
15       DEPENDS
16         .generic.${name}
17     )
18   endif()
19 endfunction(add_stdio_entrypoint_object)
21 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
22   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
23 endif()
25 if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
26   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generic)
27 endif()
29 if(NOT LLVM_LIBC_FULL_BUILD)
30   list(APPEND use_system_file "COMPILE_OPTIONS" "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
31 endif()
33 add_entrypoint_object(
34   flockfile
35   SRCS
36     flockfile.cpp
37   HDRS
38     flockfile.h
39   DEPENDS
40     libc.include.stdio
41     libc.src.__support.File.file
42     libc.src.__support.File.platform_file
45 add_entrypoint_object(
46   funlockfile
47   SRCS
48     funlockfile.cpp
49   HDRS
50     funlockfile.h
51   DEPENDS
52     libc.include.stdio
53     libc.src.__support.File.file
54     libc.src.__support.File.platform_file
57 add_entrypoint_object(
58   fopencookie
59   SRCS
60     fopencookie.cpp
61   HDRS
62     fopencookie.h
63   DEPENDS
64     libc.include.stdio
65     libc.src.__support.CPP.new
66     libc.src.__support.File.file
69 add_entrypoint_object(
70   setbuf
71   SRCS
72     setbuf.cpp
73   HDRS
74     setbuf.h
75   DEPENDS
76     libc.src.errno.errno
77     libc.include.stdio
78     libc.src.__support.File.file
79     libc.src.__support.File.platform_file
82 add_entrypoint_object(
83   setvbuf
84   SRCS
85     setvbuf.cpp
86   HDRS
87     setvbuf.h
88   DEPENDS
89     libc.src.errno.errno
90     libc.include.stdio
91     libc.src.__support.File.file
92     libc.src.__support.File.platform_file
95 list(APPEND scanf_deps
96       libc.src.__support.arg_list
97       libc.src.stdio.scanf_core.vfscanf_internal
100 if(LLVM_LIBC_FULL_BUILD)
101   list(APPEND scanf_deps
102       libc.src.__support.File.file
103       libc.src.__support.File.platform_file
104       libc.src.__support.File.platform_stdin
105   )
106 endif()
108 add_entrypoint_object(
109   sscanf
110   SRCS
111     sscanf.cpp
112   HDRS
113     sscanf.h
114   DEPENDS
115     libc.src.__support.arg_list
116     libc.src.stdio.scanf_core.reader
117     libc.src.stdio.scanf_core.scanf_main
120 add_entrypoint_object(
121   fscanf
122   SRCS
123     fscanf.cpp
124   HDRS
125     fscanf.h
126   DEPENDS
127     ${scanf_deps}
130 add_entrypoint_object(
131   scanf
132   SRCS
133     scanf.cpp
134   HDRS
135     scanf.h
136   DEPENDS
137     ${scanf_deps}
140 add_entrypoint_object(
141   sprintf
142   SRCS
143     sprintf.cpp
144   HDRS
145     sprintf.h
146   DEPENDS
147     libc.src.stdio.printf_core.printf_main
148     libc.src.stdio.printf_core.writer
151 add_entrypoint_object(
152   snprintf
153   SRCS
154     snprintf.cpp
155   HDRS
156     snprintf.h
157   DEPENDS
158     libc.src.stdio.printf_core.printf_main
159     libc.src.stdio.printf_core.writer
162 list(APPEND printf_deps
163       libc.src.__support.arg_list
164       libc.src.stdio.printf_core.vfprintf_internal
167 if(LLVM_LIBC_FULL_BUILD)
168   list(APPEND printf_deps
169       libc.src.__support.File.file
170       libc.src.__support.File.platform_file
171       libc.src.__support.File.platform_stdout
172   )
173 endif()
175 add_entrypoint_object(
176   printf
177   SRCS
178     printf.cpp
179   HDRS
180     printf.h
181   DEPENDS
182     ${printf_deps}
185 add_entrypoint_object(
186   fprintf
187   SRCS
188     fprintf.cpp
189   HDRS
190     fprintf.h
191   DEPENDS
192     libc.src.__support.arg_list
193     libc.src.stdio.printf_core.vfprintf_internal
196 add_entrypoint_object(
197   vsprintf
198   SRCS
199     vsprintf.cpp
200   HDRS
201     vsprintf.h
202   DEPENDS
203     libc.src.stdio.printf_core.printf_main
204     libc.src.stdio.printf_core.writer
207 add_entrypoint_object(
208   vsnprintf
209   SRCS
210     vsnprintf.cpp
211   HDRS
212     vsnprintf.h
213   DEPENDS
214     libc.src.stdio.printf_core.printf_main
215     libc.src.stdio.printf_core.writer
218 add_entrypoint_object(
219   vprintf
220   SRCS
221     vprintf.cpp
222   HDRS
223     vprintf.h
224   DEPENDS
225     ${printf_deps}
228 add_entrypoint_object(
229   vfprintf
230   SRCS
231     vfprintf.cpp
232   HDRS
233     vfprintf.h
234   DEPENDS
235     libc.src.__support.arg_list
236     libc.src.stdio.printf_core.vfprintf_internal
239 add_subdirectory(printf_core)
240 add_subdirectory(scanf_core)
242 add_entrypoint_object(
243   remove
244   ALIAS
245   DEPENDS
246     .${LIBC_TARGET_OS}.remove
249 # These entrypoints have multiple potential implementations.
250 add_stdio_entrypoint_object(feof)
251 add_stdio_entrypoint_object(feof_unlocked)
252 add_stdio_entrypoint_object(ferror)
253 add_stdio_entrypoint_object(ferror_unlocked)
254 add_stdio_entrypoint_object(fseek)
255 add_stdio_entrypoint_object(ftell)
256 add_stdio_entrypoint_object(fflush)
257 add_stdio_entrypoint_object(clearerr)
258 add_stdio_entrypoint_object(clearerr_unlocked)
259 add_stdio_entrypoint_object(fopen)
260 add_stdio_entrypoint_object(fclose)
261 add_stdio_entrypoint_object(fread_unlocked)
262 add_stdio_entrypoint_object(fread)
263 add_stdio_entrypoint_object(puts)
264 add_stdio_entrypoint_object(fputs)
265 add_stdio_entrypoint_object(fwrite_unlocked)
266 add_stdio_entrypoint_object(fwrite)
267 add_stdio_entrypoint_object(fputc)
268 add_stdio_entrypoint_object(putc)
269 add_stdio_entrypoint_object(putchar)
270 add_stdio_entrypoint_object(fgetc)
271 add_stdio_entrypoint_object(fgetc_unlocked)
272 add_stdio_entrypoint_object(getc)
273 add_stdio_entrypoint_object(getc_unlocked)
274 add_stdio_entrypoint_object(getchar)
275 add_stdio_entrypoint_object(getchar_unlocked)
276 add_stdio_entrypoint_object(fgets)
277 add_stdio_entrypoint_object(ungetc)
278 add_stdio_entrypoint_object(stdin)
279 add_stdio_entrypoint_object(stdout)
280 add_stdio_entrypoint_object(stderr)