@@ -92,6 +92,8 @@ foreach( src_file IN ITEMS ${SRC_FILES})
9292 source_group ("${group_name} " FILES "${src_file} " )
9393endforeach ()
9494
95+ option (COPY_PYTHON_DL "Creates a directory and copies the python dynamic library for packaging" OFF )
96+
9597# Find and link python and pybind11
9698find_package (Python 3.8 REQUIRED COMPONENTS Interpreter Development)
9799add_subdirectory (extern/pybind11)
@@ -101,21 +103,38 @@ message(STATUS "Python_RUNTIME_LIBRARY_DIRS: ${Python_RUNTIME_LIBRARY_DIRS}")
101103message (STATUS "Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS} " )
102104message (STATUS "Python_LIBRARY_DIRS: ${Python_LIBRARY_DIRS} " )
103105
106+ if (COPY_PYTHON_DL)
107+ add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
108+ ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PLUGIN_NAME} >/shared)
109+ endif ()
110+
104111if (MSVC )
105112 file (GLOB _pythondll "${Python_RUNTIME_LIBRARY_DIRS} /python3[0-9]*.dll" )
106113
107114 add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
108115 ${CMAKE_COMMAND} -E copy ${_pythondll} ${GUI_BIN_DIR} /shared)
109-
110- # install(FILES ${Python_RUNTIME_LIBRARY_DIRS}/python3[0-9]+.dll DESTINATION ${GUI_BIN_DIR}/shared)
116+ if (COPY_PYTHON_DL)
117+ add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
118+ ${CMAKE_COMMAND} -E copy ${_pythondll} $<TARGET_FILE_DIR:${PLUGIN_NAME} >/shared)
119+ endif ()
111120elseif (LINUX)
112121 file (GLOB _pythonso "${Python_RUNTIME_LIBRARY_DIRS} /libpython3.[0-9]*.so.*.*" )
113122
114123 add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
115124 ${CMAKE_COMMAND} -E copy ${_pythonso} ${GUI_BIN_DIR} /shared)
125+
126+ if (COPY_PYTHON_DL)
127+ add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
128+ ${CMAKE_COMMAND} -E copy ${_pythonso} $<TARGET_FILE_DIR:${PLUGIN_NAME} >/shared)
129+ endif ()
116130elseif (APPLE )
117131 file (GLOB _pythondylib "${Python_RUNTIME_LIBRARY_DIRS} /libpython3.[0-9]*.dylib" )
118132
119133 add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
120134 ${CMAKE_COMMAND} -E copy ${_pythondylib} $ENV{HOME} /Library/Application\ Support/open-ephys/shared-api8)
135+
136+ if (COPY_PYTHON_DL)
137+ add_custom_command (TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
138+ ${CMAKE_COMMAND} -E copy ${_pythondylib} $<TARGET_FILE_DIR:${PLUGIN_NAME} >/shared)
139+ endif ()
121140endif ()
0 commit comments