[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / startup / gpu / CMakeLists.txt
blob33afe1ef3f836ce3711064e0398a0f3a62a5b662
1 function(add_startup_object name)
2   cmake_parse_arguments(
3     "ADD_STARTUP_OBJECT"
4     "ALIAS" # Option argument
5     "SRC"   # Single value arguments
6     "DEPENDS;COMPILE_OPTIONS" # Multi value arguments
7     ${ARGN}
8   )
10   get_fq_target_name(${name} fq_target_name)
11   if(ADD_STARTUP_OBJECT_ALIAS)
12     get_fq_deps_list(fq_dep_list ${ADD_STARTUP_OBJECT_DEPENDS})
13     add_library(${fq_target_name} ALIAS ${fq_dep_list})
14     return()
15   endif()
17   add_object_library(
18     ${name}
19     SRCS ${ADD_STARTUP_OBJECT_SRC}
20     DEPENDS ${ADD_STARTUP_OBJECT_DEPENDS}
21     COMPILE_OPTIONS ${ADD_STARTUP_OBJECT_COMPILE_OPTIONS}
22   )
23   set_target_properties(
24     ${fq_target_name}
25     PROPERTIES
26       OUTPUT_NAME ${name}.o
27   )
28 endfunction()
30 if(LIBC_GPU_TARGET_ARCHITECTURE_IS_AMDGPU)
31   add_subdirectory(amdgpu)
33   add_startup_object(
34     crt1
35     ALIAS
36     DEPENDS
37       .amdgpu.crt1
38   )
39 elseif(LIBC_GPU_TARGET_ARCHITECTURE_IS_NVPTX)
40   add_subdirectory(nvptx)
42   add_startup_object(
43     crt1
44     ALIAS
45     DEPENDS
46       .nvptx.crt1
47   )
48 else()
49   # Skip building the startup code if there are no supported GPUs.
50   message(STATUS "Skipping startup for gpu target, no GPUs were detected")
51   return()
52 endif()
54 add_custom_target(libc-startup)
55 set(startup_components crt1)
56 foreach(target IN LISTS startup_components)
57   set(fq_target_name libc.startup.gpu.${target})
58   add_dependencies(libc-startup ${fq_target_name})
59   install(FILES $<TARGET_OBJECTS:${fq_target_name}>
60           DESTINATION ${CMAKE_INSTALL_LIBDIR}
61           RENAME $<TARGET_PROPERTY:${fq_target_name},OUTPUT_NAME>
62           COMPONENT libc)
63 endforeach()