Verified Commit 9266d5db authored by nagayama15's avatar nagayama15

build: import tanakh/cmdline

parent fc366fb6
......@@ -22,6 +22,7 @@ find_package(Threads)
include(ExternalProject)
include(cmake/boost.cmake)
include(cmake/binaryen.cmake)
include(cmake/cmdline.cmake)
include(cmake/fmt.cmake)
include(cmake/googletest.cmake)
......
ExternalProject_Add(cmdline
GIT_REPOSITORY "https://github.com/tanakh/cmdline.git"
GIT_TAG "master"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/cmdline"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmdline/src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmdline/build"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmdline/stamp"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
ExternalProject_Get_Property(cmdline source_dir)
ExternalProject_Get_Property(cmdline binary_dir)
add_library(cmdline::cmdline INTERFACE IMPORTED)
make_directory("${source_dir}") # To suppress non-exist directory warnings
target_include_directories(cmdline::cmdline INTERFACE
"${source_dir}"
)
add_dependencies(cmdline::cmdline cmdline)
add_executable(snpi snpi.cpp)
add_executable(snpi
snpi.cpp
)
target_link_libraries(snpi
cmdline::cmdline
fmtlib::fmt
)
add_executable(pisn
pisn.cpp
)
target_link_libraries(pisn
cmdline::cmdline
fmtlib::fmt
)
#include <fmt/printf.h>
#include "cmdline.h"
namespace {
const std::string program_name = "pisn";
const std::string version = "0.1.0";
} // namespace
int main(int argc, char* argv[]) {
cmdline::parser options{};
options.add("help", 'h', "Print help message");
options.add("version", 'v', "Print version");
options.add<std::string>("method", 'm', "Embedding method (function-ordering)", true, "", cmdline::oneof<std::string>("function-ordering"));
options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20));
options.set_program_name(program_name);
options.footer("filename");
// Parse command line arguments.
// Exit the program if help flag is specified or arguments are invalid.
options.parse_check(argc, argv);
if (options.exist("version")) {
// Show the program version.
fmt::print("{} v{}\n", program_name, version);
std::exit(EXIT_SUCCESS);
}
if (options.rest().empty()) {
// No input file specified.
fmt::print(std::cerr, "no input file\n");
fmt::print(std::cerr, "{}", options.usage());
std::exit(EXIT_FAILURE);
}
const auto input = options.rest()[0];
const auto method = options.get<std::string>("method");
const auto chunk_size = options.get<std::size_t>("chunk-size");
(void)chunk_size;
}
#include <iostream>
#include <fmt/printf.h>
#include "cmdline.h"
int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) {
std::cout << "snpi" << std::endl;
namespace {
const std::string program_name = "snpi";
const std::string version = "0.1.0";
} // namespace
int main(int argc, char* argv[]) {
cmdline::parser options{};
options.add("help", 'h', "Print help message");
options.add("version", 'v', "Print version");
options.add<std::string>("output", 'o', "Output filename", true);
options.add<std::string>("method", 'm', "Embedding method (function-ordering)", true, "", cmdline::oneof<std::string>("function-ordering"));
options.add<std::size_t>("chunk-size", 'c', "Chunk size [2~20]", false, 20, cmdline::range<std::size_t>(2, 20));
options.set_program_name(program_name);
options.footer("filename");
// Parse command line arguments.
// Exit the program if help flag is specified or arguments are invalid.
options.parse_check(argc, argv);
if (options.exist("version")) {
// Show the program version.
fmt::print("{} v{}\n", program_name, version);
std::exit(EXIT_SUCCESS);
}
if (options.rest().empty()) {
// No input file specified.
fmt::print(std::cerr, "no input file\n");
fmt::print(std::cerr, "{}", options.usage());
std::exit(EXIT_FAILURE);
}
const auto input = options.rest()[0];
const auto output = options.get<std::string>("output");
const auto method = options.get<std::string>("method");
const auto chunk_size = options.get<std::size_t>("chunk-size");
(void)chunk_size;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment