mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
The help and version arguments are still included by default, but which default arguments to include can be overridden at ArgumentParser creation. argparse generally copies Python argparse behavior. This includes a default `--help`/`-h` argument to print a help message and exit. Some developers using argparse find the automatic exit to be undesirable. The Python argparse has an opt-out parameter when constructing an ArgumentParser. Using `add_help=False` avoids adding a default `--help` argument and allows the developer to implement a custom help. This commit adds a similar opt-out to our C++ argparse, but keeps the current behavior as the default. The `--help`/`-h` and `--version`/`-v` Arguments handle their own output and exit rather than specially treating them in ArgumentParser::parse_args_internal. Closes #119 Closes #138 Closes #139 Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
60 lines
1.6 KiB
CMake
60 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.6)
|
|
project(argparse)
|
|
|
|
if(MSVC)
|
|
# Force to always compile with W4
|
|
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
else()
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
|
endif()
|
|
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
|
# Update if necessary
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
|
|
endif()
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# Disable deprecation for windows
|
|
if (WIN32)
|
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
|
endif()
|
|
|
|
# ARGPARSE executable
|
|
file(GLOB ARGPARSE_TEST_SOURCES
|
|
main.cpp
|
|
test_actions.cpp
|
|
test_append.cpp
|
|
test_compound_arguments.cpp
|
|
test_container_arguments.cpp
|
|
test_const_correct.cpp
|
|
test_default_args.cpp
|
|
test_get.cpp
|
|
test_help.cpp
|
|
test_invalid_arguments.cpp
|
|
test_is_used.cpp
|
|
test_issue_37.cpp
|
|
test_negative_numbers.cpp
|
|
test_optional_arguments.cpp
|
|
test_parent_parsers.cpp
|
|
test_parse_args.cpp
|
|
test_positional_arguments.cpp
|
|
test_repr.cpp
|
|
test_required_arguments.cpp
|
|
test_scan.cpp
|
|
test_value_semantics.cpp
|
|
test_version.cpp
|
|
)
|
|
set_source_files_properties(main.cpp
|
|
PROPERTIES
|
|
COMPILE_DEFINITIONS DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN)
|
|
ADD_EXECUTABLE(ARGPARSE ${ARGPARSE_TEST_SOURCES})
|
|
INCLUDE_DIRECTORIES("../include" ".")
|
|
set_target_properties(ARGPARSE PROPERTIES OUTPUT_NAME tests)
|
|
set_property(TARGET ARGPARSE PROPERTY CXX_STANDARD 17)
|
|
|
|
# Set ${PROJECT_NAME} as the startup project
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ARGPARSE)
|