From: Steve Lhomme Date: Thu, 25 May 2023 09:33:23 +0000 (+0200) Subject: Fix build error when cross-compiling for Windows X-Git-Tag: v3.7.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaf60eb0f14a4b09b3037c0809411baa63ca8781;p=thirdparty%2Flibarchive.git Fix build error when cross-compiling for Windows CHECK_C_SOURCE_RUNS generates a build error when cross-compiling. ZLIB_WINAPI is the only one tested. When the run test fails, it's tested again with just a compilation. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb95e34d..f0bbfd02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,11 @@ MACRO (TRY_MACRO_FOR_LIBRARY INCLUDES LIBRARIES IF("${TRY_TYPE}" MATCHES "COMPILES") CHECK_C_SOURCE_COMPILES("${SAMPLE_SOURCE}" ${VAR}) ELSEIF("${TRY_TYPE}" MATCHES "RUNS") - CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR}) + IF(CMAKE_CROSSCOMPILING) + MESSAGE(WARNING "Cannot test run \"${VAR}\" when cross-compiling") + ELSE(CMAKE_CROSSCOMPILING) + CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR}) + ENDIF(CMAKE_CROSSCOMPILING) ELSE("${TRY_TYPE}" MATCHES "COMPILES") MESSAGE(FATAL_ERROR "UNKNOWN KEYWORD \"${TRY_TYPE}\" FOR TRY_TYPE") ENDIF("${TRY_TYPE}" MATCHES "COMPILES")