Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFRA] Propagate cmake project version to argument parser #61

Merged
merged 1 commit into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,42 @@

cmake_minimum_required (VERSION 3.8)

## CUSTOMISE

# Define the application name and version.
project (raptor VERSION 2.0.0)

# Fallback to these values if there is no git or no git repository
set (RAPTOR_COMMIT_DATE "2021-08-20--no-git"
CACHE STRING
"Set to provide a commit date if git is not available or the source directory is not a git repository.")
set (RAPTOR_COMMIT_HASH "74f815358db47037e93a56b826a9df3692e55680--no-git"
CACHE STRING
"Set to provide a commit hash if git is not available or the source directory is not a git repository.")

# Extract git commit hash and date
find_package (Git QUIET)

if (GIT_FOUND)
execute_process (COMMAND "${GIT_EXECUTABLE}" -C "${CMAKE_SOURCE_DIR}" rev-parse
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE is_no_git_repository
ERROR_QUIET)

if (NOT is_no_git_repository)
execute_process (COMMAND "${GIT_EXECUTABLE}" describe --always --abbrev=40 --dirty
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE RAPTOR_COMMIT_HASH
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process (COMMAND
"${GIT_EXECUTABLE}" log -1 --format=%ad --date=short
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE RAPTOR_COMMIT_DATE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
endif ()

## BUILD

# Make Release default build type
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ target_link_libraries ("${PROJECT_NAME}_upgrade_lib" PUBLIC "${PROJECT_NAME}_int

# Raptor argument parsing
add_library ("${PROJECT_NAME}_argument_parsing_shared_lib" STATIC argument_parsing/shared.cpp)
target_compile_definitions ("${PROJECT_NAME}_argument_parsing_shared_lib" PUBLIC "-DRAPTOR_VERSION=\"${CMAKE_PROJECT_VERSION} (${RAPTOR_COMMIT_HASH})\"")
target_compile_definitions ("${PROJECT_NAME}_argument_parsing_shared_lib" PUBLIC "-DRAPTOR_DATE=\"${RAPTOR_COMMIT_DATE}\"")
target_link_libraries ("${PROJECT_NAME}_argument_parsing_shared_lib" PUBLIC "${PROJECT_NAME}_interface")

add_library ("${PROJECT_NAME}_argument_parsing_build_lib" STATIC argument_parsing/build.cpp)
Expand Down
4 changes: 2 additions & 2 deletions src/argument_parsing/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void init_shared_meta(seqan3::argument_parser & parser)
"nucleotide sequences; Enrico Seiler, Svenja Mehringer, Mitra Darvish, Etienne Turc, "
"and Knut Reinert; iScience 2021 24 (7): 102782. doi: "
"https://doi.org/10.1016/j.isci.2021.102782";
parser.info.date = "20-08-2021";
parser.info.date = RAPTOR_DATE;
parser.info.email = "enrico.seiler@fu-berlin.de";
parser.info.long_copyright = R"(BSD 3-Clause License

Expand Down Expand Up @@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.)";
parser.info.short_copyright = "BSD 3-Clause License";
parser.info.short_description = "A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences.";
parser.info.url = "https://github.com/seqan/raptor";
parser.info.version = "2.0.0";
parser.info.version = RAPTOR_VERSION;
}

void try_parsing(seqan3::argument_parser & parser)
Expand Down