Skip to content

Commit 177545b

Browse files
committed
selected_logical_kind if available
1 parent cb962d9 commit 177545b

5 files changed

Lines changed: 28 additions & 35 deletions

File tree

cmake/compilers.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,11 @@ endif()
103103
endblock()
104104

105105

106-
check_source_compiles(Fortran
107-
"program test
108-
implicit none
106+
check_source_compiles(Fortran "program test
109107
real :: a(1)
110-
print '(L1)', is_contiguous(a)
108+
if (.not. is_contiguous(a)) error stop
111109
end program"
112-
f08contiguous
113-
)
114-
115-
include(${CMAKE_CURRENT_LIST_DIR}/f08submod_bind.cmake)
110+
f08contiguous)
116111

117112

118113
block()

cmake/f08submod_bind.cmake

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/bool/bad_bool.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module bad_bool
55

66
implicit none
77

8-
integer, parameter :: lk = 8
8+
include "logical_kind.inc"
99

1010
type, bind(C) :: bool_args
11-
logical(8) :: value
11+
logical(lk) :: value
1212
integer(C_INT) :: dummy
1313
end type
1414

test/bool/CMakeLists.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
set_property(DIRECTORY PROPERTY LABELS bool)
22

3+
check_source_compiles(Fortran "program test
4+
integer, parameter :: lk = selected_logical_kind(1)
5+
end program"
6+
f23logical_kind)
7+
8+
if(f23logical_kind)
9+
file(GENERATE OUTPUT logical_kind.inc CONTENT "integer, parameter :: lk = selected_logical_kind(64)")
10+
else()
11+
file(GENERATE OUTPUT logical_kind.inc CONTENT "integer, parameter :: lk = 8")
12+
endif()
13+
314
add_library(bool_fortran OBJECT ${PROJECT_SOURCE_DIR}/src/bool/logbool.f90)
415
target_include_directories(bool_fortran INTERFACE ${PROJECT_SOURCE_DIR}/src/bool)
516

@@ -19,12 +30,13 @@ add_test(NAME Cpp_Fortran_bool COMMAND cxx_fortran_bool)
1930

2031
add_executable(fortran_cxx_bool main.f90)
2132
target_link_libraries(fortran_cxx_bool PRIVATE bool_cxx)
33+
target_include_directories(fortran_cxx_bool PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
2234
set_property(TARGET fortran_cxx_bool PROPERTY LINKER_LANGUAGE ${linker_lang})
2335
add_test(NAME Fortran_Cpp_bool COMMAND fortran_cxx_bool)
2436

2537
add_executable(fortran_c_bool main.f90)
2638
target_link_libraries(fortran_c_bool PRIVATE bool_c)
27-
set_property(TARGET fortran_c_bool PROPERTY LINKER_LANGUAGE Fortran)
39+
target_include_directories(fortran_c_bool PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
2840
add_test(NAME Fortran_C_bool COMMAND fortran_c_bool)
2941

3042
add_executable(c_cxx_bool main.c)
@@ -38,11 +50,14 @@ add_test(NAME Cpp_C_bool COMMAND cxx_c_bool)
3850

3951
add_executable(fortran_c_bad_bool bad_interface.f90)
4052
target_link_libraries(fortran_c_bad_bool PRIVATE bool_c)
41-
set_property(TARGET fortran_c_bad_bool PROPERTY LINKER_LANGUAGE Fortran)
53+
target_include_directories(fortran_c_bad_bool PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
4254
add_test(NAME Fortran_C_bad_bool COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:fortran_c_bad_bool>)
4355

4456
add_library(bad_bool_fortran OBJECT ${PROJECT_SOURCE_DIR}/src/bool/bad_bool.f90)
45-
target_include_directories(bad_bool_fortran INTERFACE ${PROJECT_SOURCE_DIR}/src/bool)
57+
target_include_directories(bad_bool_fortran
58+
INTERFACE ${PROJECT_SOURCE_DIR}/src/bool
59+
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
60+
)
4661

4762
add_executable(c_fortran_bad_bool main.c)
4863
target_link_libraries(c_fortran_bad_bool PRIVATE bad_bool_fortran)
@@ -53,4 +68,6 @@ target_link_libraries(cxx_fortran_bad_bool PRIVATE bad_bool_fortran)
5368
add_test(NAME Cpp_Fortran_bad_bool COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:cxx_fortran_bad_bool>)
5469

5570
set_tests_properties(C_Fortran_bad_bool Fortran_C_bad_bool Cpp_Fortran_bad_bool PROPERTIES WILL_FAIL true)
71+
5672
set_target_properties(c_fortran_bool c_fortran_bad_bool PROPERTIES LINKER_LANGUAGE C)
73+
set_target_properties(fortran_c_bool fortran_c_bad_bool PROPERTIES LINKER_LANGUAGE Fortran)

test/bool/bad_interface.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ program bad_interface
66

77
implicit none
88

9+
include "logical_kind.inc"
10+
911
type, bind(C) :: bool_args
10-
logical(8) :: value
12+
logical(lk) :: value
1113
integer(C_INT) :: dummy
1214
end type
1315

0 commit comments

Comments
 (0)