Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
project(qsim)

set(CMAKE_CXX_STANDARD 11)
cmake_minimum_required(VERSION 3.31)

# Check if CMAKE_SYSTEM_NAME is Darwin (macOS) and CMAKE_SYSTEM_PROCESSOR is arm64
# Set prelimary value so that other variables we need are defined
project(qsim)

# Darwin + Arm64 => Apple Silicon, where we can't build Cuda, AVX or SSE features.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(APPLE_ARM TRUE)
else()
set(APPLE_ARM FALSE)
endif()

# Set the project name and language
# Set the project name and language more precisely
if(APPLE)
project(qsim LANGUAGES CXX)
else()
Expand Down
22 changes: 2 additions & 20 deletions pybind_interface/GetPybind11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@ FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG "v${MIN_PYBIND_VERSION}"
OVERRIDE_FIND_PACKAGE
)
FetchContent_GetProperties(pybind11)
find_package(pybind11 "${MIN_PYBIND_VERSION}" CONFIG)

if (pybind11_FOUND)
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
# The pybind11_add_module doesn't correctly set the CXX_INCLUDES properly if a system pybind11 is found.
# Using `include_directories(${pybind11_INCLUDE_DIRS})` doesn't result in anything in
# CXX_INCLUDES. e.g., `pybind_interface/basic/CMakeFiles/qsim_basic.dir/flags.make` would only
# have `CXX_INCLUDES = -isystem $PREFIX/include/python3.11` and would miss `$PREFIX/include`.
# This problem would result in `fatal error: pybind11/complex.h: No such file or directory`
# This is a hack to get around that by passing `-I/path/to/include` to CXX_FLAGS
# Iterate over each include directory and add it as a compile option
foreach(INCLUDE_DIR ${pybind11_INCLUDE_DIRS})
add_compile_options("-I${INCLUDE_DIR}")
endforeach()
endif()

if((NOT pybind11_FOUND) AND (NOT pybind11_POPULATED)) # check first on system path, then attempt git fetch
FetchContent_MakeAvailable(pybind11)
endif()
FetchContent_MakeAvailable(pybind11)
15 changes: 13 additions & 2 deletions pybind_interface/avx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ ENDIF()

if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
pybind11_add_module(qsim_avx2 pybind_main_avx2.cpp)

Expand Down
14 changes: 12 additions & 2 deletions pybind_interface/avx512/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ ENDIF()

if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
Expand Down
14 changes: 12 additions & 2 deletions pybind_interface/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ endif()

if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
Expand Down
15 changes: 12 additions & 3 deletions pybind_interface/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ else()
set(CMAKE_CXX_FLAGS "-O3")
endif()


if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
Expand Down
14 changes: 12 additions & 2 deletions pybind_interface/custatevec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ endif()

if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
Expand Down
16 changes: 13 additions & 3 deletions pybind_interface/decide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ else()
set(CMAKE_CXX_FLAGS "-O3")
endif()

if(APPLE AND NOT APPLE_ARM)
if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

include(../GetPybind11.cmake)
Expand Down
15 changes: 12 additions & 3 deletions pybind_interface/sse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ ELSE()
set(CMAKE_CXX_FLAGS "-msse4.1 -O3")
ENDIF()


if(APPLE)
set(CMAKE_CXX_STANDARD 14)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
include_directories(
"/usr/local/include"
"/usr/local/opt/llvm/include"
"/opt/homebrew/include"
"/opt/homebrew/opt/llvm@19/include"
)
link_directories(
"/usr/local/lib"
"/usr/local/opt/llvm/lib"
"/opt/homebrew/lib"
"/opt/homebrew/opt/llvm@19/lib"
)
endif()

INCLUDE(../GetPybind11.cmake)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def run(self):
cmake_version = parse(
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
)
if cmake_version < parse("3.1.0"):
raise RuntimeError("CMake >= 3.1.0 is required on Windows")
if cmake_version < parse("3.31.0"):
raise RuntimeError("CMake >= 3.31.0 is required on Windows")

for ext in self.extensions:
self.build_extension(ext)
Expand Down
Loading