-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
60 lines (49 loc) · 2.09 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
50
51
52
53
54
55
56
57
58
59
60
cmake_minimum_required(VERSION 3.22)
project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX CUDA)
#project(example)
find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
include_directories( ${EIGEN3_INCLUDE_DIRS} include)
find_package(OpenMP REQUIRED)
find_package(CUDAToolkit REQUIRED)
add_subdirectory(pybind11)
#pybind11_add_module(example example.cpp)
# Find the module development requirements (requires FindPython from 3.17 or
# scikit-build-core's built-in backport)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
#find_package(pybind11 CONFIG REQUIRED)
# create a GPU library and then link this library to the python executable
set(LibHeaders
include/cuda/cu_matrix_functions.h
include/cuda/nn/nn.h
)
set(LibSources
src/cuda/cu_matrix_functions.cu
)
add_library(libcppapi-gpu STATIC ${LibSources} ${LibHeaders})
target_link_libraries(libcppapi-gpu PRIVATE CUDA::cudart CUDA::cublas)
set_target_properties(libcppapi-gpu PROPERTIES LINKER_LANGUAGE CUDA CUDA_ARCHITECTURES OFF
POSITION_INDEPENDENT_CODE ON)
# Add a library using FindPython's tooling (pybind11 also provides a helper like
# this)
python_add_library(_core MODULE src/interface.cpp
src/nn/activation.cpp
src/tutorial/comp_graph.cpp
src/nn/matrix_functions.cpp
src/tutorial/linear_regression.cpp
src/nn/loss.cpp
src/nn/nn.cpp
src/nn/nn2.cpp
src/nn/optimiser.cpp
src/nn/train.cpp
src/cuda/pybind_cuda_interface.cpp
src/data/batching.cpp
WITH_SOABI)
target_link_libraries(_core PRIVATE pybind11::headers OpenMP::OpenMP_CXX libcppapi-gpu CUDA::cudart CUDA::cublas)
# This is passing in the version as a define just as an example
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
# The install directory is the output (wheel) directory
install(TARGETS _core DESTINATION cppapi)