From: Viktor Szakats Date: Mon, 10 Feb 2025 04:57:49 +0000 (+0100) Subject: cmake: fix `HAVE_GETHOSTBYNAME_R_*` detections with `CURL_WERROR=ON` X-Git-Tag: curl-8_12_1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1d1c98b7f377e0d170b590b6c814697b22ee3c6;p=thirdparty%2Fcurl.git cmake: fix `HAVE_GETHOSTBYNAME_R_*` detections with `CURL_WERROR=ON` Fix `HAVE_GETHOSTBYNAME_R_*` feature detections always failing with `CURL_WERROR=ON` due to stripping a const. Also fix the GHA/cmake-vs-configure to enable `CURL_WERROR=ON` to sync this setting with `./configure` which enables it by default. With that, CI detects this issue. ``` CMake/CurlTests.c:73:19: error: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 73 | char *address = "example.com"; | ^~~~~~~~~~~~~ ``` Ref: https://github.com/curl/curl/actions/runs/13225827821/job/36916564107#step:33:4198 Closes #16282 --- diff --git a/.github/workflows/configure-vs-cmake.yml b/.github/workflows/configure-vs-cmake.yml index dfe2ed622f..7130c7e6d4 100644 --- a/.github/workflows/configure-vs-cmake.yml +++ b/.github/workflows/configure-vs-cmake.yml @@ -48,7 +48,7 @@ jobs: - name: 'run cmake' run: | - cmake -B bld-cm -DCURL_USE_LIBPSL=OFF -DCURL_BROTLI=OFF + cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_BROTLI=OFF - name: 'configure log' run: cat bld-am/config.log 2>/dev/null || true @@ -88,7 +88,7 @@ jobs: - name: 'run cmake' run: | - cmake -B bld-cm -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \ + cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \ -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \ -DCURL_BROTLI=OFF \ -DCURL_USE_LIBSSH2=OFF @@ -128,7 +128,7 @@ jobs: - name: 'run cmake' run: | - cmake -B bld-cm -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \ + cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \ -DCMAKE_SYSTEM_NAME=Windows \ -DCMAKE_C_COMPILER_TARGET="${TRIPLET}" \ -DCMAKE_C_COMPILER="${TRIPLET}-gcc" diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index 1428238cb0..8aa28a310a 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -70,7 +70,7 @@ int main(void) #include int main(void) { - char *address = "example.com"; + const char *address = "example.com"; int length = 0; int type = 0; struct hostent h;