From fa525649bea7ee6ec14958e123b386755d0518ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Wed, 22 Sep 2021 15:57:43 +0100 Subject: [PATCH] CMake: Try to set a required try_run() definition in a more idiomatic way This is applicable to every test (if we had more), not just HAVE_C99_VSNPRINTF. Could also be a #define but let's go with this for now. This takes advantage of the stack based design of CMakePushCheckState. --- CMakeLists.txt | 1 + ConfigureChecks.cmake | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c23b3037dd..eac75e17f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -472,6 +472,7 @@ if(MINGW) # -D_POSIX ) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX) endif() if( CMAKE_C_COMPILER_ID MATCHES "MSVC") diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index f81abeb258..328292e699 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -107,10 +107,6 @@ check_symbol_exists(tzname "time.h" HAVE_TZNAME) # Check if the libc vsnprintf() conforms to C99. If this fails we may # need to fall-back on GLib I/O. # -cmake_push_check_state(RESET) -if(MINGW) - set(CMAKE_REQUIRED_DEFINITIONS -D__USE_MINGW_ANSI_STDIO) -endif() check_c_source_runs(" #include int main(void) @@ -124,7 +120,6 @@ check_c_source_runs(" }" HAVE_C99_VSNPRINTF ) -cmake_pop_check_state() if (NOT HAVE_C99_VSNPRINTF) message(FATAL_ERROR "Building Wireshark requires a C99 compliant vsnprintf() and this \