Skip to content

Commit

Permalink
[INFRA] Propagate cmake project version to argument parser
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Aug 22, 2021
1 parent 74f8153 commit b4e8389
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
31 changes: 29 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,38 @@

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")
set (RAPTOR_COMMIT_HASH "74f815358db47037e93a56b826a9df3692e55680--no-git")

# 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

0 comments on commit b4e8389

Please sign in to comment.