mirror of
https://github.com/moparisthebest/curl
synced 2024-12-23 08:38:49 -05:00
cmake: avoid linking executable for some tests with cmake 3.6+
With CMAKE_TRY_COMPILE_TARGET_TYPE set to STATIC_LIBRARY, the try_compile() (which is used by check_c_source_compiles()) will build static library instead of executable. This avoids linking additional libraries in and thus speeds up those checks a little. This commit also avoids #3743 (GSSAPI build errors) on itself with cmake 3.6 or above. That issue was fixed separately for all versions. Ref: #3744
This commit is contained in:
parent
639cfeb0f8
commit
be17f298ff
@ -24,6 +24,8 @@ else()
|
|||||||
add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
|
add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||||
|
|
||||||
check_c_source_compiles("${_source_epilogue}
|
check_c_source_compiles("${_source_epilogue}
|
||||||
int main(void) {
|
int main(void) {
|
||||||
recv(0, 0, 0, 0);
|
recv(0, 0, 0, 0);
|
||||||
@ -177,6 +179,44 @@ int main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}" HAVE_STRUCT_TIMEVAL)
|
}" HAVE_STRUCT_TIMEVAL)
|
||||||
|
|
||||||
|
set(HAVE_SIG_ATOMIC_T 1)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
|
if(HAVE_SIGNAL_H)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H")
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
|
||||||
|
endif()
|
||||||
|
check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T)
|
||||||
|
if(HAVE_SIZEOF_SIG_ATOMIC_T)
|
||||||
|
check_c_source_compiles("
|
||||||
|
#ifdef HAVE_SIGNAL_H
|
||||||
|
# include <signal.h>
|
||||||
|
#endif
|
||||||
|
int main(void) {
|
||||||
|
static volatile sig_atomic_t dummy = 0;
|
||||||
|
(void)dummy;
|
||||||
|
return 0;
|
||||||
|
}" HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
||||||
|
if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
||||||
|
set(HAVE_SIG_ATOMIC_T_VOLATILE 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_WINDOWS_H)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
|
||||||
|
else()
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES)
|
||||||
|
if(HAVE_SYS_SOCKET_H)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
||||||
|
if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
||||||
|
set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||||
# if not cross-compilation...
|
# if not cross-compilation...
|
||||||
include(CheckCSourceRuns)
|
include(CheckCSourceRuns)
|
||||||
@ -222,38 +262,3 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|||||||
}" HAVE_POLL_FINE)
|
}" HAVE_POLL_FINE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HAVE_SIG_ATOMIC_T 1)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS)
|
|
||||||
if(HAVE_SIGNAL_H)
|
|
||||||
set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H")
|
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
|
|
||||||
endif()
|
|
||||||
check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T)
|
|
||||||
if(HAVE_SIZEOF_SIG_ATOMIC_T)
|
|
||||||
check_c_source_compiles("
|
|
||||||
#ifdef HAVE_SIGNAL_H
|
|
||||||
# include <signal.h>
|
|
||||||
#endif
|
|
||||||
int main(void) {
|
|
||||||
static volatile sig_atomic_t dummy = 0;
|
|
||||||
(void)dummy;
|
|
||||||
return 0;
|
|
||||||
}" HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
|
||||||
if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
|
|
||||||
set(HAVE_SIG_ATOMIC_T_VOLATILE 1)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_WINDOWS_H)
|
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
|
|
||||||
else()
|
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES)
|
|
||||||
if(HAVE_SYS_SOCKET_H)
|
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
|
||||||
if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
|
|
||||||
set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
|
|
||||||
endif()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user