OpenMiInk/third_party/krita-deps-management/cmake/run-pip-install-with-destdir.cmake
Hellings b8c8ff98e2 Hi
2026-10-16 09:05:56 -04:00

33 lines
1.1 KiB
CMake

LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/kde_macro")
include (KritaToNativePath)
if (DEFINED ENV{DESTDIR})
set(DESTDIR $ENV{DESTDIR})
cmake_path(ABSOLUTE_PATH DESTDIR NORMALIZE)
krita_to_native_path("${DESTDIR}" DESTDIR)
set(DESTDIR_ARGS "--root=${DESTDIR}")
endif()
set(FOUND_SEPARATOR FALSE)
foreach(i RANGE 0 ${CMAKE_ARGC})
if ("${CMAKE_ARGV${i}}" STREQUAL "--")
set(FOUND_SEPARATOR TRUE)
elseif (FOUND_SEPARATOR)
list(APPEND EXTRA_ARGS ${CMAKE_ARGV${i}})
endif()
endforeach()
# message("extra args: ${EXTRA_ARGS}")
exec_program(${Python_EXECUTABLE} ARGS -m ensurepip ${DESTDIR_ARGS} RETURN_VALUE RETVAL)
if (RETVAL)
message(FATAL_ERROR "failed to execute python -m ensurepip")
endif()
message ("Running setup with args: ${Python_EXECUTABLE} -m pip install ${DESTDIR_ARGS} ${EXTRA_DESTDIR_ARGS} ${EXTRA_ARGS}")
exec_program(${Python_EXECUTABLE} ARGS -m pip install ${DESTDIR_ARGS} ${EXTRA_ARGS} RETURN_VALUE RETVAL)
if (RETVAL)
message(FATAL_ERROR "failed to execute pip install")
endif()