Skip to content

Commit e867313

Browse files
committed
Fix python tests on macOS by linking the right Python.
1 parent a5a6752 commit e867313

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ if (WIN32)
216216
find_library(WS2_LIB ws2_32)
217217
endif()
218218

219+
if (APPLE)
220+
# Prefer libraries in the PREFIX over Apple-provided frameworks:
221+
if (NOT DEFINED CMAKE_FIND_FRAMEWORK)
222+
set(CMAKE_FIND_FRAMEWORK LAST)
223+
endif()
224+
endif()
225+
219226
find_package(Threads REQUIRED)
220227
find_package(PkgConfig REQUIRED)
221228

@@ -529,6 +536,14 @@ if (WITH_PYTHON)
529536
if (NOT DEFINED Python3_FIND_UNVERSIONED_NAMES)
530537
set (Python3_FIND_UNVERSIONED_NAMES FIRST)
531538
endif()
539+
if (NOT DEFINED Python3_FIND_VIRTUALENV)
540+
# Don't prefer virtualenv python3: Prefer the one that's first on $PATH
541+
set(Python3_FIND_VIRTUALENV STANDARD)
542+
endif()
543+
if (APPLE)
544+
# The macOS SDK-provided Python framework lacks SQLite3 support
545+
set(Python3_FIND_FRAMEWORK NEVER)
546+
endif()
532547
find_package (Python3 ${PYTHON_MIN_VERSION} COMPONENTS Interpreter Development)
533548
if (NOT Python3_FOUND)
534549
message(SEND_ERROR "Python support enabled, but Python3 interpreter and/or libaries not found.")

0 commit comments

Comments
 (0)