Skip to content

Commit

Permalink
Merge pull request #160 from eseiler/infra/google
Browse files Browse the repository at this point in the history
[INFRA] google
  • Loading branch information
eseiler authored Nov 7, 2022
2 parents 7dbb31f + b37a03a commit cb091a9
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ If you are working in the field of sequence analysis, we recommend using the

An application with one option parsing an integer from the command line can be written in only 5 lines of code:

<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./test/snippet/readme_sneak_peek.cpp&lines=3-13) -->
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=./test/snippet/readme_sneak_peek.cpp&lines=3-15) -->
<!-- The below code snippet is automatically added from ./test/snippet/readme_sneak_peek.cpp -->
```cpp
#include <sharg/all.hpp>
Expand Down
4 changes: 2 additions & 2 deletions include/sharg/detail/format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class format_help_base : public format_base
format_help_base(std::vector<std::string> const & names,
update_notifications const version_updates,
bool const advanced) :
version_check_dev_decision{version_updates},
command_names{names},
show_advanced_options{advanced},
version_check_dev_decision{version_updates}
show_advanced_options{advanced}
{}
//!\}

Expand Down
37 changes: 22 additions & 15 deletions test/cmake/sharg_require_benchmark.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,35 @@

cmake_minimum_required (VERSION 3.16)

# Exposes the google-benchmark target `gbenchmark`.
# Exposes the google-benchmark target `benchmark` and `benchmark_main`.
# CMake 3.24: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE
macro (sharg_require_benchmark)
enable_testing ()

set (gbenchmark_git_tag "v1.7.0")
set (benchmark_version "1.7.0")
set (gbenchmark_git_tag "v${benchmark_version}")

message (STATUS "Fetch Google Benchmark:")
find_package (benchmark ${benchmark_version} EXACT QUIET)

include (FetchContent)
FetchContent_Declare (
gbenchmark_fetch_content
GIT_REPOSITORY "https://github.com/google/benchmark.git"
GIT_TAG "${gbenchmark_git_tag}")
option (BENCHMARK_ENABLE_TESTING "" OFF)
option (BENCHMARK_ENABLE_WERROR "" OFF) # Does not apply to Debug builds.
FetchContent_MakeAvailable (gbenchmark_fetch_content)
if (NOT benchmark_FOUND)
message (STATUS "Fetching Google Benchmark ${benchmark_version}")

# NOTE: google benchmark's CMakeLists.txt already defines Shlwapi
add_library (gbenchmark ALIAS benchmark_main)
include (FetchContent)
FetchContent_Declare (
gbenchmark_fetch_content
GIT_REPOSITORY "https://github.com/google/benchmark.git"
GIT_TAG "${gbenchmark_git_tag}")
option (BENCHMARK_ENABLE_TESTING "" OFF)
option (BENCHMARK_ENABLE_WERROR "" OFF) # Does not apply to Debug builds.
option (BENCHMARK_ENABLE_INSTALL "" OFF)
FetchContent_MakeAvailable (gbenchmark_fetch_content)
else ()
message (STATUS "Found Google Benchmark ${benchmark_version}")
endif ()

# NOTE: google benchmark's CMakeLists.txt already defines Shlwapi
if (NOT TARGET gbenchmark_build)
add_custom_target (gbenchmark_build DEPENDS gbenchmark)
target_compile_options ("benchmark_main" PUBLIC "-w")
add_custom_target (gbenchmark_build DEPENDS benchmark_main benchmark)
endif ()

endmacro ()
30 changes: 19 additions & 11 deletions test/cmake/sharg_require_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,32 @@
cmake_minimum_required (VERSION 3.16)

# Exposes the google-test targets `gtest` and `gtest_main`.
# CMake 3.24: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE
macro (sharg_require_test)
enable_testing ()

set (gtest_git_tag "release-1.12.1")
set (gtest_version "1.12.1")
set (gtest_git_tag "release-${gtest_version}")

message (STATUS "Fetch Google Test:")
find_package (GTest ${gtest_version} EXACT QUIET)

include (FetchContent)
FetchContent_Declare (
gtest_fetch_content
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG "${gtest_git_tag}")
option (BUILD_GMOCK "" OFF)
FetchContent_MakeAvailable (gtest_fetch_content)
if (NOT GTest_FOUND)
message (STATUS "Fetching Google Test ${gtest_version}")

include (FetchContent)
FetchContent_Declare (
gtest_fetch_content
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG "${gtest_git_tag}")
option (BUILD_GMOCK "" OFF)
option (INSTALL_GTEST "" OFF)
FetchContent_MakeAvailable (gtest_fetch_content)
else ()
message (STATUS "Found Google Test ${gtest_version}")
endif ()

if (NOT TARGET gtest_build)
add_custom_target (gtest_build DEPENDS gtest_main gtest)
target_compile_options ("gtest_main" PUBLIC "-w")
target_compile_options ("gtest" PUBLIC "-w")
endif ()

endmacro ()
2 changes: 1 addition & 1 deletion test/sharg-test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif ()
# needed for performance test cases in sharg/test/performance
if (NOT TARGET sharg::test::performance)
add_library (sharg_test_performance INTERFACE)
target_link_libraries (sharg_test_performance INTERFACE "sharg::test" "gbenchmark")
target_link_libraries (sharg_test_performance INTERFACE "sharg::test" "benchmark_main" "benchmark")

add_library (sharg::test::performance ALIAS sharg_test_performance)
endif ()
Expand Down
11 changes: 7 additions & 4 deletions test/snippet/readme_sneak_peek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ int main(int argc, char ** argv)
parser.add_subsection("Eating Numbers");
parser.add_option(val, sharg::config{.short_id = 'i', .long_id = "int", .description = "Desc."});
parser.parse();

return 0;
}

#undef main

int main(int argc, char ** argv)
int main()
{
char * test_argv[] = {"./Eat-Me-App", "-h"};
int const test_argc = sizeof(test_argv) / sizeof(*test_argv);
return test(test_argc, test_argv);
std::string argv1{"./Eat-Me-App"}, argv2{"-h"};
std::array argv{argv1.data(), argv2.data()};

return test(argv.size(), argv.data());
}

1 comment on commit cb091a9

@vercel
Copy link

@vercel vercel bot commented on cb091a9 Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sharg-parser – ./

sharg-100.vercel.app
sharg-parser-seqan.vercel.app
sharg.vercel.app
sharg-parser-git-main-seqan.vercel.app

Please sign in to comment.