From daba2b76fc510eb25c3e9c8bf97ea4ae04497927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Osztrogon=C3=A1c?= Date: Mon, 11 Jan 2021 11:26:47 +0100 Subject: [PATCH] Fix HAVE_M_LIB check for older CMake (#4437) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With older CMake (for example 2.8.12.2) the feature check of HAVE_M_LIB reports false positive fail due to -Werror=strict-prototypes. It is already fixed in CMake https://gitlab.kitware.com/cmake/cmake/-/commit/4bc17345 The feature is present and works, so we should only ignore this build warning. Additionally the necessary GCC/Clang guard added to the similar CMake feature check in jerry-port/default/CMakeLists.txt JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu --- jerry-core/CMakeLists.txt | 3 +++ jerry-port/default/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index 73b1bd7e6..1fa9e80b0 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -416,6 +416,9 @@ if(JERRY_MATH) target_link_libraries(${JERRY_CORE_NAME} jerry-math) set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-math) else() + if(USING_GCC OR USING_CLANG) + set(CMAKE_REQUIRED_FLAGS "-Wno-error=strict-prototypes") + endif() check_library_exists(m sin "" HAVE_M_LIB) if(HAVE_M_LIB) target_link_libraries(${JERRY_CORE_NAME} m) diff --git a/jerry-port/default/CMakeLists.txt b/jerry-port/default/CMakeLists.txt index 68c766205..e9ac6754b 100644 --- a/jerry-port/default/CMakeLists.txt +++ b/jerry-port/default/CMakeLists.txt @@ -54,7 +54,9 @@ INCLUDE (CheckStructHasMember) # CHECK_STRUCT_HAS_MEMBER works by trying to compile some C code that accesses the # given field of the given struct. However, our default compiler options break this # C code, so turn a couple of them off for this. -set(CMAKE_REQUIRED_FLAGS "-Wno-error=strict-prototypes -Wno-error=old-style-definition -Wno-error=unused-value") +if(USING_GCC OR USING_CLANG) + set(CMAKE_REQUIRED_FLAGS "-Wno-error=strict-prototypes -Wno-error=old-style-definition -Wno-error=unused-value") +endif() # tm.tm_gmtoff is non-standard, so glibc doesn't expose it in c99 mode # (our default). Define some macros to expose it anyway. set(CMAKE_REQUIRED_DEFINITIONS "-D_BSD_SOURCE -D_DEFAULT_SOURCE")