Skip to content

Commit 33b5882

Browse files
committed
Flang: correct check_symbol_exists libs
1 parent 0ab23f3 commit 33b5882

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmake/compilers.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ check_include_file("ISO_Fortran_binding.h" HAVE_ISO_FORTRAN_BINDING_H)
5353
# otherwise, we'd need to use try_compile() with a project for each symbol
5454
# IntelLLVM didn't need this trick
5555
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
56-
set(CMAKE_REQUIRED_LIBRARIES "gfortran")
56+
set(CMAKE_REQUIRED_LIBRARIES gfortran)
5757
elseif(CMAKE_C_COMPILER_ID STREQUAL "NVHPC")
58-
set(CMAKE_REQUIRED_LIBRARIES "nvf")
58+
set(CMAKE_REQUIRED_LIBRARIES nvf)
59+
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
60+
set(CMAKE_REQUIRED_LIBRARIES FortranRuntime FortranDecimal)
5961
endif()
6062

6163
# some compilers (e.g. NVHPC) have ISO_Fortran_binding.h but don't
6264
# have all the functions
6365
if(HAVE_ISO_FORTRAN_BINDING_H)
64-
check_symbol_exists(CFI_is_contiguous "ISO_Fortran_binding.h" HAVE_CFI_IS_CONTIGUOUS)
65-
check_symbol_exists(CFI_setpointer "ISO_Fortran_binding.h" HAVE_CFI_SETPOINTER)
66+
check_symbol_exists(CFI_is_contiguous "ISO_Fortran_binding.h" HAVE_CFI_IS_CONTIGUOUS)
67+
check_symbol_exists(CFI_setpointer "ISO_Fortran_binding.h" HAVE_CFI_SETPOINTER)
6668
endif()
6769

6870
endfunction()

test/iso_fortran_binding/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ if(HAVE_C_CHAR_PTR)
3838
add_executable(string_array string_array.cpp string_array.f90)
3939
set_property(TARGET string_array PROPERTY LINKER_LANGUAGE CXX)
4040
target_compile_options(string_array PRIVATE "$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-Wno-uninitialized>")
41+
4142
add_test(NAME string_array COMMAND string_array)
4243
set_property(TEST string_array PROPERTY PASS_REGULAR_EXPRESSION
4344
"red[ \n]+green[ \n]+blue")
4445
endif()
4546

4647

47-
add_executable(cfi_setpointer setpointer.f90 setpointer.c)
48-
add_test(NAME CFI_setpointer COMMAND cfi_setpointer)
48+
if(HAVE_CFI_SETPOINTER)
49+
add_executable(cfi_setpointer setpointer.f90 setpointer.c)
50+
add_test(NAME CFI_setpointer COMMAND cfi_setpointer)
51+
endif()
4952

5053
foreach(t IN ITEMS cfi_setpointer sampling)
5154
if(TARGET ${t})

0 commit comments

Comments
 (0)