You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improved build logic to ensure consisten Fortran compilers
- README.md updated and reflowed
- jsonfortran-${CMAKE_Fortran_COMPILER_ID} is now passed to `find_package()`
by projects wishing to import jsonfortran
- libraries and mod files installed under fortran/${CMAKE_Fortran_COMPILER_ID}
to enable parallel installation of packages built by different compilers the
package config logic ensures that the correct compiler is used
# Put common compiler compatibility check in a variable to be written out, rather than
105
+
# duplicating it across the build and install package-config files
106
+
set ( COMPILER_CONSISTENCY_CHECK
107
+
"# Check that the correct compiler is in use. Mod files and object files/archives
108
+
# are NOT compatible across different Fortran compilers when modules are present
109
+
set ( ${PACKAGE_NAME}_Fortran_COMPILER_ID ${CMAKE_Fortran_COMPILER_ID} )
110
+
set ( ${PACKAGE_NAME}_COMPATIBLE_COMPILER TRUE )
111
+
if ( NOT (\"${CMAKE_Fortran_COMPILER_ID}\" MATCHES \"\${CMAKE_Fortran_COMPILER_ID}\") )
112
+
message ( SEND_ERROR \"Incompatible Fortran compilers detected! ${PACKAGE_NAME} was compiled with the ${CMAKE_Fortran_COMPILER_ID} Fortran compiler, but the current project is trying to use the \${CMAKE_Fortran_COMPILER_ID} Fortran compiler! In general, Fortran modules and libraries can only link against other projects built using the same compiler.\" )
113
+
set ( ${PACKAGE_NAME}_COMPATIBLE_COMPILER FALSE )
114
+
endif ( NOT (\"${CMAKE_Fortran_COMPILER_ID}\" MATCHES \"\${CMAKE_Fortran_COMPILER_ID}\") )" )
Copy file name to clipboardExpand all lines: README.md
+41-12Lines changed: 41 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,39 @@ A Fortran 2003/2008 JSON API
6
6
Brief Description
7
7
---------------
8
8
9
-
A mostly-complete API for reading and writing JSON files, written in modern Fortran. The code requires a Fortran compiler that supports various Fortran 2003 and Fortran 2008 features such as: allocatable strings, associate, newunit, generic, class, and abstract interface. I am using the Intel Fortran compiler 13.1.0 on Linux (the Mac and PC versions should also work fine). It also currently compiles under recent experimental 4.9 release of the gnu gfortran compiler. The source code is a single Fortran module file (json_module.f90).
9
+
A mostly-complete API for reading and writing JSON files, written in
10
+
modern Fortran. The code requires a Fortran compiler that supports
11
+
various Fortran 2003 and Fortran 2008 features such as: allocatable
12
+
strings, associate, newunit, generic, class, and abstract interface.
13
+
I am using the Intel Fortran compiler 13.1.0 on Linux (the Mac and PC
14
+
versions should also work fine). It also currently compiles under
15
+
recent experimental 4.9 release of the gnu gfortran compiler. The
16
+
source code is a single Fortran module file (json_module.f90).
10
17
11
18
Building the Library
12
19
--------------------
13
-
Currently two way are provided to build the jsonfortran library (libjsonfortran). A build script, build.sh is provided in the project root directory. Additionally, a [CMake](http://www.cmake.org) build system is provided. This build system has been tested on Mac and Linux using the Intel Fortran Compiler. It has not been tested on Windows. This CMake based build provides an install target, and exports from both the install location and the build location so that building and using json-fortran in another CMake based project is trivial. To get started with the CMake based build, set the environment variable `FC` to point to your Fortran compiler, and create a build directory. Then `(cmake-gui|ccmake|cmake) /path/to/json-fortran` to configure, `make` to build and `make install` to optionally install. As long as the project is built with CMake other CMake projects can find it and link against it:
20
+
21
+
Currently two ways are provided to build the jsonfortran library
22
+
(libjsonfortran). A build script, build.sh is provided in the project
23
+
root directory. Additionally, a [CMake](http://www.cmake.org) build
24
+
system is provided. This build system has been tested on Mac and Linux
25
+
using the Intel Fortran Compiler. It has not been tested on
26
+
Windows. This CMake based build provides an install target, and
27
+
exports from both the install location and the build location so that
28
+
building and using json-fortran in another CMake based project is
29
+
trivial. To get started with the CMake based build, set the
30
+
environment variable `FC` to point to your Fortran compiler, and
31
+
create a build directory. Then `(cmake-gui|ccmake|cmake)
32
+
/path/to/json-fortran` to configure, `make` to build and `make
33
+
install` to optionally install. As long as the project is built with
34
+
CMake other CMake projects can find it and link against it:
14
35
15
36
```CMake
16
37
cmake_minimum_required ( VERSION 2.8 FATAL_ERROR )
Reading a JSON file and getting data from it is fairly straightforward. Here is an example. See the json_example.f90 file for more examples.
31
-
```fortran
32
-
program example1
51
+
Reading a JSON file and getting data from it is fairly
52
+
straightforward. Here is an example. See the json_example.f90 file
53
+
for more examples.
54
+
55
+
```fortran program example1
33
56
34
57
use json_module
35
58
@@ -61,9 +84,10 @@ Reading a JSON file and getting data from it is fairly straightforward. Here is
61
84
Writing a JSON file
62
85
---------------
63
86
64
-
Writing a json file is slightly more complicated and involves the use of pointers. See the json_example.f90 file for more examples.
65
-
```fortran
66
-
program example2
87
+
Writing a json file is slightly more complicated and involves the use
88
+
of pointers. See the json_example.f90 file for more examples.
89
+
90
+
```fortran program example2
67
91
68
92
use json_module
69
93
@@ -102,13 +126,18 @@ Writing a json file is slightly more complicated and involves the use of pointer
102
126
!cleanup:
103
127
call json_destroy(p)
104
128
105
-
end program example2
129
+
end program example2
106
130
```
131
+
107
132
Other Comments
108
133
---------------
109
134
110
-
This code is a fork and extensive upgrade of the FSON code that can be found at: <https://github.com/josephalevin/fson>. It includes many features that the original code did not have, and fixes many of that code's bugs.
135
+
This code is a fork and extensive upgrade of the FSON code that can be
136
+
found at: <https://github.com/josephalevin/fson>. It includes many
137
+
features that the original code did not have, and fixes many of that
138
+
code's bugs.
111
139
112
140
More About JSON
113
141
------------
114
-
For more information about JSON, see: <http://www.json.org/>
142
+
143
+
For more information about JSON, see: [json.org](http://www.json.org/)
if ( "${FULL_BUILD_DIR}"STREQUAL"${FULL_SOURCE_DIR}" )
8
+
if ( ALLOW_IN_SOURCE_BUILDS )
9
+
message ( WARNING
10
+
"Caution, in source build detected, procede at your own risk. Build and source directories are the same: ${CMAKE_SOURCE_DIR}" )
11
+
else ( ALLOW_IN_SOURCE_BUILDS )
12
+
message ( SEND_ERROR
13
+
"Error, in source builds are not supported. If you really want an in source build (and know what you are doing) you may set the advanced ALLOW_IN_SOURCE_BUILDS variable to ON. Otherwise create a build directory not matching the source directory, '${CMAKE_SOURCE_DIR}'." )
0 commit comments