]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix `pkg-config`-based detection in `FindGSS.cmake`
authorViktor Szakats <commit@vsz.me>
Tue, 6 Aug 2024 23:19:44 +0000 (01:19 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 7 Aug 2024 13:13:07 +0000 (15:13 +0200)
Before this patch `pkg-config`-based detection was ignored, and used
solely as a path hint for native detection.

- fix `pkg_search_module()` result prefix to match what code expects:
  `_GSS` (was: `_GSS_PKG`). Update variable that were in sync with old
  prefix.

- update the pkg-config codepath to use `_GSS_MODULE_NAME` to detect
  GSS flavour. This requires CMake 3.16.
  Otherwise fall back to the old method. (The old method doesn't seem to
  work anymore (?) as of CMake 3.30.1. Documented
  `<prefix>_<modulename>_VERSION` variable is defined, but empty.)

- update the pkg-config codepath to use `_GSS_VERSION` set by CMake.
  Resort to the old code when this variable is empty. (The old code
  doesn't seem to work anymore (?) as of CMake 3.30.1)

- fix pkg-config codepath to set the documented result variables.

- align native detection variable names with those generated by
  `pkg_search_module()` in the pkg-config codepath.

- GHA/macos: enable GSS Heimdal in a cmake job.
  Uses the native detection.

- GHA/linux: enable GSS Heimdal in cmake and autotools jobs.
  CMake uses `pkg-config`-based detection.

- suppress test 2077 and 2078 results on Linux + Heimdal.
  ```
  FAIL-IGNORED 2077: 'curl --fail --negotiate to unauthenticated service fails' HTTP, HTTP GET, GSS-API
  FAIL-IGNORED 2078: 'curl --negotiate should not send empty POST request only' HTTP, HTTP GET, GSS-API
  ```
  Failing with valgrind errors in both autotools and cmake builds:
  https://github.com/curl/curl/actions/runs/10282222581/job/28453472068?pr=14430#step:38:3638
  https://github.com/curl/curl/actions/runs/10282222581/job/28453473398?pr=14430#step:38:7831

Closes #14430

.github/workflows/linux.yml
.github/workflows/macos.yml
CMake/FindGSS.cmake

index bd5208c689d1bb9ce90ea4422b56c45c7fd4a392..336c1680b95231aa2162adfe822f956981d65d41 100644 (file)
@@ -78,16 +78,16 @@ jobs:
             configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/bearssl/lib" --with-bearssl=$HOME/bearssl --enable-debug
             singleuse: --unit
 
-          - name: libressl
-            install_packages: zlib1g-dev valgrind
+          - name: libressl heimdal
+            install_packages: zlib1g-dev heimdal-dev valgrind
             install_steps: libressl pytest
-            configure: LDFLAGS="-Wl,-rpath,$HOME/libressl/lib" --with-openssl=$HOME/libressl --enable-debug
+            configure: LDFLAGS="-Wl,-rpath,$HOME/libressl/lib" --with-openssl=$HOME/libressl --with-gssapi --enable-debug
             singleuse: --unit
 
-          - name: libressl
-            install_packages: zlib1g-dev valgrind
+          - name: libressl heimdal
+            install_packages: zlib1g-dev heimdal-dev valgrind
             install_steps: libressl pytest
-            generate: -DOPENSSL_ROOT_DIR=$HOME/libressl -DENABLE_DEBUG=ON -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON
+            generate: -DOPENSSL_ROOT_DIR=$HOME/libressl -DCURL_USE_GSSAPI=ON -DENABLE_DEBUG=ON -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON
             singleuse: --unit
 
           - name: libressl-clang
@@ -468,10 +468,13 @@ jobs:
         if: ${{ matrix.build.generate }}
         name: 'make tests (cmake)'
 
-      - run: make V=1 VERBOSE=1 test-ci
-        name: 'run tests'
-        env:
-          TFLAGS: "${{ matrix.build.tflags }}"
+      - name: 'run tests'
+        run: |
+          export TFLAGS='${{ matrix.build.tflags }}'
+          if [[ '${{ matrix.build.install_packages }}' = *'heimdal-dev'* ]]; then
+            TFLAGS+=' ~2077 ~2078'  # valgrind errors
+          fi
+          make V=1 VERBOSE=1 test-ci
 
       - if: contains(matrix.build.install_steps, 'pytest')
         # run for `tests` directory, so pytest does not pick up any other
index 18e52ebe85c5d320f611f726583ef8c45a66b1f6..2bebf79d488f24dc10d6c8bf74b099edfea60e73 100644 (file)
@@ -283,9 +283,9 @@ jobs:
           - name: 'SecureTransport ws debug+'
             generate: -DCURL_USE_SECTRANSP=ON -DENABLE_WEBSOCKETS=ON -DENABLE_DEBUG=ON -DENABLE_CURLDEBUG=ON
             macos-version-min: '10.8'
-          - name: 'LibreSSL !ldap'
-            install: libressl
-            generate: -DOPENSSL_ROOT_DIR=$(brew --prefix libressl) -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DBUILD_EXAMPLES=ON
+          - name: 'LibreSSL !ldap heimdal'
+            install: libressl heimdal
+            generate: -DOPENSSL_ROOT_DIR=$(brew --prefix libressl) -DCURL_USE_GSSAPI=ON -DGSS_ROOT_DIR=$(brew --prefix heimdal) -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DBUILD_EXAMPLES=ON
             macos-version-min: '10.15'
           - name: 'wolfSSL !ldap'
             install: wolfssl
index 94e074bc5e88b1cfdf1a5e53aadf2c14ec6b35a8..811803610972e17ea99613ddeff4badc32bf76ef 100644 (file)
@@ -53,8 +53,8 @@ set(_GSS_ROOT_HINTS
 if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}")
   if(UNIX)
     find_package(PkgConfig QUIET)
-    pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
-    list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}")
+    pkg_search_module(_GSS ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
+    list(APPEND _GSS_ROOT_HINTS "${_GSS_PREFIX}")
   elseif(WIN32)
     list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
   endif()
@@ -97,9 +97,9 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
       foreach(_flag ${_GSS_CFLAGS})
         if(_flag MATCHES "^-I.*")
           string(REGEX REPLACE "^-I" "" _val "${_flag}")
-          list(APPEND _GSS_INCLUDE_DIR "${_val}")
+          list(APPEND _GSS_INCLUDE_DIRS "${_val}")
         else()
-          list(APPEND _GSS_COMPILER_FLAGS "${_flag}")
+          list(APPEND _GSS_CFLAGS "${_flag}")
         endif()
       endforeach()
     endif()
@@ -124,9 +124,9 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
           list(APPEND _GSS_LIBRARIES "${_val}")
         elseif(_flag MATCHES "^-L.*")
           string(REGEX REPLACE "^-L" "" _val "${_flag}")
-          list(APPEND _GSS_LINK_DIRECTORIES "${_val}")
+          list(APPEND _GSS_LIBRARY_DIRS "${_val}")
         else()
-          list(APPEND _GSS_LINKER_FLAGS "${_flag}")
+          list(APPEND _GSS_LDFLAGS "${_flag}")
         endif()
       endforeach()
     endif()
@@ -163,7 +163,7 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
 
   else()  # Either there is no config script or we are on a platform that does not provide one (Windows?)
 
-    find_path(_GSS_INCLUDE_DIR
+    find_path(_GSS_INCLUDE_DIRS
       NAMES
         "gssapi/gssapi.h"
       HINTS
@@ -173,8 +173,8 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
         inc
     )
 
-    if(_GSS_INCLUDE_DIR)  # jay, we have found something
-      set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}")
+    if(_GSS_INCLUDE_DIRS)  # jay, we have found something
+      set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIRS}")
       check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS)
 
       if(_GSS_HAVE_MIT_HEADERS)
@@ -192,7 +192,7 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
       endif()
     else()
       # I am not convinced if this is the right way but this is what autotools do at the moment
-      find_path(_GSS_INCLUDE_DIR
+      find_path(_GSS_INCLUDE_DIRS
         NAMES
           "gssapi.h"
         HINTS
@@ -202,7 +202,7 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
           inc
       )
 
-      if(_GSS_INCLUDE_DIR)
+      if(_GSS_INCLUDE_DIRS)
         set(GSS_FLAVOUR "Heimdal")
       endif()
     endif()
@@ -211,7 +211,7 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
     if(GSS_FLAVOUR)
       set(_GSS_LIBDIR_SUFFIXES "")
       set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS})
-      get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH)
+      get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIRS}" PATH)
       list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT})
 
       if(WIN32)
@@ -250,20 +250,24 @@ if(NOT _GSS_FOUND)  # Not found by pkg-config. Let us take more traditional appr
     endif()
   endif()
 else()
-  if(_GSS_PKG_${_MIT_MODNAME}_VERSION)
+  if(_GSS_MODULE_NAME STREQUAL _MIT_MODNAME OR _GSS_${_MIT_MODNAME}_VERSION)  # _GSS_MODULE_NAME set since CMake 3.16
     set(GSS_FLAVOUR "MIT")
-    set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION)
+    if(NOT _GSS_VERSION)  # for old CMake versions?
+      set(_GSS_VERSION _GSS_${_MIT_MODNAME}_VERSION)
+    endif()
   else()
     set(GSS_FLAVOUR "Heimdal")
-    set(_GSS_VERSION _GSS_PKG_${_HEIMDAL_MODNAME}_VERSION)
+    if(NOT _GSS_VERSION)  # for old CMake versions?
+      set(_GSS_VERSION _GSS_${_HEIMDAL_MODNAME}_VERSION)
+    endif()
   endif()
 endif()
 
-set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR})
+set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIRS})
 set(GSS_LIBRARIES ${_GSS_LIBRARIES})
-set(GSS_LINK_DIRECTORIES ${_GSS_LINK_DIRECTORIES})
-set(GSS_LINKER_FLAGS ${_GSS_LINKER_FLAGS})
-set(GSS_COMPILER_FLAGS ${_GSS_COMPILER_FLAGS})
+set(GSS_LINK_DIRECTORIES ${_GSS_LIBRARY_DIRS})
+set(GSS_LINKER_FLAGS ${_GSS_LDFLAGS})
+set(GSS_COMPILER_FLAGS ${_GSS_CFLAGS})
 set(GSS_VERSION ${_GSS_VERSION})
 
 if(GSS_FLAVOUR)