Skip to content

Commit

Permalink
cmake: Replace deprecated exec_program() with execute_process()
Browse files Browse the repository at this point in the history
exec_program() has been deprecated since version 3.0. See here:
https://cmake.org/cmake/help/latest/command/exec_program.html

Invoking the uninstall target causes warning messages about using
deprecated exec_program() such as:
"sudo make uninstall
-- Uninstalling /usr/lib/x86_64-linux-gnu/pkgconfig/libiio.pc
CMake Warning (dev) at cmake_uninstall.cmake:49 (exec_program):
  Policy CMP0153 is not set: The exec_program command should not be called.
  Run "cmake --help-policy CMP0153" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
"

Used cmake version 3.28.3.

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jan 9, 2025
1 parent 9c579e4 commit b076a17
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
execute_process(
COMMAND @CMAKE_COMMAND@ -E rm $ENV{DESTDIR}${file}
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
RESULT_VARIABLE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
Expand All @@ -66,10 +66,10 @@ foreach(file ${files})
break()
endif()
message(STATUS "Removing empty directory: ${dir}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove_directory ${dir}"
execute_process(
COMMAND @CMAKE_COMMAND@ -E rm -rf ${dir}
OUTPUT_VARIABLE stdout
RETURN_VALUE result
RESULT_VARIABLE result
)
if(NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove directory: '${file}'.")
Expand Down

0 comments on commit b076a17

Please sign in to comment.