mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 08:00:06 +00:00
Add Python setup to CMakeLists.txt
This commit is contained in:
parent
ffbe3aedad
commit
ea2c2e8f58
4 changed files with 44 additions and 4 deletions
|
|
@ -17,3 +17,39 @@ macro(scwx_output_dirs_setup)
|
|||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/Debug/lib)
|
||||
endmacro()
|
||||
|
||||
macro(scwx_python_setup)
|
||||
set(SCWX_VIRTUAL_ENV "" CACHE STRING "Python Virtual Environment")
|
||||
|
||||
# Use a Python Virtual Environment
|
||||
if (SCWX_VIRTUAL_ENV)
|
||||
set(ENV{VIRTUAL_ENV} "${SCWX_VIRTUAL_ENV}")
|
||||
|
||||
if (WIN32)
|
||||
set(Python3_EXECUTABLE "$ENV{VIRTUAL_ENV}/Scripts/python.exe")
|
||||
else()
|
||||
set(Python3_EXECUTABLE "$ENV{VIRTUAL_ENV}/bin/python")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using virtual environment: $ENV{VIRTUAL_ENV}")
|
||||
else()
|
||||
message(STATUS "Python virtual environment undefined")
|
||||
endif()
|
||||
|
||||
# Find Python
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
# Verify we're using the right Python
|
||||
message(STATUS "Python executable: ${Python3_EXECUTABLE}")
|
||||
message(STATUS "Python version: ${Python3_VERSION}")
|
||||
|
||||
# Only if we are in an application defined virtual environment
|
||||
if (SCWX_VIRTUAL_ENV)
|
||||
# Setup pip
|
||||
set(PIP_ARGS install --upgrade -r "${CMAKE_SOURCE_DIR}/requirements.txt")
|
||||
|
||||
# Install requirements
|
||||
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip ${PIP_ARGS}
|
||||
RESULT_VARIABLE PIP_RESULT)
|
||||
endif()
|
||||
endmacro()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue