vmtester: Use CLI11 instead of boost::program_options

This commit is contained in:
Paweł Bylica 2018-07-05 15:05:20 +02:00
parent 8331ca15de
commit 18a96c8d04
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
3 changed files with 9 additions and 30 deletions

View File

@ -6,6 +6,6 @@
# Hunter is going to be initialized only if building with tests, # Hunter is going to be initialized only if building with tests,
# where it is needed to get dependencies. # where it is needed to get dependencies.
HunterGate( HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.20.37.tar.gz" URL "https://github.com/ruslo/hunter/archive/v0.22.23.tar.gz"
SHA1 "51886d10428c924cc21756abc17623bcf4986386" SHA1 "16c562a69489ff9c1b5266a12d5e903084de693a"
) )

View File

@ -4,8 +4,8 @@
include(GNUInstallDirs) include(GNUInstallDirs)
hunter_add_package(Boost COMPONENTS program_options) hunter_add_package(CLI11)
find_package(Boost CONFIG REQUIRED program_options) find_package(CLI11)
add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp) add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp)
set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
@ -16,7 +16,7 @@ target_link_libraries(
evmc evmc
loader loader
GTest::gtest GTest::gtest
Boost::program_options CLI11::CLI11
) )
install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@ -6,13 +6,11 @@
#include <evmc/loader.h> #include <evmc/loader.h>
#include <boost/program_options.hpp> #include <CLI/CLI.hpp>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
namespace opts = boost::program_options;
namespace namespace
{ {
evmc_create_fn create_fn; evmc_create_fn create_fn;
@ -36,29 +34,10 @@ int main(int argc, char* argv[])
{ {
std::string vm_path; std::string vm_path;
opts::options_description desc("EVMC VM Tester Options"); CLI::App app{"EVMC VM Tester"};
auto add_option = desc.add_options(); app.add_option("vm", vm_path, "Path to the VM shared library to be tested");
add_option("help", "Show help message");
add_option("vm", opts::value(&vm_path)->value_name("path")->required(),
"Path to the VM shared library to be tested");
opts::positional_options_description positional;
positional.add("vm", 1);
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
CLI11_PARSE(app, argc, argv);
opts::variables_map variables_map;
opts::store(
opts::command_line_parser(argc, argv).options(desc).positional(positional).run(),
variables_map);
if (variables_map.count("help"))
{
std::cout << "\n" << desc << "\n";
return 0;
}
opts::notify(variables_map);
std::cout << "Testing " << vm_path << "\n"; std::cout << "Testing " << vm_path << "\n";
evmc_loader_error_code ec; evmc_loader_error_code ec;