Skip to content

Commit 28ac2e1

Browse files
committed
[cmake] Respect Python virtualenv on macOS
Fix issue where CMake ignores the Python interpreter specified by a virtual environment by default. This results in the generate targets failing when the Python package requirements are installed in a virtual environment but the system interpreter is found by CMake. This patch replaces the use of `CMAKE_FIND_FRAMEWORK` with the more precise `Python3_FIND_FRAMEWORK`. It also sets the `Python3_FIND_STRATEGY` to `LOCATION` which stops searching once the first Python interpreter is found, i.e. the interpreter from an activated virtual environment, or the system interpreter otherwise.
1 parent e40a321 commit 28ac2e1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1515
include(helpers)
1616

1717
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
18-
set(CMAKE_FIND_FRAMEWORK NEVER)
18+
set(Python3_FIND_FRAMEWORK NEVER)
19+
set(Python3_FIND_STRATEGY LOCATION)
1920
endif()
2021

2122
find_package(Python3 COMPONENTS Interpreter REQUIRED)

0 commit comments

Comments
 (0)