[AMDGPU] Add pseudo scalar trans instructions for GFX12 (#75204)
[llvm-project.git] / libcxx / test / CMakeLists.txt
blob48dd233462ab3b7a96a82ae74c2067f32fab0f6c
1 include(HandleLitArguments)
2 add_subdirectory(tools)
4 # By default, libcxx and libcxxabi share a library directory.
5 if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
6   set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
7       "The path to libc++abi library.")
8 endif()
10 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
11 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
13 if (LIBCXX_EXECUTOR)
14   message(DEPRECATION "LIBCXX_EXECUTOR is deprecated, please add executor=... to LIBCXX_TEST_PARAMS")
15   serialize_lit_string_param(SERIALIZED_LIT_PARAMS executor "${LIBCXX_EXECUTOR}")
16 endif()
18 if (NOT LIBCXX_ENABLE_EXCEPTIONS)
19   serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
20 endif()
22 if (NOT LIBCXX_ENABLE_RTTI)
23   serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
24 endif()
26 serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}")
28 if (CMAKE_CXX_COMPILER_TARGET)
29   serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
30 else()
31   serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
32 endif()
34 if (LLVM_USE_SANITIZER)
35   serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
36 endif()
38 serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
40 if (NOT DEFINED LIBCXX_TEST_DEPS)
41   message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
42 endif()
44 if (MSVC)
45   # Shared code for initializing some parameters used by all
46   # llvm-libc++-*-clangcl.cfg.in test configs.
47   set(dbg_include "")
49   if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
50     set(fms_runtime_lib "dll")
51     set(cxx_lib "msvcprt")
52   else()
53     set(fms_runtime_lib "static")
54     set(cxx_lib "libcpmt")
55   endif()
57   if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
58       OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
59     set(dbg_include " -include set_windows_crt_report_mode.h")
60     set(fms_runtime_lib "${fms_runtime_lib}_dbg")
61     set(cxx_lib "${cxx_lib}d")
62   endif()
64   serialize_lit_string_param(SERIALIZED_LIT_PARAMS dbg_include "${dbg_include}")
65   serialize_lit_string_param(SERIALIZED_LIT_PARAMS fms_runtime_lib "${fms_runtime_lib}")
66   serialize_lit_string_param(SERIALIZED_LIT_PARAMS cxx_lib "${cxx_lib}")
67 endif()
69 if (LIBCXX_INCLUDE_TESTS)
70   include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
72   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
73                  "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
74                  @ONLY)
76   configure_lit_site_cfg(
77     "${LIBCXX_TEST_CONFIG}"
78     ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
79     MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
81   add_custom_target(cxx-test-depends
82     DEPENDS cxx ${LIBCXX_TEST_DEPS}
83     COMMENT "Builds dependencies required to run the test suite.")
85   add_lit_testsuite(check-cxx
86     "Running libcxx tests"
87     ${CMAKE_CURRENT_BINARY_DIR}
88     DEPENDS cxx-test-depends)
90   if(LIBCXX_ENABLE_STD_MODULES)
91     # Generates the modules used in the test.
92     # Note the test will regenerate this with the proper setting
93     # - the right DCMAKE_CXX_STANDARD
94     # - the right test compilation flags
95     # Since modules depend on these flags there currently is no way to
96     # avoid generating these for the tests. The advantage of the
97     # pre generation is that less build information needs to be shared
98     # in the bridge.
99     add_custom_command(
100         OUTPUT "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
101         COMMAND
102         ${CMAKE_COMMAND}
103             "-G${CMAKE_GENERATOR}"
104             "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
105             "-B${CMAKE_BINARY_DIR}/test/__config_module__"
106             "-H${LIBCXX_GENERATED_MODULE_DIR}"
107             "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
108             "-DCMAKE_CXX_STANDARD=23"
109             "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
110             )
111   add_custom_target(generate-test-module-std
112       DEPENDS "${CMAKE_BINARY_DIR}/test/__config_module__/CMakeCache.txt"
113       COMMENT "Builds generic module std.")
114   endif()
115 endif()
117 if (LIBCXX_GENERATE_COVERAGE)
118   include(CodeCoverage)
119   set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
120   set(capture_dirs
121       "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
122       "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
123       "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
124       "${CMAKE_CURRENT_BINARY_DIR}")
125   set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
126   setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
127 endif()
129 if (LIBCXX_CONFIGURE_IDE)
130   # Create dummy targets for each of the tests in the test suite, this allows
131   # IDE's such as CLion to correctly highlight the tests because it knows
132   # roughly what include paths/compile flags/macro definitions are needed.
133   include_directories(support)
134   file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
135   file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
136   file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
137   add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
138           ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
139   add_dependencies(libcxx_test_objects cxx)
141   split_list(LIBCXX_COMPILE_FLAGS)
142   split_list(LIBCXX_LINK_FLAGS)
144   set_target_properties(libcxx_test_objects
145           PROPERTIES
146             COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
147             LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
148             EXCLUDE_FROM_ALL ON
149   )
150 endif()