1 set(test_name CommandLineInitTests)
2 set(test_suite UnitTests)
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.
11 if (NOT LLVM_BUILD_TESTS)
12 set(EXCLUDE_FROM_ALL ON)
15 if (SUPPORTS_VARIADIC_MACROS_FLAG)
16 list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros")
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")
23 list(APPEND LLVM_LINK_COMPONENTS Support)
25 add_llvm_executable(${test_name}
26 IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH
27 CommandLineInitTest.cpp)
29 target_link_libraries(${test_name} PRIVATE llvm_gtest)
31 add_dependencies(${test_suite} ${test_name})
33 set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
34 set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})