Skip to content

Commit af679ec

Browse files
committed
cmake: use modern alternative for get_filename_component()
- use `cmake_path()` to query filenames, with CMake 3.20 or upper. https://cmake.org/cmake/help/v4.1/command/cmake_path.html#query - also quote the value passed to `get_filename_component()` where missing. (Could not cause an actual issue as used in the code.) Closes libssh2#1673
1 parent a30ea29 commit af679ec

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,13 @@ if(NOT LIBSSH2_DISABLE_INSTALL)
291291
if(_lib MATCHES "/")
292292
# This gets a bit more complex, because we want to specify the
293293
# directory separately, and only once per directory
294-
get_filename_component(_libdir ${_lib} DIRECTORY)
295-
get_filename_component(_libname ${_lib} NAME_WE)
294+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
295+
cmake_path(GET _lib PARENT_PATH _libdir)
296+
cmake_path(GET _lib STEM _libname)
297+
else()
298+
get_filename_component(_libdir "${_lib}" DIRECTORY)
299+
get_filename_component(_libname "${_lib}" NAME_WE)
300+
endif()
296301
if(_libname MATCHES "^lib")
297302
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
298303
cmake_path(SET _libdir NORMALIZE "${_libdir}")

0 commit comments

Comments
 (0)