Skip to content

Commit

Permalink
feat(project-template): add VersionInfo.h generation (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeng authored Oct 9, 2023
1 parent 1dcc99e commit e906920
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmake/set_version_numbers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ endif( ${PROJECT_NAME}_BUILDVERSION )

set(${PROJECT_NAME}_FULL_LIBRARY_VERSION ${${PROJECT_NAME}_SOVERSION}.${${PROJECT_NAME}_PATCH_VERSION})

# The following generates a cpp header file that can be used to access the CMAKE version info.
# The "VersionInfo.h" is available in the project's build directory and included in the build.

string(REGEX REPLACE "^0" "" ${PROJECT_NAME}_MAJOR_VERSION_INT ${${PROJECT_NAME}_MAJOR_VERSION})
string(REGEX REPLACE "^0" "" ${PROJECT_NAME}_MINOR_VERSION_INT ${${PROJECT_NAME}_MINOR_VERSION})
string(REGEX REPLACE "^0" "" ${PROJECT_NAME}_PATCH_VERSION_INT ${${PROJECT_NAME}_PATCH_VERSION})

configure_file(cmake/version_info_template.h.in "${PROJECT_BINARY_DIR}/generated/VersionInfo.h")
include_directories(${PROJECT_BINARY_DIR}/generated)
9 changes: 9 additions & 0 deletions cmake/version_info_template.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

namespace ChimeraTK::VersionInfo {

const int major{${${PROJECT_NAME}_MAJOR_VERSION_INT}};
const int minor{${${PROJECT_NAME}_MINOR_VERSION_INT}};
const int applicationPatch{${${PROJECT_NAME}_PATCH_VERSION_INT}};

} // namespace ChimeraTK::VersionInfo

0 comments on commit e906920

Please sign in to comment.