Debian Codegraph @

llvm-project/llvm/unittests/Support/CommandLineInit/CMakeLists.txt

raw
1 set(test_name CommandLineInitTests)
2 set(test_suite UnitTests)
3
4 # We don't call add_llvm_unittest() here, because the function automatically
5 # links the test against TestMain.cpp, in which main() function calls
6 # llvm::cl::ParseCommandLineOptions, and it makes the test always pass.
7 # The following code mainly comes from `add_unittest` in
8 # llvm/cmake/modules/AddLLVM.cmake, except that gtest_main is excluded from
9 # target_link_libraries to prevent the test linking against TestMain.cpp.
10
11 if (NOT LLVM_BUILD_TESTS)
12 set(EXCLUDE_FROM_ALL ON)
13 endif()
14
15 if (SUPPORTS_VARIADIC_MACROS_FLAG)
16 list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
17 endif ()
18 # Some parts of gtest rely on this GNU extension, don't warn on it.
19 if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG)
20 list(APPEND LLVM_COMPILE_FLAGS "-Wno-gnu-zero-variadic-macro-arguments")
21 endif()
22
23 list(APPEND LLVM_LINK_COMPONENTS Support)
24
25 add_llvm_executable(${test_name}
26 IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH
27 CommandLineInitTest.cpp)
28
29 target_link_libraries(${test_name} PRIVATE llvm_gtest)
30
31 add_dependencies(${test_suite} ${test_name})
32
33 set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
34 set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
35
36 get_target_property(test_suite_folder ${test_suite} FOLDER)
37 if (test_suite_folder)
38 set_property(TARGET ${test_name} PROPERTY FOLDER "${test_suite_folder}")
39 endif ()