-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
423b8ed
commit e333c2e
Showing
2 changed files
with
32 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,46 @@ | ||
cmake_minimum_required(VERSION 3.11) | ||
|
||
if(APPLE_ARM) | ||
project(qsim LANGUAGES CXX) | ||
else() | ||
execute_process(COMMAND which nvcc OUTPUT_VARIABLE has_nvcc) | ||
if(has_nvcc STREQUAL "") | ||
execute_process(COMMAND which hipcc OUTPUT_VARIABLE has_hipcc) | ||
if(has_hipcc STREQUAL "") | ||
project(qsim) | ||
else() | ||
project(qsim LANGUAGES CXX HIP) | ||
endif() | ||
else() | ||
project(qsim LANGUAGES CXX CUDA) | ||
endif() | ||
endif() | ||
|
||
IF (WIN32) | ||
if(WIN32) | ||
set(CMAKE_CXX_FLAGS "/O2 /openmp") | ||
ELSE() | ||
else() | ||
set(CMAKE_CXX_FLAGS "-O3 -fopenmp") | ||
ENDIF() | ||
endif() | ||
|
||
if(APPLE AND NOT APPLE_ARM) | ||
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") | ||
endif() | ||
|
||
INCLUDE(../GetPybind11.cmake) | ||
include(../GetPybind11.cmake) | ||
|
||
# Configure based on the detected platform | ||
if(APPLE_ARM) | ||
pybind11_add_module(qsim_decide decide.cpp) | ||
elseif(has_nvcc STREQUAL "") | ||
if(has_hipcc STREQUAL "") | ||
pybind11_add_module(qsim_decide decide.cpp) | ||
else() | ||
list(APPEND CMAKE_MODULE_PATH "/opt/rocm/lib/cmake/hip") | ||
find_package(HIP REQUIRED) | ||
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development) | ||
|
||
include_directories(${PYTHON_INCLUDE_DIRS} ${pybind11_SOURCE_DIR}/include) | ||
|
||
hip_add_library(qsim_decide MODULE decide.cpp) | ||
|
||
set_target_properties(qsim_decide PROPERTIES | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}" | ||
) | ||
set_source_files_properties(decide.cpp PROPERTIES LANGUAGE HIP) | ||
endif() | ||
else() | ||
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development) | ||
if(has_nvcc) | ||
find_package(CUDA REQUIRED) | ||
|
||
include_directories(${PYTHON_INCLUDE_DIRS} ${pybind11_SOURCE_DIR}/include) | ||
|
||
cuda_add_library(qsim_decide MODULE decide.cpp) | ||
|
||
if(DEFINED ENV{CUQUANTUM_ROOT}) | ||
target_compile_options(qsim_decide PRIVATE | ||
$<$<COMPILE_LANGUAGE:CUDA>:-D__CUSTATEVEC__> | ||
) | ||
endif() | ||
|
||
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development) | ||
include_directories(${PYTHON_INCLUDE_DIRS} ${pybind11_SOURCE_DIR}/include) | ||
set_target_properties(qsim_decide PROPERTIES | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}" | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}" | ||
) | ||
set_source_files_properties(decide.cpp PROPERTIES LANGUAGE CUDA) | ||
elseif(has_hipcc) | ||
list(APPEND CMAKE_MODULE_PATH "/opt/rocm/lib/cmake/hip") | ||
find_package(HIP REQUIRED) | ||
hip_add_library(qsim_decide MODULE decide.cpp) | ||
set_source_files_properties(decide.cpp PROPERTIES LANGUAGE HIP) | ||
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter Development) | ||
include_directories(${PYTHON_INCLUDE_DIRS} ${pybind11_SOURCE_DIR}/include) | ||
set_target_properties(qsim_decide PROPERTIES | ||
PREFIX "${PYTHON_MODULE_PREFIX}" | ||
SUFFIX "${PYTHON_MODULE_EXTENSION}" | ||
) | ||
else() | ||
pybind11_add_module(qsim_decide decide.cpp) | ||
endif() |