Skip to content

Commit

Permalink
Merge branch 'main' into pr-add-cuda-support-to-top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhowe23 authored Dec 16, 2024
2 parents addac4a + 9afe5c4 commit 6d6b264
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
62 changes: 62 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,68 @@ if (CUDAQX_INCLUDE_TESTS)
endif()
endif()

# Hooks setup. If the repo contains a custom pre-push hook, attempt to install
# it. If the user has a different one installed, then warn them but do not fail
# configuration.
# ==============================================================================

# Define the directory where your hooks are stored
set(SRC_HOOK_PRE_PUSH "${CMAKE_SOURCE_DIR}/.githooks/pre-push")

if(EXISTS "${SRC_HOOK_PRE_PUSH}")
# Get the Git hooks directory from the Git configuration
execute_process(
COMMAND git config --get core.hooksPath
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_HOOKS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Determine the target hooks directory
if(GIT_HOOKS_DIR)
set(TARGET_HOOKS_DIR "${GIT_HOOKS_DIR}")
else()
set(TARGET_HOOKS_DIR "${CMAKE_SOURCE_DIR}/.git/hooks")
endif()
set(DST_HOOK_PRE_PUSH "${TARGET_HOOKS_DIR}/pre-push")

if(EXISTS "${DST_HOOK_PRE_PUSH}")
# Compare the contents of the src and dst hook.
execute_process(
COMMAND git hash-object "${DST_HOOK_PRE_PUSH}"
OUTPUT_VARIABLE SHA_DST
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git hash-object "${SRC_HOOK_PRE_PUSH}"
OUTPUT_VARIABLE SHA_SRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHA_SRC STREQUAL SHA_DST)
message(WARNING
"You already have a ${DST_HOOK_PRE_PUSH} script installed. "
"This configuration script will not overwrite it despite the fact that "
"it is strongly recommended to use ${SRC_HOOK_PRE_PUSH} in your environment."
"\nProceed with caution!")
endif()
else()
if(EXISTS "${TARGET_HOOKS_DIR}")
file(COPY "${SRC_HOOK_PRE_PUSH}"
DESTINATION "${TARGET_HOOKS_DIR}"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
message(STATUS "Git pre-push hook installed to ${TARGET_HOOKS_DIR}")
else()
message(WARNING
"The Git hooks directory does not exist: ${TARGET_HOOKS_DIR}\n"
"Are you sure this is a Git repository? Hook cannot be installed."
)
endif()
endif()
endif()

# Directory setup
# ==============================================================================

Expand Down
8 changes: 8 additions & 0 deletions docs/sphinx/quickstart/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ The simplest way to install CUDA-QX is via pip. You can install individual compo
# Install both libraries
pip install cudaq-qec cudaq-solvers
.. note::

CUDA-Q Solvers will require the presence of :code:`libgfortran`, which is
not distributed with the Python wheel, for provided classical optimizers. If
:code:`libgfortran` is not installed, you will need to install it via your
distribution's package manager. On Debian based systems, you can install
this with :code:`apt-get install gfortran`.

Docker Container
^^^^^^^^^^^^^^^^

Expand Down

0 comments on commit 6d6b264

Please sign in to comment.