1
- # cmake version, project name, language
2
- cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
3
- project (neural-fortran Fortran)
1
+ # CMake version, project name, language
2
+ cmake_minimum_required (VERSION 3.20)
4
3
5
- # set output paths for modules, archives, and executables
6
- set (CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR} /include )
7
- set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
8
- set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib)
9
- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
10
-
11
- # if build type not specified, default to release
4
+ # If build type not specified, default to release
12
5
if (NOT CMAKE_BUILD_TYPE )
13
- set (CMAKE_BUILD_TYPE "release" )
14
- endif ()
15
-
16
- if (SERIAL)
17
- message (STATUS "Configuring build for serial execution" )
18
- else ()
19
- message (STATUS "Configuring build for parallel execution" )
6
+ set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build Release" )
20
7
endif ()
21
8
22
- # compiler flags for gfortran
23
- if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
24
-
25
- if (SERIAL)
26
- message (STATUS "Configuring to build with -fcoarray=single" )
27
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcoarray=single" )
28
- endif ()
29
-
30
- if (BLAS)
31
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fexternal-blas ${BLAS} " )
32
- set (LIBS "${LIBS} blas" )
33
- message (STATUS "Configuring build to use BLAS from ${BLAS} " )
34
- endif ()
35
-
36
- set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -fcheck=bounds -fbacktrace" )
37
- set (CMAKE_Fortran_FLAGS_RELEASE "-Ofast -fno-frontend-optimize" )
38
- endif ()
39
-
40
- # compiler flags for ifort
41
- if (CMAKE_Fortran_COMPILER_ID MATCHES Intel)
42
-
43
- if (SERIAL)
44
- message (STATUS "Configuring to build with -coarray=single" )
45
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -coarray=single" )
46
- endif ()
9
+ project (neural-fortran
10
+ LANGUAGES C Fortran
11
+ )
47
12
48
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl" )
49
- set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -C -traceback" )
50
- set (CMAKE_Fortran_FLAGS_RELEASE "-O3" )
13
+ enable_testing ()
51
14
52
- if (NOT SERIAL)
53
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -coarray=shared" )
54
- endif ()
15
+ include (FetchContent)
55
16
56
- endif ()
17
+ include (cmake/options .cmake)
18
+ include (cmake/compilers.cmake)
57
19
58
- # compiler flags for Cray ftn
59
- if (CMAKE_Fortran_COMPILER_ID MATCHES Cray)
60
- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -h noomp" )
61
- set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g" )
62
- set (CMAKE_Fortran_FLAGS_RELEASE "-O3" )
63
- endif ()
20
+ include (cmake/h5fortran.cmake)
21
+ include (cmake/json.cmake)
64
22
65
23
# library to archive (libneural.a)
66
24
add_library (neural
@@ -70,6 +28,8 @@ add_library(neural
70
28
src/nf/nf_base_layer_submodule.f90
71
29
src/nf/nf_conv2d_layer.f90
72
30
src/nf/nf_conv2d_layer_submodule.f90
31
+ src/nf/nf_datasets.f90
32
+ src/nf/nf_datasets_submodule.f90
73
33
src/nf/nf_datasets_mnist.f90
74
34
src/nf/nf_datasets_mnist_submodule.f90
75
35
src/nf/nf_dense_layer.f90
@@ -80,8 +40,8 @@ add_library(neural
80
40
src/nf/nf_input1d_layer_submodule.f90
81
41
src/nf/nf_input3d_layer.f90
82
42
src/nf/nf_input3d_layer_submodule.f90
83
- src/nf/nf_io .f90
84
- src/nf/nf_io_submodule .f90
43
+ src/nf/nf_keras .f90
44
+ src/nf/nf_keras_submodule .f90
85
45
src/nf/nf_layer_constructors.f90
86
46
src/nf/nf_layer_constructors_submodule.f90
87
47
src/nf/nf_layer.f90
@@ -97,20 +57,22 @@ add_library(neural
97
57
src/nf/nf_parallel_submodule.f90
98
58
src/nf/nf_random.f90
99
59
src/nf/nf_random_submodule.f90
60
+ src/nf/io/nf_io_binary.f90
61
+ src/nf/io/nf_io_binary_submodule.f90
62
+ src/nf/io/nf_io_hdf5.f90
63
+ src/nf/io/nf_io_hdf5_submodule.f90
100
64
)
65
+ target_link_libraries (neural PRIVATE h5fortran::h5fortran HDF5::HDF5 jsonfortran::jsonfortran)
66
+
67
+ install (TARGETS neural)
101
68
102
69
# Remove leading or trailing whitespace
103
70
string (REGEX REPLACE "^ | $" "" LIBS "${LIBS} " )
104
71
105
- # tests
106
- enable_testing ()
107
- foreach (execid input1d_layer input3d_layer dense_layer conv2d_layer maxpool2d_layer flatten_layer dense_network conv2d_network)
108
- add_executable (test_${execid} test /test_${execid} .f90)
109
- target_link_libraries (test_${execid} neural ${LIBS} )
110
- add_test (test_${execid} bin/test_${execid} )
111
- endforeach ()
112
-
113
- foreach (execid cnn mnist simple sine)
114
- add_executable (${execid} example/${execid} .f90)
115
- target_link_libraries (${execid} neural ${LIBS} )
116
- endforeach ()
72
+ if (${PROJECT_NAME} _BUILD_TESTING)
73
+ add_subdirectory (test )
74
+ endif ()
75
+
76
+ if (${PROJECT_NAME} _BUILD_EXAMPLES)
77
+ add_subdirectory (example)
78
+ endif ()
0 commit comments