Skip to content

Commit

Permalink
Making application version driven by the git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
prmoore77 committed Mar 4, 2024
1 parent 94ec410 commit 86f4a1c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@ project(flight_sql)

set(CMAKE_CXX_STANDARD 17)

# Function to retrieve the latest Git tag
function(get_latest_git_tag OUTPUT_VARIABLE)
execute_process(
COMMAND git describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE RETURN_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${OUTPUT_VARIABLE} ${RETURN_VALUE} PARENT_SCOPE)
endfunction()

# Set the version
get_latest_git_tag(LATEST_TAG)
set(PROJECT_VERSION ${LATEST_TAG})

# Display variable values using message
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")

# Configure a header file with the version
configure_file(
${CMAKE_SOURCE_DIR}/src/library/include/version.h.in
${CMAKE_SOURCE_DIR}/src/library/include/version.h
)

# --------------------- Arrow ---------------------
configure_file(third_party/Arrow_CMakeLists.txt.in arrow/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
Expand Down
1 change: 1 addition & 0 deletions src/library/include/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version.h
3 changes: 2 additions & 1 deletion src/library/include/flight_sql_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#pragma once

#include <filesystem>
#include "version.h"

// Constants
const std::string FLIGHT_SQL_SERVER_VERSION = "v1.2.3"; // For now - be sure to update this version with the git tag! TODO: automate this
const std::string FLIGHT_SQL_SERVER_VERSION = PROJECT_VERSION;
const std::string DEFAULT_FLIGHT_HOSTNAME = "0.0.0.0";
const std::string DEFAULT_FLIGHT_USERNAME = "flight_username";
const int DEFAULT_FLIGHT_PORT = 31337;
Expand Down
8 changes: 8 additions & 0 deletions src/library/include/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// version.h.in
// This file is used by CMake to generate version.h
#ifndef PROJECT_VERSION_H
#define PROJECT_VERSION_H

#define PROJECT_VERSION "@PROJECT_VERSION@"

#endif // PROJECT_VERSION_H

0 comments on commit 86f4a1c

Please sign in to comment.