File tree Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.28)
2- project (untitled11 )
2+ project (pybind_test )
33
4+ #************************************基础配置***********************************************************
45# 添加子目录 pybind11
56add_subdirectory (extern/pybind11)
67
7- # 加入cpp文件
8- pybind11_add_module(example SHARED example.cpp)
9-
10- # 设置输出文件后缀名为 .pyd
11- set_target_properties (example PROPERTIES SUFFIX ".pyd" )
12-
138# 添加包含目录
149include_directories (
1510 "E:\\ DataBuffer\\ hurleykane\\ miniconda3\\ include"
@@ -22,8 +17,14 @@ find_library(PYTHON3_LIB python3 PATHS ${PYTHON_LIB_DIR})
2217find_library (PYTHON311_LIB python311 PATHS ${PYTHON_LIB_DIR} )
2318link_directories (${PTTHON_LIB_DIR} )
2419
25- # 添加依赖项
26- target_link_libraries (example PUBLIC
27- ${PYTHON3_LIB}
28- ${PYTHON311_LIB}
29- )
20+ # 添加依赖项函数
21+ function (link_to_python target_module)
22+ target_link_libraries (${target_module} PUBLIC
23+ ${PYTHON3_LIB}
24+ ${PYTHON311_LIB}
25+ )
26+ endfunction ()
27+
28+ #******************************访问子文件CMakeLists.txt*********************************************
29+ add_subdirectory (core/add)
30+
Original file line number Diff line number Diff line change 1+ # 加入cpp文件
2+ pybind11_add_module(add SHARED add.cpp)
3+
4+ # 设置输出文件后缀名为 .pyd
5+ set_target_properties (
6+ add PROPERTIES SUFFIX ".pyd"
7+ )
8+
9+ # 添加依赖项
10+ link_to_python(add)
File renamed without changes.
You can’t perform that action at this time.
0 commit comments