-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build issues due to IDEs overriding the
Python_EXECUTABLE
path
Recent versions of CLion and some VScode extensions has started implicitly passing `-DPython_EXECUTABLE=<system_python>` when configuring CMake. This ends up overriding `find_package(Python)` with bad results. The fix is to no allow this by `FORCE` setting `Python_EXECUTABLE`. See the changelog entry and code comments for more details on the issue and fix.
- Loading branch information
Showing
7 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
include_guard(GLOBAL) | ||
|
||
# A hint for `find_package(Python)` | ||
set(Python_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/embedded_python" CACHE STRING "") | ||
|
||
if(WIN32) # Extra hint to speed up the find (not needed for correctness) | ||
set(Python_EXECUTABLE "${Python_ROOT_DIR}/python.exe" CACHE STRING "") | ||
# `find_package(Python)` supports specifying `Python_EXECUTABLE` to short-circuit the search. | ||
# See: https://cmake.org/cmake/help/latest/module/FindPython.html#artifacts-specification | ||
# When this variable is specified, all other hints are ignored. Note that we `FORCE` set the | ||
# variables. Otherwise, the values could be hijacked via earlier `set(CACHE)` calls or via | ||
# `-D` flags on the command line (some IDEs do this implicitly). For projects that embed | ||
# Python, it's important that there are no traces of system Python in the build. | ||
set(Python_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/embedded_python" CACHE STRING "" FORCE) | ||
if(WIN32) | ||
set(Python_EXECUTABLE "${Python_ROOT_DIR}/python.exe" CACHE STRING "" FORCE) | ||
else() | ||
set(Python_EXECUTABLE "${Python_ROOT_DIR}/bin/python3" CACHE STRING "") | ||
set(Python_EXECUTABLE "${Python_ROOT_DIR}/python3" CACHE STRING "" FORCE) | ||
endif() | ||
|
||
find_package(Python ${self.pyversion} EXACT REQUIRED GLOBAL COMPONENTS Interpreter Development) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters