|
1 | 1 | # CMake version, project name, language |
2 | 2 | cmake_minimum_required(VERSION 3.20) |
3 | | -project(neural-fortran Fortran) |
| 3 | + |
| 4 | +# If build type not specified, default to release |
| 5 | +if(NOT CMAKE_BUILD_TYPE) |
| 6 | + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build Release") |
| 7 | +endif() |
| 8 | + |
| 9 | +project(neural-fortran LANGUAGES Fortran) |
| 10 | + |
| 11 | +option(SERIAL "Serial execution") |
4 | 12 |
|
5 | 13 | # Set output paths for modules, archives, and executables |
6 | 14 | set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include) |
7 | 15 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
8 | 16 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
9 | 17 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
10 | 18 |
|
11 | | -# If build type not specified, default to release |
12 | | -if(NOT CMAKE_BUILD_TYPE) |
13 | | - set(CMAKE_BUILD_TYPE "release") |
14 | | -endif() |
15 | | - |
16 | 19 | if(SERIAL) |
17 | 20 | message(STATUS "Configuring build for serial execution") |
18 | 21 | else() |
@@ -57,7 +60,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES GNU) |
57 | 60 | set(LIBS "${LIBS} blas") |
58 | 61 | message(STATUS "Configuring build to use BLAS from ${BLAS}") |
59 | 62 | endif() |
60 | | - |
| 63 | + |
61 | 64 | set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -fcheck=bounds -fbacktrace") |
62 | 65 | set(CMAKE_Fortran_FLAGS_RELEASE "-Ofast -fno-frontend-optimize") |
63 | 66 | endif() |
@@ -140,7 +143,7 @@ foreach(execid input1d_layer input3d_layer dense_layer conv2d_layer maxpool2d_la |
140 | 143 | target_link_libraries(test_${execid} PRIVATE neural h5fortran::h5fortran jsonfortran ${LIBS}) |
141 | 144 | add_test(test_${execid} bin/test_${execid}) |
142 | 145 | endforeach() |
143 | | - |
| 146 | + |
144 | 147 | foreach(execid cnn mnist mnist_from_keras simple sine) |
145 | 148 | add_executable(${execid} example/${execid}.f90) |
146 | 149 | target_link_libraries(${execid} PRIVATE neural h5fortran::h5fortran jsonfortran ${LIBS}) |
|
0 commit comments