Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm][CMake] Check dependency cxx source compiles #68549

Merged
merged 2 commits into from
Oct 18, 2023
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
20 changes: 16 additions & 4 deletions llvm/cmake/modules/FindFFI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,27 @@ find_library(FFI_LIBRARIES ffi PATHS ${FFI_LIBRARY_DIR})

if(FFI_LIBRARIES)
include(CMakePushCheckState)
include(CheckCSourceCompiles)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARIES})
check_c_source_compiles("
set(HAVE_FFI_CALL_SRC [=[
#ifdef __cplusplus
extern "C" {
#endif
struct ffi_cif;
typedef struct ffi_cif ffi_cif;
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue);
int main(void) { ffi_call(0, 0, 0, 0); }"
HAVE_FFI_CALL)
#ifdef __cplusplus
}
#endif
int main(void) { ffi_call(0, 0, 0, 0); }
]=])
if(DEFINED CMAKE_C_COMPILER)
include(CheckCSourceCompiles)
check_c_source_compiles("${HAVE_FFI_CALL_SRC}" HAVE_FFI_CALL)
else()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("${HAVE_FFI_CALL_SRC}" HAVE_FFI_CALL)
endif()
cmake_pop_check_state()
endif()

Expand Down
20 changes: 16 additions & 4 deletions llvm/cmake/modules/FindTerminfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)

if(Terminfo_LIBRARIES)
include(CMakePushCheckState)
include(CheckCSourceCompiles)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
check_c_source_compiles("
set(Terminfo_LINKABLE_SRC [=[
#ifdef __cplusplus
extern "C" {
#endif
int setupterm(char *term, int filedes, int *errret);
int main(void) { return setupterm(0, 0, 0); }"
Terminfo_LINKABLE)
#ifdef __cplusplus
}
#endif
int main(void) { return setupterm(0, 0, 0); }
]=])
if(DEFINED CMAKE_C_COMPILER)
include(CheckCSourceCompiles)
check_c_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
else()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
endif()
cmake_pop_check_state()
endif()

Expand Down