Skip to content

Commit

Permalink
♻️ replace Python.cmake
Browse files Browse the repository at this point in the history
Signed-off-by: burgholzer <burgholzer@me.com>
  • Loading branch information
burgholzer committed Jan 27, 2024
1 parent 0d0c01b commit bd2fd7b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ if(BUILD_MQT_CORE_BINDINGS)
set(BINDINGS
ON
CACHE INTERNAL "Enable settings related to Python bindings")
include(cmake/Python.cmake)
find_python()
# Some common settings for finding Python
set(Python_FIND_VIRTUALENV
FIRST
CACHE STRING "Give precedence to virtualenvs when searching for Python")
set(Python_FIND_FRAMEWORK
LAST
CACHE STRING "Prefer Brew/Conda to Apple framework Python")
set(Python_ARTIFACTS_INTERACTIVE
ON
CACHE BOOL "Prevent multiple searches for Python and instead cache the results.")

# top-level call to find Python
find_package(
Python 3.8 REQUIRED
COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
endif()

# check if this is the master project or used via add_subdirectory
Expand Down
16 changes: 16 additions & 0 deletions cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ include(FetchContent)
include(CMakeDependentOption)
set(FETCH_PACKAGES "")

if(BUILD_MQT_CORE_BINDINGS)
if(NOT SKBUILD)
# Manually detect the installed pybind11 package and import it into CMake.
execute_process(
COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE pybind11_DIR)
list(APPEND CMAKE_PREFIX_PATH "${pybind11_DIR}")
endif()

message(STATUS "Python executable: ${Python_EXECUTABLE}")

# add pybind11 library
find_package(pybind11 CONFIG REQUIRED)
endif()

set(JSON_VERSION
3.11.3
CACHE STRING "nlohmann_json version")
Expand Down
35 changes: 0 additions & 35 deletions cmake/Python.cmake

This file was deleted.

0 comments on commit bd2fd7b

Please sign in to comment.