From 4258af45dd6fb70cce325f041a1df890325641eb Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 11 May 2026 16:57:32 +0200 Subject: [PATCH] cmake_path removed --- CMakeLists.txt | 53 ++++++++++---------------------------------------- README.md | 6 +++--- appveyor.yml | 2 +- 3 files changed, 14 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74a14e90..40ef4a71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ endif() option(WITH_OPENGL_MODERN "Compile with OpenGL modern renderer" ON) option(WITH_OPENGL_LEGACY "Compile with OpenGL legacy renderer" ON) -option(WITH_PYTHON "Compile with python3" ON) +option(WITH_PYTHON "Python 3.14 embedded scripting" ON) option(WITH_UART "Compile with libserialport" ON) option(WITH_LUA "Compile with lua scripting support" ON) option(WITH_OPENVR "Compile with OpenVR" OFF) @@ -81,10 +81,6 @@ option(WITH_BETTER_RENDERER "Experimental multi-backend renderer based on NVRHI" option(GENERATE_PDB "Generate executable with program debugging symbols" ON) option(ENABLE_MCC "Enable multicore compilation" ON) option(WITHDUMPGEN "Enable generating DMP files on crash" ON) -if(WIN32) - option(WITH_PYTHON_AUTO_INSTALL_WIN "If Python 3.14 Development is missing, install into tools/python314 (network)" ON) -endif() - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # vcpkg init @@ -253,7 +249,7 @@ if (WITH_CRASHPAD) endif() endif() -if (WITH_PYTHON) +if(WITH_PYTHON) set(DEFINITIONS ${DEFINITIONS} "WITH_PYTHON") set(SOURCES ${SOURCES} "scripting/PyInt.cpp") else() @@ -468,37 +464,15 @@ endif() target_link_libraries(${PROJECT_NAME} glfw) if(WITH_PYTHON) - set(_py_tools "${CMAKE_SOURCE_DIR}/tools/python314") - set(_pyv 3.14.0) - if(WIN32) - if(EXISTS "${_py_tools}/python.exe" AND NOT Python3_ROOT_DIR) - set(Python3_ROOT_DIR "${_py_tools}" CACHE PATH "Python 3.14 (tools/python314)") - endif() - find_package(Python3 3.14 QUIET COMPONENTS Development) - endif() find_package(Python3 3.14 REQUIRED COMPONENTS Development) target_include_directories(${PROJECT_NAME} PRIVATE ${Python3_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${Python3_LIBRARIES}) + if(WIN32) - cmake_path(GET Python3_EXECUTABLE PARENT_PATH _px) - set(_rt "") - if(Python3_RUNTIME_LIBRARY_DIRS) - list(GET Python3_RUNTIME_LIBRARY_DIRS 0 _rt) - endif() - if(NOT _rt) - set(_rt "${_px}") - endif() - set(EU07_PY_DLL "${_rt}/python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}.dll") - set(EU07_PY_ZLIB "${_rt}/zlib1.dll") - set(EU07_PY_LIBDIR "${_px}/Lib") - set(EU07_PY_DLLSDIR "${_px}/DLLs") - set(_vpt "${VCPKG_INSTALLED_PATH}/tools/python3") - if(NOT EXISTS "${EU07_PY_LIBDIR}") - set(EU07_PY_LIBDIR "${_vpt}/Lib") - endif() - if(NOT EXISTS "${EU07_PY_DLLSDIR}") - set(EU07_PY_DLLSDIR "${_vpt}/DLLs") - endif() + set(EU07_PY_DLL "${Python3_ROOT_DIR}/python314.dll") + set(EU07_PY_ZLIB "${Python3_ROOT_DIR}/zlib1.dll") + set(EU07_PY_LIBDIR "${Python3_ROOT_DIR}/Lib") + set(EU07_PY_DLLSDIR "${Python3_ROOT_DIR}/DLLs") endif() endif() @@ -583,18 +557,11 @@ if (WIN32) endif () if(WIN32 AND WITH_PYTHON) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EU07_PY_DLL}" "$" - ) - if(EXISTS "${EU07_PY_ZLIB}") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EU07_PY_ZLIB}" "$" - ) - endif() - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${EU07_PY_ZLIB}" "$" COMMAND ${CMAKE_COMMAND} -E copy_directory "${EU07_PY_LIBDIR}" "$/python64/Lib" - ) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${EU07_PY_DLLSDIR}" "$/python64/DLLs" ) endif() diff --git a/README.md b/README.md index e86aae2a..9bf9b8e1 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ MaSzyna compiles and runs natively on **Linux** and **Windows**. Other platforms | `-DCMAKE_BUILD_TYPE=Release` | Release build | | `-DCMAKE_BUILD_TYPE=RelWithDebInfo` | Release build with debug symbols | | `-DWITH_BETTER_RENDERER=ON/OFF` | Enable/disable NVRHI-based renderer | -| `-DPython3_ROOT_DIR=` | Root directory of the **Python 3.14** install to use (embedding); needed if several versions are present | +| `-DPython3_ROOT_DIR=` | Root of the **Python 3.14** install on Windows (`python.exe`, `Lib`, `DLLs`) for embed/copy steps; on Linux, optional if CMake picks the wrong interpreter | > **Linux note:** `WITH_BETTER_RENDERER` uses DirectX 12 through NVRHI and is **not supported on Linux**. @@ -107,9 +107,9 @@ MaSzyna compiles and runs natively on **Linux** and **Windows**. Other platforms ## Windows -Install **Python 3.14 x64** from [python.org](https://www.python.org/downloads/windows/) and include the optional **Python native development** feature (headers and `.lib` for embedding). If CMake picks another interpreter, pass `-DPython3_ROOT_DIR="C:\Path\To\Python314"` on the `cmake` line. +Install **Python 3.14 x64** from [python.org](https://www.python.org/downloads/windows/) and include the optional **Python native development** feature (headers and `.lib` for embedding). Pass `-DPython3_ROOT_DIR="C:\Path\To\Python314"` on the `cmake` line when you want the layout under that directory used for embedding and for copying `Lib` / `DLLs` next to the executable. -**AppVeyor CI** builds with the worker image’s preinstalled Python at `C:/Python314-x64` (see [`appveyor.yml`](./appveyor.yml): `-DPython3_ROOT_DIR=...` and `-DWITH_PYTHON_AUTO_INSTALL_WIN=OFF`). +**AppVeyor CI** builds with the worker image’s preinstalled Python at `C:/Python314-x64` (see [`appveyor.yml`](./appveyor.yml): `-DPython3_ROOT_DIR=...`). ```powershell # Clone repository with submodules diff --git a/appveyor.yml b/appveyor.yml index fdb15110..3a189dc9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,7 @@ before_build: - cmd: | if not exist build mkdir build cd build - cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=%CONFIG% -DPython3_ROOT_DIR=C:/Python314-x64 -DWITH_PYTHON_AUTO_INSTALL_WIN=OFF + cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=%CONFIG% -DPython3_ROOT_DIR=C:/Python314-x64 build_script: - cmd: |