1set(test_name CommandLineInitTests) 2set(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 11if (NOT LLVM_BUILD_TESTS) 12 set(EXCLUDE_FROM_ALL ON) 13endif() 14 15if (SUPPORTS_VARIADIC_MACROS_FLAG) 16 list(APPEND LLVM_COMPILE_FLAGS "-Wno-variadic-macros") 17endif () 18# Some parts of gtest rely on this GNU extension, don't warn on it. 19if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG) 20 list(APPEND LLVM_COMPILE_FLAGS "-Wno-gnu-zero-variadic-macro-arguments") 21endif() 22 23list(APPEND LLVM_LINK_COMPONENTS Support) 24 25add_llvm_executable(${test_name} 26 IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH 27 CommandLineInitTest.cpp) 28 29target_link_libraries(${test_name} PRIVATE llvm_gtest) 30 31add_dependencies(${test_suite} ${test_name}) 32 33set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) 34set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir}) 35 36