-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathCMakeLists.txt
49 lines (42 loc) · 1.81 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cmake_minimum_required(VERSION 3.15...3.26)
project(ext)
set(PYTHON "ON")
set(OSQP_BUILD_UNITTESTS "OFF")
set(OSQP_USE_LONG "OFF")
set(OSQP_CUSTOM_PRINTING "${CMAKE_CURRENT_SOURCE_DIR}/cmake/printing.h")
set(OSQP_CUSTOM_MEMORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/memory.h")
set(OSQP_CODEGEN_INSTALL_DIR "codegen/codegen_src" CACHE PATH "" FORCE)
if(APPLE)
message(STATUS "Building for Apple arches: ${CMAKE_OSX_ARCHITECTURES}")
endif()
include(FetchContent)
find_package(pybind11 CONFIG REQUIRED)
message(STATUS "Fetching/configuring OSQP")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
osqp
GIT_REPOSITORY https://github.com/osqp/osqp.git
GIT_TAG ff371613bef82e85fb431590343853846ff96203
)
list(POP_BACK CMAKE_MESSAGE_INDENT)
FetchContent_MakeAvailable(osqp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/bindings.cpp.in
${CMAKE_CURRENT_SOURCE_DIR}/src/bindings.cpp)
pybind11_add_module(${OSQP_EXT_MODULE_NAME} src/bindings.cpp)
install(TARGETS ${OSQP_EXT_MODULE_NAME} DESTINATION . COMPONENT python)
# TODO: We shouldn't have to do this once the interfaces are set up correctly
if(${OSQP_ALGEBRA_BACKEND} STREQUAL "builtin")
target_link_libraries(ext_builtin PUBLIC pybind11::module osqpstatic)
elseif(${OSQP_ALGEBRA_BACKEND} STREQUAL "mkl")
if(APPLE)
target_link_libraries(osqp_mkl PUBLIC pybind11::module osqpstatic)
else()
target_link_libraries(osqp_mkl PUBLIC pybind11::module osqpstatic $<LINK_ONLY:MKL::MKL>)
endif()
elseif(${OSQP_ALGEBRA_BACKEND} STREQUAL "cuda")
enable_language(CUDA)
find_package(CUDA)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_directories(osqp_cuda PUBLIC ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(osqp_cuda PUBLIC pybind11::module osqpstatic cublas cusparse)
endif()