Skip to content

Commit

Permalink
add checks that Flang f18 doesn't have yet
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 10, 2024
1 parent c6b8b8f commit 7fea5ec
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 5 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.19...3.28)
cmake_minimum_required(VERSION 3.19...3.29)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Please specify build directory like:
Expand All @@ -16,10 +16,11 @@ include(CheckSourceCompiles)

# --- compiler checks

foreach(i IN ITEMS f03ieee f03utf8
f08contig f08kind
foreach(i IN ITEMS f03abstract f03charalloc f03ieee f03utf8 f03selectType
f08contig f08execute f08kind
f18abstract f18assumed_rank f18prop f18random
f2023rank_integer f2023ternary f2023tokenize f2023real16)

include(cmake/${i}.cmake)
endforeach()

Expand Down
19 changes: 19 additions & 0 deletions cmake/f03abstract.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
check_source_compiles(Fortran
"program abst
implicit none
type, abstract :: L1
integer, pointer :: bullseye(:,:)
end type L1
type, extends(L1) :: L2
integer, pointer :: arrow(:)
end type L2
class(L2), allocatable :: obj
end program
"
f03abstract
)
11 changes: 11 additions & 0 deletions cmake/f03charalloc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
check_source_compiles(Fortran
"program a
implicit none
character(:), allocatable :: x(:)
character(:), allocatable :: flex(:), scalar
flex = [character(5) :: 'hi', 'hello']
end program"
f03charalloc
)
29 changes: 29 additions & 0 deletions cmake/f03selectType.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
check_source_compiles(Fortran
"
program selectType
implicit none
real :: r
integer :: i
call selector(r)
call selector(i)
contains
subroutine selector(x)
class(*), intent(in) :: x
select type (x)
type is (real)
print *, 'real'
type is (integer)
print *, 'integer'
end select
end subroutine
end program
"
f03selectType
)
9 changes: 9 additions & 0 deletions cmake/f08execute.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
check_source_compiles(Fortran
"program a
implicit none
call execute_command_line('echo hello')
end program"
f08execute
)
2 changes: 2 additions & 0 deletions cmake/f08kind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ check_source_compiles(Fortran
use, intrinsic:: iso_fortran_env, only: real128
use, intrinsic:: ieee_arithmetic, only: ieee_is_nan
real(real128) :: pi128 = 4*atan(1.0_real128)
print *, huge(0._real128)
print *, ieee_is_nan(0._real128)
Expand Down
2 changes: 2 additions & 0 deletions src/system/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set_property(DIRECTORY PROPERTY LABELS system)

add_library(osdet OBJECT os_detect.f90)

if(f08execute)
find_package(Python COMPONENTS Interpreter)

add_executable(callpython call_python_script.f90)
Expand All @@ -12,3 +13,4 @@ find_program(FFPLAY NAMES ffplay)
add_executable(playsound play_sound.f90)
add_test(NAME PlaySound COMMAND playsound ${CMAKE_CURRENT_SOURCE_DIR}/bell.aac)
set_property(TEST PlaySound PROPERTY DISABLED $<NOT:$<BOOL:${FFPLAY}>>)
endif()
2 changes: 2 additions & 0 deletions test/array/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
set_property(DIRECTORY PROPERTY LABELS array)

if(f03selectType)
add_executable(rotflip test_rot90.f90 ${PROJECT_SOURCE_DIR}/src/array/rot90.f90)
add_test(NAME RotFlip COMMAND rotflip)
endif()

add_executable(auto_allocate_array auto_allocate.f90)
target_compile_options(auto_allocate_array PRIVATE
Expand Down
8 changes: 7 additions & 1 deletion test/character/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
set_property(DIRECTORY PROPERTY LABELS character)

foreach(t IN ITEMS ascii character_allocatable character_array charlen
set(tests ascii character_array charlen
color_text
print_vs_write overwrite_stdout special_characters str2int utf8)

if(f03charalloc)
list(APPEND tests character_allocatable)
endif()

foreach(t IN LISTS tests)
add_executable(${t} ${t}.f90)
add_test(NAME ${t} COMMAND ${t})
endforeach()
Expand Down
4 changes: 4 additions & 0 deletions test/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ foreach(t IN ITEMS devnull leading_zeros terminal_size)
endforeach()


if(f03selectType)

add_library(logging OBJECT ${PROJECT_SOURCE_DIR}/src/io/logging.f90)

add_executable(append_file append_file.f90 unlink.f90)
target_link_libraries(append_file PRIVATE logging)
add_test(NAME appendFile COMMAND append_file)

endif()

add_executable(termio ${PROJECT_SOURCE_DIR}/app/io/terminal_io.f90)
add_test(NAME terminal
COMMAND ${CMAKE_COMMAND}
Expand Down
7 changes: 6 additions & 1 deletion test/pointer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
set_property(DIRECTORY PROPERTY LABELS pointer)

foreach(t IN ITEMS null_pointer derived_type)
set(tests null_pointer)
if(f03abstract)
list(APPEND tests derived_type)
endif()

foreach(t IN LISTS tests)
add_executable(${t} ${t}.f90)
add_test(NAME ${t} COMMAND ${t})
endforeach()
4 changes: 4 additions & 0 deletions test/submodule/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set_property(DIRECTORY PROPERTY LABELS submodule)

if(NOT f03selectType)
return()
endif()

foreach(t IN ITEMS explicit procedure)
add_executable(${t} ${t}.f90)
add_test(NAME ${t} COMMAND ${t})
Expand Down

0 comments on commit 7fea5ec

Please sign in to comment.