Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Runtime] Add support for Lightning source directory to be used in runtime build #732

Merged
merged 9 commits into from
May 23, 2024
5 changes: 3 additions & 2 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ FetchContent_Declare(
)

function(fetch_pybind11)
find_package(Python COMPONENTS Interpreter Development) # Required for non-standard Python system intsalls
mlxd marked this conversation as resolved.
Show resolved Hide resolved
mlxd marked this conversation as resolved.
Show resolved Hide resolved
find_package(pybind11 CONFIG)
if (pybind11_FOUND)
message(STATUS, "FOUND pybind11")
Expand All @@ -58,8 +59,8 @@ function(fetch_pybind11)
set(CMAKE_POLICY_DEFAULT_CMP0127 NEW) # To suppress pybind11 CMP0127 warning

FetchContent_Declare(pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.10.1
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.12.0
)

FetchContent_MakeAvailable(pybind11)
Expand Down
33 changes: 25 additions & 8 deletions runtime/lib/backend/lightning/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
include(ExternalProject)

if(RUNTIME_CLANG_TIDY)
if(NOT DEFINED CLANG_TIDY_BINARY)
Expand All @@ -14,12 +15,30 @@ if(RUNTIME_CLANG_TIDY)
)
endif()

set(LIGHTNING_GIT_TAG "master" CACHE STRING "GIT_TAG value to build Lightning")
FetchContent_Declare(
pennylane_lightning
GIT_REPOSITORY https://github.com/PennyLaneAI/pennylane-lightning.git
GIT_TAG ${LIGHTNING_GIT_TAG}
)
if(LIGHTNING_SRC_PATH)
if(NOT IS_ABSOLUTE ${LIGHTNING_SRC_PATH})
message(FATAL_ERROR " LIGHTNING_SRC_PATH=${LIGHTNING_SRC_PATH} must be set to an absolute path")
endif()
if(LIGHTNING_GIT_TAG)
message(WARN " Setting `LIGHTNING_SRC_PATH=${LIGHTNING_SRC_PATH}` overrides `LIGHTNING_GIT_TAG=${LIGHTNING_GIT_TAG}`")
endif()

FetchContent_Declare(
pennylane_lightning
URL file://${LIGHTNING_SRC_PATH}
)
else()
if(NOT LIGHTNING_GIT_TAG)
set(LIGHTNING_GIT_TAG "master" CACHE STRING "GIT_TAG value to build Lightning")
endif()
FetchContent_Declare(
pennylane_lightning
GIT_REPOSITORY https://github.com/PennyLaneAI/pennylane-lightning.git
GIT_TAG ${LIGHTNING_GIT_TAG}
)
endif()
FetchContent_MakeAvailable(pennylane_lightning)

set(CMAKE_POSITION_INDEPENDENT_CODE ON) # build with -fPIC

if(ENABLE_LIGHTNING AND ENABLE_LIGHTNING_KOKKOS)
Expand All @@ -31,8 +50,6 @@ elseif(ENABLE_LIGHTNING_KOKKOS)
endif()
set(ENABLE_PYTHON OFF CACHE BOOL "Enable compilation of the Python module")

FetchContent_MakeAvailable(pennylane_lightning)

set(src_files)

if(ENABLE_LIGHTNING)
Expand Down
Loading