Skip to content

Commit

Permalink
better align fortran and c examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bast committed Mar 29, 2018
1 parent b17e5eb commit 9d92730
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Chapter06/recipe-04/c-example/example.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <stdio.h>

// 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");
}
6 changes: 5 additions & 1 deletion Chapter06/recipe-04/c-example/version.h.in
Original file line number Diff line number Diff line change
@@ -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@"
4 changes: 3 additions & 1 deletion Chapter06/recipe-04/fortran-example/example.f90
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9d92730

Please sign in to comment.