cmake - use git to generate version string

This commit is contained in:
Matthias Hochsteger 2020-05-18 15:55:40 +02:00
parent c81ebc9f24
commit 267e8b33fb
6 changed files with 20 additions and 7 deletions

View File

@ -78,12 +78,8 @@ else()
endif()
endif()
set(NETGEN_VERSION_MAJOR 6)
set(NETGEN_VERSION_MINOR 2)
string(TIMESTAMP NETGEN_VERSION_PATCH "%y%U%w" )
set(NETGEN_VERSION "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}-dev")
set(PACKAGE_VERSION "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}-${NETGEN_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
include (${CMAKE_CURRENT_LIST_DIR}/cmake/generate_version_file.cmake)
set(CPACK_PACKAGE_VERSION "${NETGEN_VERSION}")
#######################################################################
@ -326,6 +322,12 @@ if (USE_MPEG)
include_directories(${FFMPEG_INCLUDE_DIR})
endif (USE_MPEG)
#######################################################################
add_custom_target(ng_generate_version_file
${CMAKE_COMMAND}
-DBDIR=${CMAKE_CURRENT_BINARY_DIR}
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/generate_version_file.cmake
)
#######################################################################
if(INSTALL_PROFILES)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "#!/bin/sh\n")

View File

@ -1,4 +1,8 @@
set(NETGEN_VERSION "@NETGEN_VERSION@")
set(NETGEN_VERSION_MAJOR "@NETGEN_VERSION_MAJOR@")
set(NETGEN_VERSION_MINOR "@NETGEN_VERSION_MINOR@")
set(NETGEN_VERSION_PATCH "@NETGEN_VERSION_PATCH@")
set(NETGEN_VERSION_TWEAK "@NETGEN_VERSION_TWEAK@")
get_filename_component(NETGEN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

View File

@ -71,6 +71,8 @@ if(ENABLE_CPP_CORE_GUIDELINES_CHECK)
set_target_properties(ngcore PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)
add_dependencies(ngcore ng_generate_version_file)
if(USE_PYTHON)
pybind11_add_module(pyngcore SHARED python_ngcore_export.cpp)
target_link_libraries(pyngcore PUBLIC ngcore netgen_python)

View File

@ -14,6 +14,8 @@ namespace netgen
templates, global types, defines and variables
*/
DLL_HEADER extern const string netgen_version;
/// The following value may be adapted to the hardware !
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000000

View File

@ -1,5 +1,6 @@
#include <mystdlib.h>
#include "meshing.hpp"
#include <netgen_version.hpp>
namespace netgen
@ -21,6 +22,8 @@ namespace netgen
// NetgenOutStream * testout = new NetgenOutStream;
const string netgen_version = NETGEN_VERSION;
ostream * mycout = &cout;
ostream * myerr = &cerr;

View File

@ -82,7 +82,7 @@ int main(int argc, char ** argv)
if ( netgen::id == 0 )
{
cout << "NETGEN-" << PACKAGE_VERSION << endl;
cout << "NETGEN-" << netgen::netgen_version << endl;
cout << "Developed by Joachim Schoeberl at" << endl
<< "2010-xxxx Vienna University of Technology" << endl