85 lines
2.9 KiB
CMake
85 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(nui_openni2_virtual_device LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(OPENNI2_ROOT "$ENV{HOME}/.local/openni2-root" CACHE PATH
|
|
"User-space OpenNI2 package root")
|
|
set(OPENNI2_INCLUDE_DIR
|
|
"${OPENNI2_ROOT}/usr/include/openni2" CACHE PATH
|
|
"Directory containing OpenNI.h")
|
|
set(OPENNI2_LIBRARY
|
|
"${OPENNI2_ROOT}/usr/lib/x86_64-linux-gnu/libOpenNI2.so" CACHE FILEPATH
|
|
"OpenNI2 shared library")
|
|
|
|
foreach(required_path
|
|
"${OPENNI2_INCLUDE_DIR}/OpenNI.h"
|
|
"${OPENNI2_LIBRARY}")
|
|
if(NOT EXISTS "${required_path}")
|
|
message(FATAL_ERROR "Required OpenNI2 file not found: ${required_path}")
|
|
endif()
|
|
endforeach()
|
|
|
|
set(REPOSITORY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
add_library(SynthKinectDriver MODULE
|
|
src/openni2_synth_driver.cpp
|
|
src/shm_frame_source.cpp
|
|
"${REPOSITORY_ROOT}/core/mapping/mapping.cpp"
|
|
"${REPOSITORY_ROOT}/core/synth/mask_stabilizer.cpp"
|
|
"${REPOSITORY_ROOT}/core/synth/synth.cpp"
|
|
)
|
|
target_include_directories(SynthKinectDriver PRIVATE
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/openni2"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
|
"${OPENNI2_INCLUDE_DIR}"
|
|
"${REPOSITORY_ROOT}/core"
|
|
)
|
|
target_link_libraries(SynthKinectDriver PRIVATE Threads::Threads)
|
|
target_compile_options(SynthKinectDriver PRIVATE
|
|
-Wall -Wextra -Wpedantic -Werror
|
|
)
|
|
# This provisioned libOpenNI2.so build has no OPENNI2_DRIVERS_PATH env var and
|
|
# never finds its own etc/openni2/OpenNI.ini override (it only checks the
|
|
# absolute system path /etc/openni2/OpenNI.ini, which does not exist without
|
|
# a package install); its driver scanner also globs strictly for "*.so.0",
|
|
# not plain "*.so". So the module is built with that exact suffix, matching
|
|
# the stock drivers (libDummyDevice.so.0, libPS1080.so.0, ...).
|
|
set_target_properties(SynthKinectDriver PROPERTIES
|
|
PREFIX "lib"
|
|
OUTPUT_NAME "SynthKinect"
|
|
SUFFIX ".so.0"
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/OpenNI2/Drivers"
|
|
)
|
|
|
|
# Deploy step: the host's own default driver repository (relative to its
|
|
# libOpenNI2.so) is the only path it actually scans, so an OpenNI2 app can
|
|
# find this module only once it is placed there too - mirroring how a real
|
|
# OpenNI2 driver gets installed.
|
|
add_custom_command(TARGET SynthKinectDriver POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
"$<TARGET_FILE:SynthKinectDriver>"
|
|
"${OPENNI2_ROOT}/usr/lib/x86_64-linux-gnu/OpenNI2/Drivers/libSynthKinect.so.0"
|
|
)
|
|
|
|
add_executable(openni2_depth_consumer
|
|
tools/openni2_depth_consumer.cpp
|
|
)
|
|
target_include_directories(openni2_depth_consumer PRIVATE
|
|
"${OPENNI2_INCLUDE_DIR}"
|
|
)
|
|
target_link_libraries(openni2_depth_consumer PRIVATE
|
|
"${OPENNI2_LIBRARY}"
|
|
)
|
|
target_compile_options(openni2_depth_consumer PRIVATE
|
|
-Wall -Wextra -Wpedantic -Werror
|
|
)
|
|
set_target_properties(openni2_depth_consumer PROPERTIES
|
|
BUILD_RPATH "${OPENNI2_ROOT}/usr/lib/x86_64-linux-gnu"
|
|
)
|
|
|