Skip to content

Commit 64f70a4

Browse files
added --version support for FANS (#50)
* added --version support for FANS --------- Co-authored-by: Ishaan Desai <[email protected]>
1 parent 680ae3c commit 64f70a4

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## latest
44

5+
- Add support for `--version` command line argument for checking the version of FANS
56
- Modify way to provide micro structure in JSON input https://github.com/DataAnalyticsEngineering/FANS/pull/43
67
- Add conda package for FANS https://github.com/DataAnalyticsEngineering/FANS/pull/39
78
- Introduce system for checking compiler flags: `avx2` & `fma` https://github.com/DataAnalyticsEngineering/FANS/pull/34

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ set_property(TARGET FANS_FANS PROPERTY PUBLIC_HEADER
182182
include/material_models/J2Plasticity.h
183183
)
184184

185+
# version.h is generated and added to the build include directory
186+
configure_file(
187+
"${PROJECT_SOURCE_DIR}/include/version.h.in"
188+
"${PROJECT_BINARY_DIR}/include/version.h" @ONLY
189+
)
190+
target_include_directories(FANS_main PRIVATE "${PROJECT_BINARY_DIR}/include")
191+
185192
# ##############################################################################
186193
# SOURCES
187194
# ##############################################################################

include/version.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef VERSION_H
2+
#define VERSION_H
3+
4+
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
5+
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
6+
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
7+
#define PROJECT_VERSION "@PROJECT_VERSION@"
8+
9+
#endif // VERSION_H

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include "setup.h"
44
#include "solver.h"
55

6+
// Version
7+
#include "version.h"
8+
69
template <int howmany>
710
void runSolver(Reader &reader, const char *output_file_basename)
811
{
@@ -32,6 +35,11 @@ void runSolver(Reader &reader, const char *output_file_basename)
3235

3336
int main(int argc, char *argv[])
3437
{
38+
if (argc > 1 && string(argv[1]) == "--version") {
39+
cout << "FANS version " << PROJECT_VERSION << endl;
40+
return 0;
41+
}
42+
3543
if (argc != 3) {
3644
fprintf(stderr, "USAGE: %s [input file basename] [output file basename]\n", argv[0]);
3745
return 10;

0 commit comments

Comments
 (0)