[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / libc / test / integration / startup / CMakeLists.txt
blobfb5d6bc787cc26163f682d19374f7ca1f432924d
1 # A rule to add startup system tests. When we have a complete startup system,
2 # we should be able to use the add_libc_unittest rule or an extension of it.
3 # But, while the system is being developed,  we need to use a special rule like
4 # this.
5 function(add_startup_test target_name)
6   if(NOT CMAKE_HOST_UNIX)
7     message(
8         WARNING
9         "Test for the startup system currently assume a POSIX/Unix like "
10         "environment and may not work on your platform.")
11   endif()
13   cmake_parse_arguments(
14     "ADD_STARTUP_TEST"
15     ""    # No option arguments
16     "SRC" # Single value arguments
17     "DEPENDS;ARGS;ENV" # Multivalue arguments.
18     ${ARGN}
19   )
21   get_fq_target_name(${target_name} fq_target_name)
22   add_executable(
23     ${fq_target_name}
24     EXCLUDE_FROM_ALL
25     ${ADD_STARTUP_TEST_SRC}
26   )
28   set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
30   target_include_directories(
31     ${fq_target_name}
32     PRIVATE
33       ${LIBC_SOURCE_DIR}
34       ${LIBC_BUILD_DIR}
35       ${LIBC_BUILD_DIR}/include
36   )
38   if(ADD_STARTUP_TEST_DEPENDS)
39     get_fq_deps_list(fq_deps_list ${ADD_STARTUP_TEST_DEPENDS})
40     add_dependencies(${fq_target_name} ${fq_deps_list})
41     get_object_files_for_test(link_object_files has_skipped_entrypoint_list ${fq_deps_list})
42     target_link_libraries(${fq_target_name} ${link_object_files})
43   endif()
45   target_link_options(
46     ${fq_target_name}
47     BEFORE PRIVATE
48     -nostdlib
49   )
51   add_custom_command(
52     TARGET ${fq_target_name}
53     POST_BUILD
54     COMMAND ${ADD_STARTUP_TEST_ENV} $<TARGET_FILE:${fq_target_name}> ${ADD_STARTUP_TEST_ARGS}
55   )
57   add_dependencies(libc_startup_tests ${fq_target_name})
58 endfunction(add_startup_test)
60 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
61   add_subdirectory(${LIBC_TARGET_OS})
62 endif()