Skip to content

Commit 762b556

Browse files
authored
Avoid runtime checks (#16)
1 parent cc59dd7 commit 762b556

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

config/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
3232
)
3333
endif()
3434

35-
include(CheckFortranSourceRuns)
36-
check_fortran_source_runs(
37-
"if (selected_real_kind(33) == -1) stop 1; end"
35+
include(CheckFortranSourceCompiles)
36+
check_fortran_source_compiles(
37+
"integer, parameter :: qp = selected_real_kind(33); complex(qp) :: x; end"
3838
WITH_QP
3939
)
4040
set(WITH_QP ${WITH_QP} PARENT_SCOPE)
41-
check_fortran_source_runs(
42-
"if (any(selected_real_kind(18) == [-1, selected_real_kind(33)])) stop 1; end"
41+
check_fortran_source_compiles(
42+
"integer, parameter :: xdp = merge(-1, selected_real_kind(18), selected_real_kind(18) == selected_real_kind(33)); complex(xdp) :: x; end"
4343
WITH_XDP
4444
)
4545
set(WITH_XDP ${WITH_XDP} PARENT_SCOPE)

config/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ if get_option('openmp')
5454
lib_deps += omp_dep
5555
endif
5656

57-
with_qp = fc.run('if (selected_real_kind(33) == -1) stop 1; end').returncode() == 0
58-
with_xdp = fc.run('if (any(selected_real_kind(18) == [-1, selected_real_kind(33)])) stop 1; end').returncode() == 0
57+
with_qp = fc.compiles('integer, parameter :: qp = selected_real_kind(33); complex(qp) :: x; end')
58+
with_xdp = fc.compiles('integer, parameter :: xdp = merge(-1, selected_real_kind(18),selected_real_kind(18) == selected_real_kind(33)); complex(xdp) :: x; end')
5959
add_project_arguments(
6060
'-DWITH_QP=@0@'.format(with_qp.to_int()),
6161
'-DWITH_XDP=@0@'.format(with_xdp.to_int()),

0 commit comments

Comments
 (0)