1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-10 06:23:02 +03:00

cmake: add linter, fix issues

Ref: https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
Ref: https://github.com/cheshirekow/cmake_format

Closes #1610
This commit is contained in:
Viktor Szakats
2025-06-10 22:30:54 +02:00
parent d7cf63bb05
commit 694b9d964b
12 changed files with 112 additions and 41 deletions

View File

@@ -35,8 +35,10 @@
#
# SPDX-License-Identifier: BSD-3-Clause
include(CheckFunctionExists)
include(CheckLibraryExists)
# - check_function_exists_maybe_need_library(<function> <var> [lib1 ... libn])
# libssh2_check_function_exists_may_need_library(<function> <var> [lib1 ... libn])
#
# Check if function is available for linking, first without extra libraries, and
# then, if not found that way, linking in each optional library as well. This
@@ -56,11 +58,7 @@
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#
include(CheckFunctionExists)
include(CheckLibraryExists)
function(check_function_exists_may_need_library _function _variable)
function(libssh2_check_function_exists_may_need_library _function _variable)
check_function_exists(${_function} ${_variable})
@@ -72,7 +70,7 @@ function(check_function_exists_may_need_library _function _variable)
check_library_exists(${_lib} ${_function} "" HAVE_${_function}_IN_${_lib})
if(HAVE_${_function}_IN_${_lib})
set(${_variable} 1 CACHE INTERNAL "Function ${_function} found in library ${_lib}")
set(NEED_LIB_${_up_lib} 1 CACHE INTERNAL "Need to link ${_lib}")
set(NEED_LIB_${_up_lib} 1 CACHE INTERNAL "Need to link ${_lib}") # cmake-lint: disable=C0103
break()
endif()
endforeach()