Skip to content

Commit 70ca00a

Browse files
committed
osx zip packing
1 parent 131a698 commit 70ca00a

File tree

3 files changed

+59
-15
lines changed

3 files changed

+59
-15
lines changed

CMakeLists.txt

+37-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ if (UNIX)
3636
set(Onnxruntime_INCLUDE_HINT /usr/local/include/)
3737
endif()
3838

39+
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release" CACHE STRING "Directory for building release packages")
40+
3941
set(CMAKE_PREFIX_PATH "${QTDIR}")
4042
set(CMAKE_INCLUDE_CURRENT_DIR ON)
4143
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/external")
@@ -121,9 +123,7 @@ if(WIN32)
121123
endif()
122124

123125
# find the onnxruntime DLL for packaging with the plugin DLL
124-
if (WIN32)
125-
set(Onnxruntime_DLL "${Onnxruntime_LIBRARY_DIR}/onnxruntime.dll")
126-
endif()
126+
set(Onnxruntime_DLL "${Onnxruntime_LIBRARY_DIR}/onnxruntime.dll")
127127

128128
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL when building with VS2019)
129129
if (MSVC)
@@ -148,8 +148,6 @@ if(WIN32)
148148

149149
# --- Release package helper ---
150150
# The "release" folder has a structure similar OBS' one on Windows
151-
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
152-
153151
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
154152
# If config is Release or RelWithDebInfo, package release files
155153
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
@@ -209,9 +207,7 @@ if(WIN32)
209207
)
210208
# --- End of sub-section ---
211209

212-
install(DIRECTORY "${RELEASE_DIR}/"
213-
DESTINATION .
214-
)
210+
install(DIRECTORY "${RELEASE_DIR}/" DESTINATION .)
215211
# Tell CPack to create a zip file.
216212
set(CPACK_GENERATOR "ZIP")
217213
# Tell CPack what to name the zip file. It will append `.zip`.
@@ -251,5 +247,38 @@ if(APPLE)
251247

252248
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
253249
target_link_libraries(${CMAKE_PROJECT_NAME} "${OBS_FRONTEND_LIB}")
250+
251+
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
252+
# If config is Release or RelWithDebInfo, package release files
253+
COMMAND
254+
"${CMAKE_COMMAND}" ARGS -E make_directory
255+
"${RELEASE_DIR}/Resources/data/obs-plugins/${CMAKE_PROJECT_NAME}"
256+
"${RELEASE_DIR}/Plugins"
257+
258+
259+
COMMAND
260+
"${CMAKE_COMMAND}" ARGS -E copy_directory
261+
"${PROJECT_SOURCE_DIR}/data"
262+
"${RELEASE_DIR}/Resources/data/obs-plugins/${CMAKE_PROJECT_NAME}"
263+
264+
265+
COMMAND
266+
"${CMAKE_COMMAND}" ARGS -E copy
267+
"$<TARGET_FILE:${CMAKE_PROJECT_NAME}>"
268+
"${RELEASE_DIR}/Plugins/"
269+
270+
)
271+
272+
install(DIRECTORY "${RELEASE_DIR}/" DESTINATION .)
273+
274+
# Tell CPack to create a zip file.
275+
set(CPACK_GENERATOR "ZIP")
276+
# Tell CPack what to name the zip file. It will append `.zip`.
277+
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-macosx")
278+
# Tell CPack not to put everything inside an enclosing directory.
279+
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
280+
# Apparently this should be always on but isn't for backwards compatibility.
281+
set(CPACK_VERBATIM_VARIABLES YES)
282+
include(CPack)
254283
endif()
255284
# -- End of section --

external/FindLibObs.cmake

+10-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ find_path(LIBOBS_INCLUDE_DIR
3737
/usr/include /usr/local/include /opt/local/include /sw/include
3838
PATH_SUFFIXES
3939
libobs
40+
DOC "Lib OBS include directory"
4041
)
4142

43+
if(APPLE)
44+
# Hopeful hint at libobs in the /Applications folder
45+
set(obsLibPath_osx "/Applications/OBS.app/Contents/Frameworks/")
46+
endif()
47+
4248
function(find_obs_lib base_name repo_build_path lib_name)
4349
string(TOUPPER "${base_name}" base_name_u)
4450

@@ -55,6 +61,7 @@ function(find_obs_lib base_name repo_build_path lib_name)
5561
${obsPath}
5662
${obsLibPath}
5763
${_${base_name_u}_LIBRARY_DIRS}
64+
${obsLibPath_osx}
5865
PATHS
5966
/usr/lib /usr/local/lib /opt/local/lib /sw/lib
6067
PATH_SUFFIXES
@@ -76,6 +83,7 @@ function(find_obs_lib base_name repo_build_path lib_name)
7683
build/${repo_build_path}/Debug
7784
build/${repo_build_path}/Release
7885
build/${repo_build_path}/RelWithDebInfo
86+
DOC "Lib OBS library"
7987
)
8088
endfunction()
8189

@@ -98,8 +106,8 @@ if(LIBOBS_FOUND)
98106
set(W32_PTHREADS_INCLUDE_DIR ${LIBOBS_INCLUDE_DIR}/../deps/w32-pthreads)
99107
endif()
100108

101-
set(LIBOBS_INCLUDE_DIRS ${LIBOBS_INCLUDE_DIR} ${W32_PTHREADS_INCLUDE_DIR})
102-
set(LIBOBS_LIBRARIES ${LIBOBS_LIB} ${W32_PTHREADS_LIB})
109+
set(LIBOBS_INCLUDE_DIRS ${LIBOBS_INCLUDE_DIR} ${W32_PTHREADS_INCLUDE_DIR} CACHE STRING "Lib OBS include directories")
110+
set(LIBOBS_LIBRARIES ${LIBOBS_LIB} ${W32_PTHREADS_LIB} CACHE STRING "Lib OBS libraries")
103111

104112
if (EXISTS ${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake)
105113
include(${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake)

external/FindOnnxruntime.cmake

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
set(Onnxruntime_DIR_BUILD ${CMAKE_BINARY_DIR}/onnxruntime/)
99
if(APPLE AND EXISTS ${Onnxruntime_DIR_BUILD})
10-
file(GLOB Onnxruntime_LIBRARIES ${Onnxruntime_DIR_BUILD}/lib/lib*.a)
11-
set(Onnxruntime_INCLUDE_DIR ${Onnxruntime_DIR_BUILD}/include)
10+
file(GLOB Onnxruntime_LIBRARIES_EX ${Onnxruntime_DIR_BUILD}/lib/lib*.a)
11+
set(Onnxruntime_LIBRARIES ${Onnxruntime_LIBRARIES_EX} CACHE STRING "Onnxruntime libraries")
12+
set(Onnxruntime_INCLUDE_DIR ${Onnxruntime_DIR_BUILD}/include CACHE STRING "Onnxruntime include directory")
1213
else()
1314
find_library(Onnxruntime_LIBRARIES
1415
NAMES
@@ -34,12 +35,18 @@ include(FindPackageHandleStandardArgs)
3435
find_package_handle_standard_args(Onnxruntime DEFAULT_MSG Onnxruntime_INCLUDE_DIR Onnxruntime_LIBRARIES)
3536

3637
if (Onnxruntime_FOUND)
37-
set(Onnxruntime_INCLUDE_DIRS ${Onnxruntime_INCLUDE_DIR} )
38+
set(Onnxruntime_INCLUDE_DIRS ${Onnxruntime_INCLUDE_DIR} CACHE STRING "Onnxruntime include directories")
3839
if (APPLE)
3940
set(Onnxruntime_INCLUDE_DIRS ${Onnxruntime_INCLUDE_DIRS} ${Onnxruntime_INCLUDE_DIR}/onnxruntime/core/session)
4041
endif()
41-
get_filename_component(Onnxruntime_LIBRARY_DIR ${Onnxruntime_LIBRARY} DIRECTORY)
42+
list(GET Onnxruntime_LIBRARIES 0 Onnxruntime_LIBRARY)
43+
get_filename_component(Onnxruntime_LIBRARY_DIR_EX ${Onnxruntime_LIBRARY} DIRECTORY)
44+
set(Onnxruntime_LIBRARY_DIR ${Onnxruntime_LIBRARY_DIR_EX} CACHE STRING "Onnxruntime library directory")
4245
endif()
4346

4447
# Tell cmake GUIs to ignore the "local" variables.
45-
mark_as_advanced(Onnxruntime_INCLUDE_DIR Onnxruntime_LIBRARY)
48+
mark_as_advanced(Onnxruntime_INCLUDE_DIR
49+
Onnxruntime_LIBRARY
50+
Onnxruntime_INCLUDE_DIRS
51+
Onnxruntime_LIBRARY_DIR
52+
Onnxruntime_LIBRARIES)

0 commit comments

Comments
 (0)