From 9d92730bc366866aa3928963096a63eacca47799 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 29 Mar 2018 20:39:07 +0200 Subject: [PATCH] better align fortran and c examples --- Chapter06/recipe-04/c-example/example.c | 6 ++++-- Chapter06/recipe-04/c-example/version.h.in | 6 +++++- Chapter06/recipe-04/fortran-example/example.f90 | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Chapter06/recipe-04/c-example/example.c b/Chapter06/recipe-04/c-example/example.c index 2adbad7d4..ffff811be 100644 --- a/Chapter06/recipe-04/c-example/example.c +++ b/Chapter06/recipe-04/c-example/example.c @@ -1,10 +1,12 @@ #include -// provides PROJECT_VERSION +// provides PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR #include "version.h" int main() { - printf("This is output from example code v%s:\n", PROJECT_VERSION); + printf("This is output from example code %s\n", PROJECT_VERSION); + printf("The major version number is %i\n", PROJECT_VERSION_MAJOR); + printf("The minor version number is %i\n", PROJECT_VERSION_MINOR); printf("Hello CMake world!\n"); } diff --git a/Chapter06/recipe-04/c-example/version.h.in b/Chapter06/recipe-04/c-example/version.h.in index 6e0f05107..deb9578fa 100644 --- a/Chapter06/recipe-04/c-example/version.h.in +++ b/Chapter06/recipe-04/c-example/version.h.in @@ -1,3 +1,7 @@ #pragma once -#define PROJECT_VERSION "@PROJECT_VERSION@" +#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@ + +#define PROJECT_VERSION "v@PROJECT_VERSION@" diff --git a/Chapter06/recipe-04/fortran-example/example.f90 b/Chapter06/recipe-04/fortran-example/example.f90 index f81863447..fa6c975b4 100644 --- a/Chapter06/recipe-04/fortran-example/example.f90 +++ b/Chapter06/recipe-04/fortran-example/example.f90 @@ -1,11 +1,13 @@ program example - use version, only: PROJECT_VERSION, PROJECT_VERSION_MAJOR + use version, only: PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR implicit none print *, "This is output from example code ", PROJECT_VERSION print *, "The major version number is", PROJECT_VERSION_MAJOR + print *, "The minor version number is", PROJECT_VERSION_MINOR + print *, "Hello CMake world!" end program