diff --git a/CMakeLists.txt b/CMakeLists.txt index 703e13081..7fb348049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/pybind_interface/GetPybind11.cmake b/pybind_interface/GetPybind11.cmake index a9b4f527d..d2f14efc7 100644 --- a/pybind_interface/GetPybind11.cmake +++ b/pybind_interface/GetPybind11.cmake @@ -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) diff --git a/pybind_interface/avx2/CMakeLists.txt b/pybind_interface/avx2/CMakeLists.txt index 54ceb30c7..bd299c1d7 100644 --- a/pybind_interface/avx2/CMakeLists.txt +++ b/pybind_interface/avx2/CMakeLists.txt @@ -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) diff --git a/pybind_interface/avx512/CMakeLists.txt b/pybind_interface/avx512/CMakeLists.txt index 3523b3553..acd960ca6 100644 --- a/pybind_interface/avx512/CMakeLists.txt +++ b/pybind_interface/avx512/CMakeLists.txt @@ -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) diff --git a/pybind_interface/basic/CMakeLists.txt b/pybind_interface/basic/CMakeLists.txt index f148f855c..5bff46386 100644 --- a/pybind_interface/basic/CMakeLists.txt +++ b/pybind_interface/basic/CMakeLists.txt @@ -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) diff --git a/pybind_interface/cuda/CMakeLists.txt b/pybind_interface/cuda/CMakeLists.txt index 129e3077c..5a6486d8a 100644 --- a/pybind_interface/cuda/CMakeLists.txt +++ b/pybind_interface/cuda/CMakeLists.txt @@ -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) diff --git a/pybind_interface/custatevec/CMakeLists.txt b/pybind_interface/custatevec/CMakeLists.txt index fab71e03e..3c6c72711 100644 --- a/pybind_interface/custatevec/CMakeLists.txt +++ b/pybind_interface/custatevec/CMakeLists.txt @@ -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) diff --git a/pybind_interface/decide/CMakeLists.txt b/pybind_interface/decide/CMakeLists.txt index 6ca7f8f03..17ec933e9 100644 --- a/pybind_interface/decide/CMakeLists.txt +++ b/pybind_interface/decide/CMakeLists.txt @@ -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) diff --git a/pybind_interface/sse/CMakeLists.txt b/pybind_interface/sse/CMakeLists.txt index a5868e521..2877d6e02 100644 --- a/pybind_interface/sse/CMakeLists.txt +++ b/pybind_interface/sse/CMakeLists.txt @@ -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) diff --git a/setup.py b/setup.py index e571aa12f..868c8fca0 100644 --- a/setup.py +++ b/setup.py @@ -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)