|
1 |
| -### Pre-process: .fpp -> .f90 via Fypp |
2 |
| - |
3 |
| -# Create a list of the files to be preprocessed |
4 |
| -set(fppFiles |
5 |
| - stdlib_bitsets.fypp |
6 |
| - stdlib_bitsets_64.fypp |
7 |
| - stdlib_bitsets_large.fypp |
8 |
| - stdlib_io.fypp |
9 |
| - stdlib_linalg.fypp |
10 |
| - stdlib_linalg_diag.fypp |
11 |
| - stdlib_optval.fypp |
12 |
| - stdlib_stats.fypp |
13 |
| - stdlib_stats_corr.fypp |
14 |
| - stdlib_stats_cov.fypp |
15 |
| - stdlib_stats_mean.fypp |
16 |
| - stdlib_stats_moment.fypp |
17 |
| - stdlib_stats_var.fypp |
18 |
| - stdlib_quadrature.fypp |
19 |
| - stdlib_quadrature_trapz.fypp |
20 |
| - stdlib_quadrature_simps.fypp |
21 |
| - stdlib_stats_distribution_PRNG.fypp |
22 |
| - stdlib_stats_distribution_uniform.fypp |
23 |
| - stdlib_stats_distribution_normal.fypp |
24 |
| -) |
| 1 | +cmake_minimum_required(VERSION 3.14.0) |
| 2 | +project(stdlib Fortran) |
| 3 | +enable_testing() |
| 4 | + |
| 5 | +include(${CMAKE_SOURCE_DIR}/cmake/stdlib.cmake) |
| 6 | + |
| 7 | +# --- compiler options |
| 8 | +if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) |
| 9 | + add_compile_options(-fimplicit-none) |
| 10 | + add_compile_options(-ffree-line-length-132) |
| 11 | + add_compile_options(-Wall) |
| 12 | + add_compile_options(-Wextra) |
| 13 | + add_compile_options(-Wimplicit-procedure) |
| 14 | + add_compile_options(-Wconversion-extra) |
| 15 | + # -pedantic-errors triggers a false positive for optional arguments of elemental functions, |
| 16 | + # see test_optval and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446 |
| 17 | + add_compile_options(-pedantic-errors) |
| 18 | + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) |
| 19 | + add_compile_options(-std=f2018) |
| 20 | + else() |
| 21 | + add_compile_options(-std=f2008ts) |
| 22 | + endif() |
| 23 | +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) |
| 24 | + add_compile_options(-warn declarations,general,usage,interfaces,unused) |
| 25 | + add_compile_options(-standard-semantics) |
| 26 | + if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 18.0) |
| 27 | + add_compile_options(-stand f15) |
| 28 | + else() |
| 29 | + add_compile_options(-stand f18) |
| 30 | + endif() |
| 31 | +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI) |
| 32 | + add_compile_options(-Mdclchk) |
| 33 | +endif() |
25 | 34 |
|
| 35 | +# --- compiler feature checks |
| 36 | +include(CheckFortranSourceCompiles) |
| 37 | +include(CheckFortranSourceRuns) |
| 38 | +check_fortran_source_compiles("error stop i; end" f18errorstop SRC_EXT f90) |
| 39 | +check_fortran_source_compiles("real, allocatable :: array(:, :, :, :, :, :, :, :, :, :); end" f03rank SRC_EXT f90) |
| 40 | +check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128) |
26 | 41 |
|
27 |
| -# Custom preprocessor flags |
28 | 42 | if(DEFINED CMAKE_MAXIMUM_RANK)
|
29 |
| - set(fyppFlags "-DMAXRANK=${CMAKE_MAXIMUM_RANK}") |
30 |
| -elseif(f03rank) |
31 |
| - set(fyppFlags) |
32 |
| -else() |
33 |
| - set(fyppFlags "-DVERSION90") |
| 43 | + set(CMAKE_MAXIMUM_RANK ${CMAKE_MAXIMUM_RANK}) |
34 | 44 | endif()
|
35 | 45 |
|
36 |
| -fypp_f90("${fyppFlags}" "${fppFiles}" outFiles) |
37 |
| - |
38 |
| -set(SRC |
39 |
| - stdlib_ascii.f90 |
40 |
| - stdlib_error.f90 |
41 |
| - stdlib_kinds.f90 |
42 |
| - stdlib_logger.f90 |
43 |
| - stdlib_system.F90 |
44 |
| - ${outFiles} |
45 |
| -) |
46 |
| - |
47 |
| -add_library(fortran_stdlib ${SRC}) |
48 |
| - |
49 |
| -set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/) |
50 |
| -set_target_properties(fortran_stdlib PROPERTIES |
51 |
| - Fortran_MODULE_DIRECTORY ${LIB_MOD_DIR}) |
52 |
| -target_include_directories(fortran_stdlib PUBLIC |
53 |
| - $<BUILD_INTERFACE:${LIB_MOD_DIR}> |
54 |
| - $<INSTALL_INTERFACE:include> |
55 |
| -) |
56 |
| - |
57 |
| -if(f18errorstop) |
58 |
| - target_sources(fortran_stdlib PRIVATE f18estop.f90) |
59 |
| -else() |
60 |
| - target_sources(fortran_stdlib PRIVATE f08estop.f90) |
| 46 | +# --- find preprocessor |
| 47 | +find_program(FYPP fypp) |
| 48 | +if(NOT FYPP) |
| 49 | + message(FATAL_ERROR "Preprocessor fypp not found!") |
61 | 50 | endif()
|
62 | 51 |
|
63 |
| -add_subdirectory(tests) |
64 |
| - |
65 |
| -install(TARGETS fortran_stdlib |
66 |
| - RUNTIME DESTINATION bin |
67 |
| - ARCHIVE DESTINATION lib |
68 |
| - LIBRARY DESTINATION lib |
69 |
| - ) |
70 |
| -install(DIRECTORY ${LIB_MOD_DIR} DESTINATION include) |
| 52 | +add_subdirectory(src) |
0 commit comments