Skip to content

Commit 6f56c05

Browse files
authored
Add support for quadruple and extended double precision support (#6)
- Fpm will require preprocessor defines -DWITH_QP={0|1} and -DWITH_XDP={0|1} - meson and cmake will attempt to run test programs to automatically determine this information - make driver procedures recursive to allow running the testsuites in strict mode - provide is_nan implementation for compiler not having IEEE arithmetic support
1 parent d94d77b commit 6f56c05

12 files changed

+1161
-28
lines changed

.github/workflows/build.yml

-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ jobs:
4747
compiler: gnu
4848
version: 10
4949

50-
- os: macos-latest
51-
build: meson
52-
build-type: debug
53-
compiler: gnu
54-
version: 5
55-
5650
- os: macos-latest
5751
build: cmake
5852
build-type: debug

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ target_include_directories(
5656
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
5757
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${module-dir}>
5858
)
59+
target_compile_definitions(
60+
"${PROJECT_NAME}-lib"
61+
PRIVATE
62+
"WITH_QP=$<BOOL:${WITH_QP}>"
63+
"WITH_XDP=$<BOOL:${WITH_XDP}>"
64+
)
5965

6066
# Export targets for other projects
6167
add_library("${PROJECT_NAME}" INTERFACE)

config/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ 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"
38+
WITH_QP
39+
)
40+
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"
43+
WITH_XDP
44+
)
45+
set(WITH_XDP ${WITH_XDP} PARENT_SCOPE)
46+
3547
include(CMakePackageConfigHelpers)
3648
configure_package_config_file(
3749
"${CMAKE_CURRENT_SOURCE_DIR}/template.cmake"

config/meson.build

+8
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ if get_option('openmp')
5353
omp_dep = dependency('openmp')
5454
lib_deps += omp_dep
5555
endif
56+
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
59+
add_project_arguments(
60+
'-DWITH_QP=@0@'.format(with_qp.to_int()),
61+
'-DWITH_XDP=@0@'.format(with_xdp.to_int()),
62+
language: 'fortran',
63+
)

config/template.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@PACKAGE_INIT@
22

3+
set("@PROJECT_NAME@_WITH_QP" @WITH_QP@)
4+
set("@PROJECT_NAME@_WITH_XDP" @WITH_XDP@)
5+
36
if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
47
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
58
endif()

src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(dir "${CMAKE_CURRENT_SOURCE_DIR}")
1515

1616
list(
1717
APPEND srcs
18-
"${dir}/testdrive.f90"
18+
"${dir}/testdrive.F90"
1919
"${dir}/testdrive_version.f90"
2020
)
2121

src/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
# limitations under the License.
1313

1414
srcs += files(
15-
'testdrive.f90',
15+
'testdrive.F90',
1616
'testdrive_version.f90',
1717
)

0 commit comments

Comments
 (0)