mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 20:30:05 +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
|
|
@ -1,5 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
set(PROJECT_NAME supercell-wx)
|
||||
|
||||
include(tools/scwx_config.cmake)
|
||||
|
||||
scwx_python_setup()
|
||||
|
||||
project(${PROJECT_NAME}
|
||||
VERSION 0.4.9
|
||||
DESCRIPTION "Supercell Wx is a free, open source advanced weather radar viewer."
|
||||
|
|
@ -11,8 +16,6 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
|||
set(CMAKE_POLICY_DEFAULT_CMP0079 NEW)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0148 OLD) # aws-sdk-cpp uses FindPythonInterp
|
||||
|
||||
include(tools/scwx_config.cmake)
|
||||
|
||||
scwx_output_dirs_setup()
|
||||
|
||||
enable_testing()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/external/cmake-conan/conan_provider.cmake"
|
||||
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/external/cmake-conan/conan_provider.cmake",
|
||||
"SCWX_VIRTUAL_ENV": "${sourceDir}/.venv"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="%script_dir%\..\..\external\cmake-conan\conan_provider.cmake" ^
|
||||
-DCONAN_HOST_PROFILE=%conan_profile% ^
|
||||
-DCONAN_BUILD_PROFILE=%conan_profile% ^
|
||||
-DSCWX_VENV_PATH=%venv_path%
|
||||
-DSCWX_VIRTUAL_ENV=%venv_path%
|
||||
|
||||
@if defined build_type (
|
||||
set cmake_args=%cmake_args% ^
|
||||
|
|
|
|||
|
|
@ -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