agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.10) |
| 2 | |
| 3 | # set the project name |
| 4 | set (ProjectName GreenScreen) |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 5 | set (Version 2.0.0) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 6 | |
| 7 | project(${ProjectName} VERSION ${Version}) |
| 8 | |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 9 | set (DAEMON ${PROJECT_SOURCE_DIR}/../../daemon) |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 10 | set (JPL_FILE_NAME ${ProjectName}.jpl) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 11 | set (DAEMON_SRC ${DAEMON}/src) |
| 12 | set (CONTRIB_PATH ${DAEMON}/contrib) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 13 | set (PLUGINS_LIB ${PROJECT_SOURCE_DIR}/../lib) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 14 | set (JPL_DIRECTORY ${PROJECT_BINARY_DIR}/jpl) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 15 | set (LIBS_DIR ${PROJECT_SOURCE_DIR}/../contrib/Libs) |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 16 | set (ONNX_DIR $ENV{PLUGIN_ENV}/onnxruntime) |
agsantos | 2c8525e | 2021-03-19 11:18:01 -0400 | [diff] [blame] | 17 | set (PREFERENCESFILENAME preferences) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 18 | |
| 19 | if(WIN32) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 20 | message(OS:\ WINDOWS\ ${CMAKE_SYSTEM_PROCESSOR}) |
| 21 | if (NOT ${CMAKE_CL_64}) |
| 22 | message( FATAL_ERROR "\nUse CMake only for x64 Windows" ) |
| 23 | endif() |
| 24 | set (CONTRIB_PLATFORM_CURT x64) |
| 25 | set (CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-windows) |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 26 | set (LIBRARY_FILE_NAME ${ProjectName}.dll) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 27 | set (FFMPEG ${CONTRIB_PATH}/build/ffmpeg/Build/win32/x64) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 28 | endif() |
| 29 | |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 30 | message(Building:\ ${ProjectName}\ ${Version}) |
| 31 | message(Build\ path:\ ${PROJECT_BINARY_DIR}) |
| 32 | message(JPL\ assembling\ path:\ ${JPL_DIRECTORY}) |
| 33 | message(JPL\ path:\ ${JPL_DIRECTORY}/../../../build/${ProjectName}/${JPL_FILE_NAME}) |
| 34 | |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 35 | if(NVIDIA) |
| 36 | add_definitions(-DNVIDIA) |
| 37 | set(ONNX_DIR ${ONNX_DIR}/nvidia-gpu) |
| 38 | message(Provider:\ NVIDIA) |
| 39 | set(EXTRA_PATH nvidia-gpu) |
agsantos | 2c8525e | 2021-03-19 11:18:01 -0400 | [diff] [blame] | 40 | set (PREFERENCESFILENAME ${PREFERENCESFILENAME}-accel) |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 41 | else() |
| 42 | set(ONNX_DIR ${ONNX_DIR}/cpu) |
| 43 | message(Provider:\ NONE) |
| 44 | set(EXTRA_PATH cpu) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 45 | endif() |
| 46 | |
| 47 | set(CMAKE_CXX_STANDARD 17) |
| 48 | set(CMAKE_CXX_STANDARD_REQUIRED True) |
| 49 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") |
| 50 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") |
| 51 | |
| 52 | set(plugin_SRC main.cpp |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 53 | pluginMediaHandler.cpp |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 54 | videoSubscriber.cpp |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 55 | pluginProcessor.cpp |
agsantos | 1e7736c | 2020-10-28 14:39:13 -0400 | [diff] [blame] | 56 | ./../lib/accel.cpp |
agsantos | c9181b4 | 2020-11-26 12:03:04 -0500 | [diff] [blame] | 57 | ./../lib/frameUtils.cpp |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 58 | ./../lib/frameFilter.cpp |
| 59 | ${DAEMON_SRC}/string_utils.cpp |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 60 | ) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 61 | |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 62 | set(plugin_HDR pluginMediaHandler.h |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 63 | videoSubscriber.h |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 64 | pluginProcessor.h |
agsantos | c9181b4 | 2020-11-26 12:03:04 -0500 | [diff] [blame] | 65 | ./../lib/pluglog.h |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 66 | ./../lib/mediaStream.h |
| 67 | ./../lib/audioFormat.h |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 68 | ) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 69 | |
| 70 | |
| 71 | |
| 72 | # add the library |
| 73 | add_library(${ProjectName} SHARED ${plugin_SRC} |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 74 | ${plugin_HDR} |
| 75 | ) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 76 | |
agsantos | 364bbae | 2020-08-17 11:29:56 -0400 | [diff] [blame] | 77 | if (WIN32) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 78 | target_include_directories(${ProjectName} PUBLIC ${PROJECT_BINARY_DIR} |
| 79 | ${PROJECT_SOURCE_DIR} |
| 80 | ${PLUGINS_LIB} |
| 81 | ${DAEMON_SRC} |
| 82 | ${CONTRIB_PATH} |
| 83 | ${FFMPEG}/include |
| 84 | ${CONTRIB_PATH}/build/opencv/build/install/include |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 85 | ${ONNX_DIR}/../include/session |
| 86 | ${ONNX_DIR}/../include/providers/cuda |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 87 | ) |
| 88 | target_link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH} |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 89 | ${CONTRIB_PATH}/build/opencv/build/lib/Release |
| 90 | ${CONTRIB_PATH}/build/opencv/build/3rdparty/lib/Release |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 91 | ${FFMPEG}/lib |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 92 | ${ONNX_DIR} |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 93 | ${CONTRIB_PATH}/msvc/lib/x64 |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 94 | ) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 95 | |
agsantos | dd6a62a | 2021-03-29 17:13:27 -0400 | [diff] [blame] | 96 | target_link_libraries(${ProjectName} PUBLIC libavfilter libswscale libavformat libavcodec libavutil libvpx libx264 libopus libmfx |
| 97 | libzlib ws2_32 Bcrypt Crypt32 Secur32 Dnsapi opencv_imgproc411 opencv_core411 onnxruntime msvcrt) |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 98 | endif() |
| 99 | |
| 100 | add_custom_command( |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 101 | TARGET ${ProjectName} |
| 102 | PRE_BUILD |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 103 | COMMAND python ${PROJECT_SOURCE_DIR}/../SDK/jplManipulation.py --preassemble --plugin=${ProjectName} |
| 104 | COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} |
| 105 | COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.dll ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} |
| 106 | COMMAND ${CMAKE_COMMAND} -E make_directory ${JPL_DIRECTORY}/data/model |
| 107 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/modelSRC/mModel.onnx ${JPL_DIRECTORY}/data/model |
agsantos | 2c8525e | 2021-03-19 11:18:01 -0400 | [diff] [blame] | 108 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/${PREFERENCESFILENAME}.json ${JPL_DIRECTORY}/data/preferences.json |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 109 | COMMENT "Assembling Plugin files" |
agsantos | 5aa3965 | 2020-08-11 18:18:04 -0400 | [diff] [blame] | 110 | ) |
| 111 | |
agsantos | 364bbae | 2020-08-17 11:29:56 -0400 | [diff] [blame] | 112 | if (WIN32) |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 113 | add_custom_command( |
| 114 | TARGET ${ProjectName} |
| 115 | POST_BUILD |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 116 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${ProjectName}.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} |
| 117 | COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${LIBRARY_FILE_NAME} ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 118 | COMMAND python ${PROJECT_SOURCE_DIR}/../SDK/jplManipulation.py --assemble --plugin=${ProjectName} --extraPath=${EXTRA_PATH} |
agsantos | ac1940d | 2020-09-17 10:18:40 -0400 | [diff] [blame] | 119 | COMMENT "Generating JPL archive" |
| 120 | ) |
agsantos | 364bbae | 2020-08-17 11:29:56 -0400 | [diff] [blame] | 121 | |
agsantos | 796b5af | 2020-12-22 19:38:27 -0500 | [diff] [blame] | 122 | endif() |