Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ endif()

list(
APPEND fyppFlags
"-DWITH_CBOOL=$<BOOL:${WITH_CBOOL}>"
"-DWITH_QP=$<BOOL:${WITH_QP}>"
"-DWITH_XDP=$<BOOL:${WITH_XDP}>"
"-DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}"
Expand Down
9 changes: 9 additions & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
# Check for available features
# Note: users can overwrite the automatic check by setting the value at configure time
include(CheckFortranSourceRuns)
if (NOT DEFINED WITH_CBOOL)
check_fortran_source_runs(
"use, intrinsic :: iso_c_binding, only: c_bool; integer, parameter :: lk = kind(.true.)
if (c_bool == lk) stop 1
end"
WITH_CBOOL
)
set(WITH_CBOOL ${WITH_CBOOL} PARENT_SCOPE)
endif()
if (NOT DEFINED WITH_QP)
check_fortran_source_runs(
"if (selected_real_kind(33) == -1) stop 1; end"
Expand Down
1 change: 1 addition & 0 deletions config/template.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@PACKAGE_INIT@

set("@PROJECT_NAME@_WITH_CBOOL" @WITH_CBOOL@)
set("@PROJECT_NAME@_WITH_QP" @WITH_QP@)
set("@PROJECT_NAME@_WITH_XDP" @WITH_XDP@)

Expand Down
10 changes: 9 additions & 1 deletion src/common.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#! Project version number
#:set PROJECT_VERSION = "{}.{}.{}".format(PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH)

#! Support for C_BOOL logical
#:if not defined("WITH_CBOOL")
#:set WITH_CBOOL = False
#:endif

#! Support for quadruple precision floating point numbers
#:if not defined("WITH_QP")
#:set WITH_QP = False
Expand Down Expand Up @@ -53,7 +58,10 @@
#:set INT_KINDS_TYPES = list(zip(INT_KINDS, INT_TYPES))

#! Logical kinds to be considered during templating
#:set LOG_KINDS = ["lk", "c_bool"]
#:set LOG_KINDS = ["lk"]
#:if WITH_CBOOL
#:set LOG_KINDS = LOG_KINDS + ["c_bool"]
#:endif

#! Logical types to be considered during templating
#:set LOG_TYPES = ["logical({})".format(k) for k in LOG_KINDS]
Expand Down
2 changes: 1 addition & 1 deletion test/ascii/test_ascii.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module test_ascii
is_digit, is_octal_digit, is_hex_digit, is_white, is_blank, &
is_control, is_punctuation, is_graphical, is_printable, is_ascii, &
to_lower, to_upper, to_title, to_sentence, reverse, LF, TAB, NUL, DEL
use stdlib_kinds, only : int8, int16, int32, int64, lk, c_bool
use stdlib_kinds, only : int8, int16, int32, int64, lk
implicit none
private

Expand Down
9 changes: 9 additions & 0 deletions test/string/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#### Pre-process: .fpp -> .f90 via Fypp

# Create a list of the files to be preprocessed
set(fppFiles
test_string_assignment.fypp
)

fypp_f90("${fyppFlags}" "${fppFiles}" outFiles)

ADDTEST(string_assignment)
ADDTEST(string_operator)
ADDTEST(string_intrinsic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ subroutine test_constructor(error)
call check(error, string_type(.false.) == trim(flc))
if (allocated(error)) return

#:if WITH_CBOOL
write(flc, '(g0)') .false._c_bool
call check(error, string_type(.false._c_bool) == trim(flc))
if (allocated(error)) return
#:endif

write(flc, '(g0)') .true._lk
call check(error, string_type(.true._lk) == trim(flc))
Expand Down