Skip to content

Instantly share code, notes, and snippets.

@tritao
Created February 12, 2025 15:25
Show Gist options
  • Save tritao/08e71a11e1e3ea558f8b7938839a8e22 to your computer and use it in GitHub Desktop.
Save tritao/08e71a11e1e3ea558f8b7938839a8e22 to your computer and use it in GitHub Desktop.
diff --git a/cMake/FreeCAD_Helpers/SetupPython.cmake b/cMake/FreeCAD_Helpers/SetupPython.cmake
index a2887affcb..6043fba779 100644
--- a/cMake/FreeCAD_Helpers/SetupPython.cmake
+++ b/cMake/FreeCAD_Helpers/SetupPython.cmake
@@ -18,4 +18,12 @@ macro(SetupPython)
message(FATAL_ERROR "To build FreeCAD you need at least Python 3.8\n")
endif()
+ # If a custom Python directory was passed in, then save it as PYTHON_HOME_DIR,
+ # which is used by config.h.cmake when generating the config header file.
+ if (DEFINED Python3_ROOT_DIR)
+ set(HAVE_PYTHON_HOME_DIR ON)
+ file(REAL_PATH "${Python3_ROOT_DIR}" PYTHON_HOME_DIR)
+ endif ()
+
+
endmacro(SetupPython)
diff --git a/src/config.h.cmake b/src/config.h.cmake
index 97c068e6cf..2208fc48a8 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -117,6 +117,12 @@
/* Define to 1 if you have a C runtime with backtrace symbols. */
#cmakedefine HAVE_BACKTRACE_SYMBOLS
+/* Define to 1 if we have a custom Python home root directory. */
+#cmakedefine HAVE_PYTHON_HOME_DIR
+
+/* Path to the custom Python home root directory (PYTHONHOME) */
+#define PYTHON_HOME_DIR "${PYTHON_HOME_DIR}"
+
/* Name of package */
#define PACKAGE "FreeCAD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment