updated build system

This commit is contained in:
Scott E. Graves 2024-07-09 14:58:56 -05:00
parent 68c9ec0f82
commit 239652be7c
6 changed files with 58 additions and 31 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ deps/
scripts/cleanup.cmd
scripts/cleanup.sh
version.rc
version.cpp

View File

@ -22,9 +22,20 @@ include(cmake/functions.cmake)
include(cmake/libraries.cmake)
if(PROJECT_BUILD)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE PROJECT_GIT_REV
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp "")
file(GLOB_RECURSE ADDITIONAL_SOURCES
${PROJECT_3RD_PARTY_DIR}/src/*.c
${PROJECT_3RD_PARTY_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp
)
list(APPEND PROJECT_ADDITIONAL_SOURCES
@ -36,15 +47,14 @@ if(PROJECT_BUILD)
include(project.cmake)
if (PROJECT_VERSION)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build/version.sh "export PROJECT_VERSION=${PROJECT_VERSION}")
add_definitions(-DPROJECT_VERSION=\"${PROJECT_VERSION}\")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp.in
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp
@ONLY
)
if (PROJECT_GIT_REV)
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build/git_rev.sh "export PROJECT_GIT_REV=${PROJECT_GIT_REV}")
add_definitions(-DPROJECT_GIT_REV=\"${PROJECT_GIT_REV}\")
endif()
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build/version.sh "export PROJECT_VERSION=${PROJECT_VERSION}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build/git_rev.sh "export PROJECT_GIT_REV=${PROJECT_GIT_REV}")
else()
message(STATUS "-=[CMake Settings]=-")
message(STATUS " C standard: ${CMAKE_C_STANDARD}")

View File

@ -1,11 +1,3 @@
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE PROJECT_GIT_REV
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(REPERTORY_MAJOR 2)
set(REPERTORY_MINOR 0)
set(REPERTORY_REV 2)

View File

@ -403,11 +403,6 @@ using FileInfo = FSP_FSCTL_FILE_INFO;
using namespace Fsp;
namespace repertory {
auto get_repertory_git_revision() -> const std::string &;
auto get_repertory_version() -> const std::string &;
} // namespace repertory
namespace {
template <class... Ts> struct overloaded : Ts... {
using Ts::operator()...;

View File

@ -19,17 +19,13 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "types/repertory.hpp"
#include "utils/utils.hpp"
#ifndef LIBREPERTORY_INCLUDE_VERSION_HPP_
#define LIBREPERTORY_INCLUDE_VERSION_HPP_
namespace repertory {
auto get_repertory_git_revision() -> const std::string & {
static const std::string git_revision = PROJECT_GIT_REV;
return git_revision;
}
[[nodiscard]] auto project_get_git_rev() -> std::string_view;
auto get_repertory_version() -> const std::string & {
static const std::string version = PROJECT_VERSION;
return version;
}
[[nodiscard]] auto project_get_version() -> std::string_view;
} // namespace repertory
#endif // LIBREPERTORY_INCLUDE_VERSION_HPP_

33
repertory/version.cpp.in Normal file
View File

@ -0,0 +1,33 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "version.hpp"
namespace {
static constexpr const std::string_view git_rev = "@PROJECT_GIT_REV@";
static constexpr const std::string_view version = "@PROJECT_VERSION@";
} // namespace
namespace repertory {
auto project_get_git_rev() -> std::string_view { return git_rev; }
auto project_get_version() -> std::string_view { return version; }
} // namespace repertory