Skip to content

Commit 9d3b2b8

Browse files
Add files via upload
1 parent 8da3064 commit 9d3b2b8

File tree

2 files changed

+62
-154
lines changed

2 files changed

+62
-154
lines changed

CMakeLists.txt

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,52 @@
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()
2534

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)
2641

27-
# Custom preprocessor flags
2842
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})
3444
endif()
3545

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!")
6150
endif()
6251

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)

Makefile.manual

Lines changed: 17 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,24 @@
1-
SRC = f18estop.f90 \
2-
stdlib_ascii.f90 \
3-
stdlib_bitsets.f90 \
4-
stdlib_bitsets_64.f90 \
5-
stdlib_bitsets_large.f90 \
6-
stdlib_error.f90 \
7-
stdlib_io.f90 \
8-
stdlib_kinds.f90 \
9-
stdlib_linalg.f90 \
10-
stdlib_linalg_diag.f90 \
11-
stdlib_logger.f90 \
12-
stdlib_optval.f90 \
13-
stdlib_quadrature.f90 \
14-
stdlib_quadrature_trapz.f90 \
15-
stdlib_stats.f90 \
16-
stdlib_stats_mean.f90 \
17-
stdlib_stats_moment.f90 \
18-
stdlib_stats_var.f90 \
19-
stdlib_stats_distribution_PRNG.f90\
20-
stdlib_stats_distribution_uniform.f90 \
21-
stdlib_stats_distribution_normal.f90
22-
23-
LIB = libstdlib.a
1+
# Fortran stdlib Makefile
242

3+
FC = gfortran
4+
FFLAGS = -Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all
5+
FYPPFLAGS=
256

7+
export FC
8+
export FFLAGS
9+
export FYPPFLAGS
2610

27-
OBJS = $(SRC:.f90=.o)
28-
MODS = $(OBJS:.o=.mod)
29-
SMODS = $(OBJS:.o=*.smod)
11+
.PHONY: all clean test
3012

31-
.PHONY: all clean
13+
all:
14+
$(MAKE) -f Makefile.manual --directory=src
15+
$(MAKE) -f Makefile.manual --directory=src/tests
3216

33-
all: $(LIB)
34-
35-
$(LIB): $(OBJS)
36-
ar rcs $@ $(OBJS)
17+
test:
18+
$(MAKE) -f Makefile.manual --directory=src/tests test
19+
@echo
20+
@echo "All tests passed."
3721

3822
clean:
39-
$(RM) $(LIB) $(OBJS) $(MODS) $(SMODS)
40-
41-
%.o: %.f90
42-
$(FC) $(FFLAGS) -c $<
43-
44-
%.f90: %.fypp
45-
fypp $(FYPPFLAGS) $< $@
46-
47-
# Fortran module dependencies
48-
f18estop.o: stdlib_error.o
49-
stdlib_bitsets.o: stdlib_kinds.o
50-
stdlib_bitsets_64.o: stdlib_bitsets.o
51-
stdlib_bitsets_large.o: stdlib_bitsets.o
52-
stdlib_error.o: stdlib_optval.o
53-
stdlib_io.o: \
54-
stdlib_error.o \
55-
stdlib_optval.o \
56-
stdlib_kinds.o
57-
stdlib_linalg_diag.o: stdlib_kinds.o
58-
stdlib_logger.o: stdlib_ascii.o stdlib_optval.o
59-
stdlib_optval.o: stdlib_kinds.o
60-
stdlib_quadrature.o: stdlib_kinds.o
61-
stdlib_stats_mean.o: \
62-
stdlib_optval.o \
63-
stdlib_kinds.o \
64-
stdlib_stats.o
65-
stdlib_stats_moment.o: \
66-
stdlib_optval.o \
67-
stdlib_kinds.o \
68-
stdlib_stats.o
69-
stdlib_stats_var.o: \
70-
stdlib_optval.o \
71-
stdlib_kinds.o \
72-
stdlib_stats.o
73-
stdlib_stats_distribution_PRNG.o: stdlib_kinds.o
74-
stdlib_stats_distribution_uniform.o: \
75-
stdlib_kinds.o \
76-
stdlib_error.o \
77-
stdlib_stats_distribution_PRNG.o
78-
stdlib_stats_distribution_normal.o \
79-
stdlib_kinds.o
80-
stdlib_error.o \
81-
stdlib_stats_distribution.PRNG.o \
82-
stdlib_stats_distribution.uniform.o
83-
84-
# Fortran sources that are built from fypp templates
85-
stdlib_bitsets_64.f90: stdlib_bitsets_64.fypp
86-
stdlib_bitsets_large.f90: stdlib_bitsets_large.fypp
87-
stdlib_bitsets.f90: stdlib_bitsets.fypp
88-
stdlib_io.f90: stdlib_io.fypp
89-
stdlib_linalg.f90: stdlib_linalg.fypp
90-
stdlib_linalg_diag.f90: stdlib_linalg_diag.fypp
91-
stdlib_quadrature.f90: stdlib_quadrature.fypp
92-
stdlib_stats.f90: stdlib_stats.fypp
93-
stdlib_stats_mean.f90: stdlib_stats_mean.fypp
94-
stdlib_stats_moment.f90: stdlib_stats_moment.fypp
95-
stdlib_stats_var.f90: stdlib_stats_var.fypp
96-
stdlib_stats_distribution_PRNG.f90: stdlib_stats_distribution_PRNG.fypp
97-
stdlib_stats_distribution_uniform.f90: stdlib_stats_distribution_uniform.fypp
98-
stdlib_stats_distribution_normal.f90: stdlib_stats_distribution_normal.fypp
23+
$(MAKE) -f Makefile.manual clean --directory=src
24+
$(MAKE) -f Makefile.manual clean --directory=src/tests

0 commit comments

Comments
 (0)