From c67fd74037212128a87858aedf6f5913bd77e550 Mon Sep 17 00:00:00 2001 From: smehringer Date: Mon, 27 Jun 2022 13:15:20 +0200 Subject: [PATCH] [FEATURE] Add sharg-parser submodule. --- .gitmodules | 3 +++ build_system/seqan3-config.cmake | 43 ++++++++++++++++++++++++++++++++ submodules/sharg-parser | 1 + 3 files changed, 47 insertions(+) create mode 160000 submodules/sharg-parser diff --git a/.gitmodules b/.gitmodules index 9b5fdeae86..9817630aaf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "cereal"] path = submodules/cereal url = https://github.com/USCiLab/cereal +[submodule "submodules/sharg-parser"] + path = submodules/sharg-parser + url = https://github.com/seqan/sharg-parser.git diff --git a/build_system/seqan3-config.cmake b/build_system/seqan3-config.cmake index 86ae5bc450..de762153ae 100644 --- a/build_system/seqan3-config.cmake +++ b/build_system/seqan3-config.cmake @@ -26,6 +26,7 @@ # # SeqAn has the following optional dependencies: # +# Sharg -- Argument Parsing # ZLIB -- zlib compression library # BZip2 -- libbz2 compression library # Cereal -- Serialisation library @@ -36,6 +37,7 @@ # # If you wish to require the presence of ZLIB or BZip2, just check for the module before # finding SeqAn3, e.g. "find_package (ZLIB REQUIRED)". +# If you wish to require the presence of SHARG, you may define SEQAN3_SHARG. # If you wish to require the presence of CEREAL, you may define SEQAN3_CEREAL. # If you wish to require the presence of LEMON, you may define SEQAN3_LEMON. # @@ -168,6 +170,25 @@ set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) # Force-deactivate optional dependencies # ---------------------------------------------------------------------------- +# Sharg is auto-detected by default, i.e. used if found, not used if not found. +# You can optionally set a hard requirement so a build fails without Sharg, +# or you can force-disable Sharg even if present on the system. +option (SEQAN3_SHARG "Require Sharg and fail if not present." OFF) +option (SEQAN3_NO_SHARG "Don't use Sharg, even if present." OFF) + +if (SEQAN3_SHARG AND SEQAN3_NO_SHARG) + # this is always a user error, therefore we always error-out, even if SeqAn is not required + message (FATAL_ERROR "You may not specify SEQAN3_SHARG and SEQAN3_NO_SHARG at the same time.\n\ + You can specify neither (use auto-detection), or specify either to force on/off.") + return () +endif () + +if (SEQAN3_SHARG) + set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_WITH_SHARG=1") +elseif (SEQAN3_NO_SHARG) + set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_WITH_SHARG=0") +endif () + # Cereal is auto-detected by default, i.e. used if found, not used if not found. # You can optionally set a hard requirement so a build fails without cereal, # or you can force-disable cereal even if present on the system. @@ -320,6 +341,28 @@ else () "The SDSL library is required, but wasn't found. Get it from https://github.com/xxsds/sdsl-lite") endif () +# ---------------------------------------------------------------------------- +# Sharg dependency is optional, but may set as required +# ---------------------------------------------------------------------------- + +if (NOT SEQAN3_NO_SHARG) + check_include_file_cxx (sharg/version.hpp _SEQAN3_HAVE_SHARG) + + if (_SEQAN3_HAVE_SHARG) + if (SEQAN3_SHARG) + seqan3_config_print ("Required dependency: Sharg found.") + else () + seqan3_config_print ("Optional dependency: Sharg found.") + endif () + else () + if (SEQAN3_SHARG) + seqan3_config_error ("The (optional) Sharg library was marked as required, but wasn't found.") + else () + seqan3_config_print ("Optional dependency: Sharg not found.") + endif () + endif () +endif () + # ---------------------------------------------------------------------------- # Cereal dependency is optional, but may set as required # ---------------------------------------------------------------------------- diff --git a/submodules/sharg-parser b/submodules/sharg-parser new file mode 160000 index 0000000000..1cbbe5adfc --- /dev/null +++ b/submodules/sharg-parser @@ -0,0 +1 @@ +Subproject commit 1cbbe5adfce06632e26803029cae0ba7b3f149b7