Skip to content

Commit

Permalink
Merge pull request #2679 from eseiler/infra/rc_pack
Browse files Browse the repository at this point in the history
[INFRA] cpack: package an RC
  • Loading branch information
eseiler authored May 25, 2021
2 parents d84652d + daf888a commit 85d0057
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ list (APPEND CMAKE_MODULE_PATH "${SEQAN3_MODULE_PATH}")
include (seqan3-config-version)

if (CMAKE_VERSION VERSION_LESS 3.12)
project (seqan3 LANGUAGES CXX VERSION "${PACKAGE_VERSION}")
project (seqan3 LANGUAGES CXX VERSION "${SEQAN3_PROJECT_VERSION}")
else ()
project (
seqan3 LANGUAGES CXX VERSION "${PACKAGE_VERSION}"
seqan3 LANGUAGES CXX VERSION "${SEQAN3_PROJECT_VERSION}"
DESCRIPTION "SeqAn3 -- the modern C++ library for sequence analysis" # since cmake 3.9
HOMEPAGE_URL "https://github.com/seqan/seqan3" # since cmake 3.12
)
Expand Down
24 changes: 24 additions & 0 deletions build_system/seqan3-config-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ else()
endif()
endif()

# extract release candidate
file(STRINGS "${SEQAN3_INCLUDE_DIR}/seqan3/version.hpp" SEQAN3_RELEASE_CANDIDATE_HPP REGEX "#define SEQAN3_RELEASE_CANDIDATE ")
string(REGEX REPLACE "#define SEQAN3_RELEASE_CANDIDATE " "" SEQAN3_RELEASE_CANDIDATE_VERSION "${SEQAN3_RELEASE_CANDIDATE_HPP}")

# As of writing this (cmake 3.20):
# cmake does not allow to set a version containing a suffix via `project(... VERSION 3.0.3-rc.1)`.
# Version comparisons like VERSION_LESS, VERSION_GREATER do support comparing versions with a suffix (they just drop
# it), see https://cmake.org/cmake/help/latest/command/if.html#version-comparisons.
#
# If https://gitlab.kitware.com/cmake/cmake/-/issues/16716 is ever resolved, we can use SEQAN3_VERSION instead of
# SEQAN3_PROJECT_VERSION.
#
# SEQAN3_PROJECT_VERSION is intended to be used within `project (... VERSION "${SEQAN3_PROJECT_VERSION}")`.
set (SEQAN3_PROJECT_VERSION "${PACKAGE_VERSION}")
if (SEQAN3_RELEASE_CANDIDATE_VERSION VERSION_GREATER "0")
set (PACKAGE_VERSION "${PACKAGE_VERSION}-rc.${SEQAN3_RELEASE_CANDIDATE_VERSION}")
endif ()

if (NOT SEQAN3_PROJECT_VERSION VERSION_EQUAL PACKAGE_VERSION)
# Note: depending on how https://gitlab.kitware.com/cmake/cmake/-/issues/16716 is resolved (whether they use semver
# comparison semantics), (NOT "3.0.3" VERSION_GREATER_EQUAL "3.0.3-rc.1") might be the correct expression.
message (AUTHOR_WARNING "SEQAN3_PROJECT_VERSION and SEQAN3_VERSION mismatch, please report this issue and mention your cmake version.")
endif ()

# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
return()
Expand Down
2 changes: 1 addition & 1 deletion build_system/seqan3-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,6 @@ if (SEQAN3_FIND_DEBUG)
message ("")
message (" SEQAN3_VERSION ${SEQAN3_VERSION}")
message (" SEQAN3_VERSION_MAJOR ${SEQAN3_VERSION_MAJOR}")
message (" SEQAN3_VERSION_MINORG ${SEQAN3_VERSION_MINOR}")
message (" SEQAN3_VERSION_MINOR ${SEQAN3_VERSION_MINOR}")
message (" SEQAN3_VERSION_PATCH ${SEQAN3_VERSION_PATCH}")
endif ()
1 change: 1 addition & 0 deletions build_system/seqan3-package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cmake_minimum_required (VERSION 3.7)

set (CPACK_GENERATOR "TXZ")

set (CPACK_PACKAGE_VERSION "${SEQAN3_VERSION}")
set (CPACK_PACKAGE_VENDOR "seqan")
# A description of the project, used in places such as the introduction screen of CPack-generated Windows installers.
# set (CPACK_PACKAGE_DESCRIPTION_FILE "") # TODO
Expand Down
4 changes: 1 addition & 3 deletions include/seqan3/argument_parser/detail/format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@ class format_help_base : public format_base
//!\brief Prints the version information.
void print_version()
{
std::string const version_str = std::to_string(SEQAN3_VERSION_MAJOR) + "." +
std::to_string(SEQAN3_VERSION_MINOR) + "." +
std::to_string(SEQAN3_VERSION_PATCH);
std::string const version_str{seqan3_version_cstring};

// Print version, date and url.
derived_t().print_section("Version");
Expand Down
19 changes: 16 additions & 3 deletions include/seqan3/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#define SEQAN3_VERSION_MINOR 0
//!\brief The patch version as MACRO.
#define SEQAN3_VERSION_PATCH 3
//!\brief The release candidate number. 0 means stable release, >= 1 means release candidate.
#define SEQAN3_RELEASE_CANDIDATE 2

//!\brief The full version as MACRO (number).
#define SEQAN3_VERSION (SEQAN3_VERSION_MAJOR * 10000 \
+ SEQAN3_VERSION_MINOR * 100 \
+ SEQAN3_VERSION_PATCH)
+ SEQAN3_VERSION_MINOR * 100 \
+ SEQAN3_VERSION_PATCH)

/*!\brief Converts a number to a string. Preprocessor needs this indirection to
* properly expand the values to strings.
Expand All @@ -38,11 +40,21 @@
SEQAN3_VERSION_CSTRING_HELPER_STR(MINOR) "."\
SEQAN3_VERSION_CSTRING_HELPER_STR(PATCH)

#if (SEQAN3_RELEASE_CANDIDATE > 0)
//!\brief A helper function that expands to a suitable release candidate suffix.
#define SEQAN3_RELEASE_CANDIDATE_HELPER(RC) \
"-rc." SEQAN3_VERSION_CSTRING_HELPER_STR(RC)
#else
//!\brief A helper function that expands to a suitable release candidate suffix.
#define SEQAN3_RELEASE_CANDIDATE_HELPER(RC) ""
#endif

//!\brief The full version as null terminated string.
#define SEQAN3_VERSION_CSTRING \
SEQAN3_VERSION_CSTRING_HELPER_FUNC(SEQAN3_VERSION_MAJOR, \
SEQAN3_VERSION_MINOR, \
SEQAN3_VERSION_PATCH)
SEQAN3_VERSION_PATCH) \
SEQAN3_RELEASE_CANDIDATE_HELPER(SEQAN3_RELEASE_CANDIDATE)

namespace seqan3
{
Expand All @@ -64,3 +76,4 @@ constexpr char const* seqan3_version_cstring = SEQAN3_VERSION_CSTRING;

#undef SEQAN3_VERSION_CSTRING_HELPER_STR
#undef SEQAN3_VERSION_CSTRING_HELPER_FUNC
#undef SEQAN3_RELEASE_CANDIDATE_HELPER
2 changes: 1 addition & 1 deletion test/documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cmake_minimum_required(VERSION 3.7)
include (../../build_system/seqan3-config-version.cmake)
set (SEQAN3_VERSION "${PACKAGE_VERSION}")

project (seqan3 LANGUAGES NONE VERSION "${SEQAN3_VERSION}")
project (seqan3 LANGUAGES NONE VERSION "${SEQAN3_PROJECT_VERSION}")

if (NOT EXISTS "${SEQAN3_INCLUDE_DIR}/seqan3/version.hpp")
message (FATAL_ERROR "Could not find SeqAn3. Not building documentation.")
Expand Down
6 changes: 4 additions & 2 deletions test/unit/argument_parser/detail/format_man_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct format_man_test : public ::testing::Test
std::vector<std::string> list_pos_opt_value{};
std::string my_stdout{};
const char * argv[4] = {"./format_man_test --version-check false", "--export-help", "man"};
std::string const version_str{seqan3::seqan3_version_cstring};
std::string expected =
R"(.TH DEFAULT 1 "December 01, 1994" "default 01.01.01" "default_man_page_title")" "\n"
R"(.SH NAME)" "\n"
Expand Down Expand Up @@ -85,7 +86,7 @@ struct format_man_test : public ::testing::Test
R"(.br)" "\n"
R"(\fBdefault version: \fR01.01.01)" "\n"
R"(.br)" "\n"
R"(\fBSeqAn version: \fR3.0.3)" "\n";
R"(\fBSeqAn version: \fR)" + version_str + "\n";

// Full info parser initialisation
void dummy_init(seqan3::argument_parser & parser)
Expand Down Expand Up @@ -121,6 +122,7 @@ TEST_F(format_man_test, empty_information)
parser.info.man_page_title = "default_man_page_title";
parser.info.short_description = "A short description here.";

std::string const version_str{seqan3::seqan3_version_cstring};
std::string expected_short =
R"(.TH DEFAULT 1 "December 01, 1994" "default 01.01.01" "default_man_page_title")" "\n"
R"(.SH NAME)" "\n"
Expand Down Expand Up @@ -150,7 +152,7 @@ TEST_F(format_man_test, empty_information)
R"(.br)" "\n"
R"(\fBdefault version: \fR01.01.01)" "\n"
R"(.br)" "\n"
R"(\fBSeqAn version: \fR3.0.3)" "\n";
R"(\fBSeqAn version: \fR)" + version_str + "\n";

// Test the dummy parser with minimal information.
testing::internal::CaptureStdout();
Expand Down

0 comments on commit 85d0057

Please sign in to comment.