1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-31 00:03:08 +03:00

cmake: tidy up syntax, minor improvements

- make internal variables underscore-lowercase.
- unfold lines.
- fold lines setting header directories.
- fix indent.
- drop interim variable `EXAMPLES`.
- initialize some variables before populating them.
- clear a variable after use.
- add `libssh2_dumpvars()` function for debugging.
- allow to override default `CMAKE_UNITY_BUILD_BATCH_SIZE`.
- bump up default `CMAKE_UNITY_BUILD_BATCH_SIZE` to 0 (was 32).
- tidy up option descriptions.

Closes #1446
This commit is contained in:
Viktor Szakats
2024-08-19 20:33:58 +02:00
parent 570de0f23f
commit 9d9ee7807d
6 changed files with 142 additions and 127 deletions

View File

@ -60,21 +60,19 @@
include(CheckFunctionExists)
include(CheckLibraryExists)
function(check_function_exists_may_need_library function variable)
function(check_function_exists_may_need_library _function _variable)
check_function_exists(${function} ${variable})
check_function_exists(${_function} ${_variable})
if(NOT ${variable})
foreach(lib IN LISTS ARGN)
string(TOUPPER ${lib} UP_LIB)
if(NOT ${_variable})
foreach(_lib IN LISTS ARGN)
string(TOUPPER ${_lib} _up_lib)
# Use new variable to prevent cache from previous step shortcircuiting
# new test
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}")
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}")
break()
endif()
endforeach()