aboutsummaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
authorJakub Zakrzewski <slither.jz@gmail.com>2019-04-07 12:43:38 +0200
committerJakub Zakrzewski <slither.jz@gmail.com>2019-04-10 19:12:28 +0200
commitbe17f298ff508d62d493d4a8d43e56a1e2861a50 (patch)
tree827ce8d6f32fb7359dbfc2bf6245cb3a15724fb2 /CMake
parent639cfeb0f8f0f869d9cdd3756f72935f382b179a (diff)
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
Diffstat (limited to 'CMake')
-rw-r--r--CMake/OtherTests.cmake75
1 files changed, 40 insertions, 35 deletions
diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake
index c180a5888..c1c9aa32a 100644
--- a/CMake/OtherTests.cmake
+++ b/CMake/OtherTests.cmake
@@ -24,6 +24,8 @@ else()
add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
endif()
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+
check_c_source_compiles("${_source_epilogue}
int main(void) {
recv(0, 0, 0, 0);
@@ -177,6 +179,44 @@ int main(void) {
return 0;
}" 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 cross-compilation...
include(CheckCSourceRuns)
@@ -222,38 +262,3 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
}" HAVE_POLL_FINE)
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()