Author: brane
Date: Thu May 29 00:22:08 2025
New Revision: 1925922
URL: http://svn.apache.org/viewvc?rev=1925922&view=rev
Log:
Add support for using GSSAPI to the CMake build.
* build/FindGSSAPI.cmake: New module for finding GSSAPI.
* CMakeLists.txt: Find and use the package, and add its libraries to the
pkg-config file (along with ZLIB libraries).
Added:
serf/trunk/build/FindGSSAPI.cmake
Modified:
serf/trunk/CMakeLists.txt
Modified: serf/trunk/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1925922&r1=1925921&r2=1925922&view=diff
==============================================================================
--- serf/trunk/CMakeLists.txt (original)
+++ serf/trunk/CMakeLists.txt Thu May 29 00:22:08 2025
@@ -54,7 +54,7 @@ option(APR_ROOT:PATH "Path to APR's inst
option(APRUtil_ROOT:PATH "Path to APR-Util's install area" "")
option(OPENSSL_ROOT_DIR:PATH "Path to OpenSSL's install area" "")
option(ZLIB_ROOT:PATH "Path to zlib's install area" "")
-option(BROTLI_ROOT:PATH "Path to GSSAPI's install area" "")
+option(BROTLI_ROOT:PATH "Path to Brotli's install area" "")
option(GSSAPI_ROOT:PATH "Path to GSSAPI's install area" "")
# Build options
@@ -210,10 +210,6 @@ if(BROTLI_ROOT)
message(WARNING "option BROTLI_ROOT is not implemented")
endif()
-if(GSSAPI_ROOT)
- message(WARNING "option GSSAPI_ROOT is not implemented")
-endif()
-
if(SERF_WINDOWS)
if(EXPAT)
set(PC_EXPAT_INCLUDE_DIRS "${EXPAT}/include")
@@ -225,14 +221,23 @@ else(SERF_WINDOWS)
endif(EXPAT)
endif(SERF_WINDOWS)
-# Find dependencies
+# Find required dependencies
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(APR REQUIRED)
find_package(APRUtil REQUIRED)
+# Find optional dependencies
+find_package(GSSAPI)
+if(GSSAPI_FOUND)
+ add_definitions("-DSERF_HAVE_GSSAPI")
+endif()
+
# Calculate the set of private and public targets
set(SERF_PRIVATE_TARGETS OpenSSL::Crypto OpenSSL::SSL ZLIB::ZLIB)
+if(GSSAPI_FOUND)
+ list(APPEND SERF_PRIVATE_TARGETS KRB5::GSSAPI)
+endif()
if(APR_STATIC)
if(SERF_WINDOWS)
@@ -395,6 +400,8 @@ if(NOT SERF_WINDOWS)
${APRUTIL_LDFLAGS}
${APRUTIL_LIBRARIES}
${APRUTIL_EXTRALIBS}
+ ${GSSAPI_LIBRARIES}
+ ${ZLIB_LIBRARIES}
)
list(REMOVE_DUPLICATES SERF_INTERFACE_LIBS)
unset(LIBS)
Added: serf/trunk/build/FindGSSAPI.cmake
URL:
http://svn.apache.org/viewvc/serf/trunk/build/FindGSSAPI.cmake?rev=1925922&view=auto
==============================================================================
--- serf/trunk/build/FindGSSAPI.cmake (added)
+++ serf/trunk/build/FindGSSAPI.cmake Thu May 29 00:22:08 2025
@@ -0,0 +1,103 @@
+# ===================================================================
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ===================================================================
+
+cmake_minimum_required(VERSION 3.12)
+
+set(GSSAPI_FOUND FALSE)
+
+if(DEFINED GSSAPI_ROOT)
+ get_filename_component(GSSAPI_ROOT "${GSSAPI_ROOT}" REALPATH)
+ find_program(KRB5_CONFIG_EXECUTABLE NAMES "krb5-config"
+ PATHS "${GSSAPI_ROOT}/bin" NO_DEFAULT_PATH)
+else()
+ find_program(KRB5_CONFIG_EXECUTABLE NAMES "krb5-config")
+endif()
+mark_as_advanced(KRB5_CONFIG_EXECUTABLE)
+
+if("${KRB5_CONFIG_EXECUTABLE}" STREQUAL "KRB5_CONFIG_EXECUTABLE-NOTFOUND")
+ message(STATUS "Could NOT find GSSAPI (missing: krb5-config)")
+else()
+ function(_krb5_config _varname _dedup)
+ execute_process(COMMAND ${KRB5_CONFIG_EXECUTABLE} ${ARGN} "gssapi"
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE failed)
+ if(failed)
+ message(FATAL_ERROR "failed: ${KRB5_CONFIG_EXECUTABLE} ${ARGN} gssapi")
+ endif()
+ string(STRIP "${output}" output)
+ if(_dedup)
+ separate_arguments(output)
+ list(REMOVE_DUPLICATES output)
+ endif()
+ set(${_varname} ${output} PARENT_SCOPE)
+ endfunction(_krb5_config)
+
+ _krb5_config(GSSAPI_INCLUDES TRUE --cflags)
+ _krb5_config(GSSAPI_LIBRARIES TRUE --libs)
+ _krb5_config(GSSAPI_VERSION FALSE --version)
+
+ # Filter everything but include paths from --cflags
+ list(FILTER GSSAPI_INCLUDES INCLUDE REGEX "^-I")
+
+ # Figure out the import location. First, try with -L options in the libs.
+ function(_find_location _variable _filter)
+ set(tmp ${ARGN})
+ list(FILTER tmp INCLUDE REGEX "${_filter}")
+ list(LENGTH tmp len)
+ if(${len} EQUAL 0)
+ unset(${_variable} PARENT_SCOPE)
+ else()
+ list(GET tmp 0 first)
+ string(REGEX REPLACE "${_filter}" "" first "${first}")
+ set(${_variable} "${first}" PARENT_SCOPE)
+ endif()
+ endfunction(_find_location)
+
+ _find_location(_location "^-L" ${GSSAPI_LIBRARIES})
+ _find_location(_library "^-l" ${GSSAPI_LIBRARIES})
+ if(DEFINED _location)
+ find_library(_imported_location "${_library}"
+ PATHS "${_location}" NO_DEFAULT_PATH)
+ else()
+ find_library(_imported_location "${_library}")
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ list(LENGTH GSSAPI_INCLUDES _inc_len)
+ if(${_inc_len} EQUAL 0)
+ # When using default include locations, GSSAPI_INCLUDES may be empty.
+ find_package_handle_standard_args(GSSAPI
+ REQUIRED_VARS GSSAPI_LIBRARIES
+ VERSION_VAR GSSAPI_VERSION)
+ else()
+ # Remove option tags from the include paths.
+ list(TRANSFORM GSSAPI_INCLUDES REPLACE "^-I" "")
+ find_package_handle_standard_args(GSSAPI
+ REQUIRED_VARS GSSAPI_LIBRARIES GSSAPI_INCLUDES
+ VERSION_VAR GSSAPI_VERSION)
+ endif()
+
+ if(GSSAPI_FOUND)
+ add_library(KRB5::GSSAPI UNKNOWN IMPORTED)
+ set_target_properties(KRB5::GSSAPI PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GSSAPI_INCLUDES}"
+ INTERFACE_LINK_LIBRARIES "${GSSAPI_LIBRARIES}"
+ IMPORTED_LOCATION "${_imported_location}")
+ endif(GSSAPI_FOUND)
+endif() # krb5-config not found