[Workflow] Roll back some settings since they caused more issues
[llvm-project.git] / libc / startup / linux / CMakeLists.txt
blob007aa30c17d6abea747a96c238e5da9e7a43b872
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(NOT (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE}))
31   message(STATUS "Skipping startup for target architecture ${LIBC_TARGET_ARCHITECTURE}")
32   return()
33 endif()
35 add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
37 add_startup_object(
38   crt1
39   ALIAS
40   DEPENDS
41     .${LIBC_TARGET_ARCHITECTURE}.crt1
44 add_startup_object(
45   crti
46   SRC
47     crti.cpp
50 add_startup_object(
51   crtn
52   SRC
53     crtn.cpp
56 add_custom_target(libc-startup)
57 set(startup_components crt1 crti crtn)
58 foreach(target IN LISTS startup_components)
59   set(fq_target_name libc.startup.linux.${target})
60   add_dependencies(libc-startup ${fq_target_name})
61   install(FILES $<TARGET_OBJECTS:${fq_target_name}>
62           DESTINATION ${CMAKE_INSTALL_LIBDIR}
63           RENAME $<TARGET_PROPERTY:${fq_target_name},OUTPUT_NAME>
64           COMPONENT libc)
65 endforeach()