From: Andres Noetzli Date: Wed, 4 May 2022 20:54:41 +0000 (-0700) Subject: Improve finding Python library/includes (#8718) X-Git-Tag: cvc5-1.0.1~169 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c6e91b97a63c8085263c3e5e0513ec133763884;p=cvc5.git Improve finding Python library/includes (#8718) On macOS, find_package(PythonLibs ...) does not find the Python include directory or library when they were installed via homebrew. find_package(Python ...) is more robust, but only available on newer versions of CMake. If we are compiling cvc5 on macOS and we have a newer version of CMake available, this tries to use find_package(Python ...) to find the paths. --- diff --git a/src/api/python/CMakeLists.txt b/src/api/python/CMakeLists.txt index b5c7b917b..eb9d6ec31 100644 --- a/src/api/python/CMakeLists.txt +++ b/src/api/python/CMakeLists.txt @@ -44,6 +44,20 @@ endif() list(APPEND CMAKE_MODULE_PATH ${SKBUILD_CMAKE_MODULE_PATH}) find_package(PythonExtensions REQUIRED) + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND + CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") + # On macOS, find_package(PythonLibs ...) does not find the Python include + # directory or library when they were installed via homebrew. + # find_package(Python ...) is more robust, but only available on newer + # versions of CMake. If we are compiling cvc5 on macOS and we have a newer + # version of CMake available, we try to use find_package(Python ...) to find + # the paths. + find_package(Python COMPONENTS Development) + set(PYTHON_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") + set(PYTHON_LIBRARY "${Python_LIBRARIES}") +endif() + find_package(Cython 0.29 REQUIRED) set(CYTHON_FLAGS "-X embedsignature=True")