Skip to content

Commit

Permalink
Add auto generation of version.h from CMake PROJECT_VERSION string
Browse files Browse the repository at this point in the history
  • Loading branch information
Gennady Pospelov committed Jun 18, 2020
1 parent 17700a0 commit d2b4815
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 27 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Linux

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
build:
Expand All @@ -17,13 +17,13 @@ jobs:
with:
submodules: true

- name: setup apt dependencies
- name: setup dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ccache \
cmake qt5-default qttools5-dev libqt5svg5-dev libx11-xcb1
- name: Prepare ccache timestamp
- name: ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
Expand All @@ -38,7 +38,7 @@ jobs:
restore-keys: |
qtmvvm-ubuntu-ccache-
- name: make
- name: build
env:
CCACHE_DIR: $GITHUB_WORKSPACE/.ccache
CCACHE_COMPRESS: "true"
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ name: MacOS

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
strategy:
max-parallel: 3
Expand All @@ -19,13 +17,13 @@ jobs:
with:
submodules: true

- name: setup dependencies
- name: dependencies
run: |
brew install cmake qt5 ccache
echo "Qt5 is installed to"
echo $QTDIR
- name: Prepare ccache timestamp
- name: ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
Expand Down Expand Up @@ -54,9 +52,7 @@ jobs:
CPPFLAGS: "-I/usr/local/opt/qt/include"
run: |
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> /Users/runner/.bash_profile
cd $GITHUB_WORKSPACE
pwd
ls
cd $GITHUB_WORKSPACE && pwd && ls
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
Expand All @@ -71,7 +67,7 @@ jobs:
ccache -s
ctest -j4
- name: upload test logs
- name: ctest output
uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ env:

on:
push:
branches: [ master ]
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
build:
Expand Down Expand Up @@ -45,22 +45,22 @@ jobs:
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
- name: Prepare ccache timestamp
- name: ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Prepare ccache files
- name: ccache files
uses: actions/[email protected]
with:
path: .ccache
key: qtmvvm-win-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
qtmvvm-win-ccache-
- name: Build
- name: build
shell: cmd
env:
CCACHE_BASEDIR: $GITHUB_WORKSPACE
Expand All @@ -81,7 +81,7 @@ jobs:
ccache -p
cmake --build . --config Release -j4
- name: Run functional tests
- name: ctest
if: success()
shell: cmd
run: |
Expand All @@ -92,7 +92,7 @@ jobs:
ccache -s
ctest --output-on-failure
- name: Functional test output
- name: ctest output
if: failure()
shell: cmd
run: |
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ message(STATUS " Qt5 Includes : ${Qt5Widgets_INCLUDE_DIRS}")
# Generating config files

configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/testconfig.h.in ${BUILD_INC_DIR}/testconfig.h @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/mvvm_version.h.in ${BUILD_INC_DIR}/mvvm_version.h @ONLY)
add_definitions(-I${BUILD_INC_DIR})

add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
51 changes: 51 additions & 0 deletions cmake/scripts/mvvm_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ************************************************************************** //
//
// Model-view-view-model framework for large GUI applications
//
//! @license GNU General Public License v3 or higher (see COPYING)
//! @authors see AUTHORS
//
// ************************************************************************** //

#ifndef SCRIPTS_MVVM_VERSION_H
#define SCRIPTS_MVVM_VERSION_H

//! @file mvvm_version.h
//! Automatically generated in <builddir>/inc from mvvm_version.h.in

#include <string>

namespace ModelView
{

//! Returns major project version.
inline int ProjectVersionMajor()
{
const int project_version_major = @PROJECT_VERSION_MAJOR@;
return project_version_major;
}

//! Returns minor project version.
inline int ProjectVersionMinor()
{
const int project_version_minor = @PROJECT_VERSION_MAJOR@;
return project_version_minor;
}

//! Returns patch project version.
inline int ProjectVersionPatch()
{
const int project_version_path = @PROJECT_VERSION_PATCH@;
return project_version_path;
}

//! Returns project version string
inline std::string ProjectVersion()
{
const std::string project_version = @PROJECT_VERSION_PATCH@;
return project_version;
}

} // namespace ModelView

#endif // BAVERSION_H
10 changes: 5 additions & 5 deletions cmake/scripts/testconfig.h.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// ************************************************************************** //
//
// Prototype of mini MVVM framework for bornagainproject.org
// Model-view-view-model framework for large GUI applications
//
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher
//! @license GNU General Public License v3 or higher (see COPYING)
//! @authors see AUTHORS
//
// ************************************************************************** //

#ifndef TESTCONFIG_H
#define TESTCONFIG_H
#ifndef SCRIPTS_TESTCONFIG_H
#define SCRIPTS_TESTCONFIG_H

#include <string>

Expand Down
15 changes: 15 additions & 0 deletions source/libmvvm_model/mvvm/core/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// ************************************************************************** //
//
// Model-view-view-model framework for large GUI applications
//
//! @license GNU General Public License v3 or higher (see COPYING)
//! @authors see AUTHORS
//
// ************************************************************************** //

#ifndef MVVM_CORE_VERSION_H
#define MVVM_CORE_VERSION_H

#include "mvvm_version.h" // auto generated in <build>/inc

#endif // MVVM_CORE_VERSION_H

0 comments on commit d2b4815

Please sign in to comment.