Azure-Kinect-Sensor-SDK/CMakeLists.txt

331 строка
12 KiB
CMake
Исходник Постоянная ссылка Обычный вид История

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Minimum Version determined by the following dev environments
# Ubuntu 16.04 (Xenial) - CMake 3.5.1
# Ubuntu 18.04 (Bionic) - CMake 3.10.2
# Visual Studio 2017 15.3 - CMake 3.8
# Visual Studio 2017 15.4 - CMake 3.9
# Visual Studio 2017 15.7 - CMake 3.11
cmake_minimum_required(VERSION 3.9.0)
cmake_policy(SET CMP0048 NEW)
# Add this repository's cmake modules to CMAKE_MODULE_PATH
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_LIST_DIR}/cmake)
# If no project name is set, we are the root project
if (NOT CMAKE_PROJECT_NAME)
# Set the default build type (if not already set)
include(DefaultBuildType)
endif()
project(K4A LANGUAGES C CXX
VERSION 1.4)
option(K4A_BUILD_DOCS "Build K4A doxygen documentation" OFF)
option(K4A_MTE_VERSION "Skip FW version check" OFF)
option(K4A_SOURCE_LINK "Enable source linking on MSVC" OFF)
include(GitCommands)
# Set the project version
include(K4AProjectVersion)
2019-06-25 20:05:38 +03:00
# Default to not embed an icon in resources
set(K4A_USE_ICON 0)
set(K4A_ICON_PATH ${CMAKE_CURRENT_LIST_DIR}/kinect-viewer.ico)
set(PROJ_DIR ${CMAKE_CURRENT_LIST_DIR})
set(INCLUDE_DIR ${PROJ_DIR}/include)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Before CMake 3.14 setting CMAKE_POSITION_INDEPENDENT_CODE did not set the
# "-pie" flag for GCC or Clang
if("${CMAKE_VERSION}" VERSION_LESS "3.14.0")
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
# Turn off incremental linking
include(MSVCLinkerFlags)
# Enable source linking
# NOTE: Dependencies are not properly setup here.
# Currently, CMake does not know to re-link if SOURCE_LINK_JSON changes
# Currently, CMake does not re-generate SOURCE_LINK_JSON if git's HEAD changes
if (K4A_SOURCE_LINK)
if ("${CMAKE_C_COMPILER_VERSION}" VERSION_GREATER_EQUAL "19.20")
include(SourceLink)
file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/source_link.json" SOURCE_LINK_JSON)
source_link(${PROJECT_SOURCE_DIR} ${SOURCE_LINK_JSON})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SOURCELINK:${SOURCE_LINK_JSON}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SOURCELINK:${SOURCE_LINK_JSON}")
else()
message(WARNING "Disabling SourceLink due to old version of MSVC. Please update to VS2019!")
endif()
endif()
# Include hashes of source files in the PDB
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /ZH:SHA_256")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZH:SHA_256")
endif()
# If using clang or GCC, only linked shared libraries if needed
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
endif()
# If using clang or GCC, be sure to include a build id
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id")
endif()
# If using clang or GCC, set default visibilty to hidden
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
# Find all dependencies
add_subdirectory(extern)
# Don't enable testing until after building dependencies
enable_testing()
# Turn on compiler flags for our code
include(k4aCompilerFlags)
# Source for the K4A SDK
set(K4A_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
# Source for the common version resource file
set(K4A_VERSION_RC ${CMAKE_CURRENT_LIST_DIR}/version.rc.in)
if ("${K4A_ENABLE_LEAK_DETECTION_CMAKE}" STREQUAL "1")
add_definitions(-DK4A_ENABLE_LEAK_DETECTION)
endif()
# Sets the RUNPATH entry in the .dynamic section of an elf. RUNPATH is
# interpreted by the linux loader as an additional path to search for shared
# objects. $ORIGIN is a special setting telling the loader to search the path
# relative to the exectuable.
#
# These specific settings tell the loader to search the directory of the
# executable for shared objects. This is done on Linux to emulate the default
# behavior of the Windows loader, which searches for DLLs in the path of the
# executable.
#
# We only set RPATH for build since our libs and executables are put in the
# same folder.
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(CMAKE_BUILD_RPATH "\$ORIGIN")
endif()
include(DetermineTargetArch)
determine_target_arch(TARGET_ARCH)
Add Green Screen example (#619) * Added beginnings of greenscreen example * More progress, try/catch * runs and sometimes gets all captures * WIP, but closer. * Single-camera greenscreen works! But it's slow * it's getting closer to working now and that's cool * further progress, not compiling * Calibration runs, unclear if correct * still WIP but coming along * still not working- calibration may not even be necessary * closer to working, sane results but not similar when moving calibration board * Still not perfect but consistently good * homogeneous matrix constructed reasonably * Greening partially working * CLeanup and fix averaging incorrectness * Added fix for reversed calibration points bug * Mostly comments * Working on a refactor and adding lots of explanation * Started refactor, fixed images desynchronizing * Better debugging and not dropping as many frames * debug commit * fixed slowness, starting to come together * More refactoring, mostly towards fewer vectors * yet more refactoring * Comment changes and made some long code a function * Removed unnecessary try-catch * More comments, cleanup, and less output params * Less output parameters * deleted extraneous function * Refactor a function to not have output args * another output param refactor * reformat comments * Added command-line options and fixed chessboard size issues * Explain some constants * Account for subordinate color-to-depth delay * threshold now a command line arg * Use Matx and factored transformation code mostly out * Only use one configuration object for each * Moved synchronization logic to MultiDeviceCapturer * minor comment clarifications * Cleaned up displaying a bit * Improved greenscreening logic * Calibration now uses many images * Minor cleanup * Fixed unclear indentation of comments * It's 'green screen', not 'greenscreen' * clangformat wants this, though it's not very clear * Set background completely green * Fixed incorrect usage of calibration * Added WIP README that provides info + background * Changed master-sub to main-backup in main to clarify purpose of devices * Hopefully sets up OpenCV as a dependency properly * Fixed typo in opencv install * Pre-search was failing, so don't pre-search * Construct new calibration object, not modify old * Consistency in camera name ordering * Fix out-of-date comment * More explanatory comment on transformations * Added copyright headers * Backup to secondary, hopefully more clear * Added more and better error messages * Refactor to not have vector of devices exposed * Remove GetOpt dependency, debug viz * Fixed issues with the merge * Attempt to get OpenCV conditionally required * Fix up some CMake issues and installation issues * Missed update to yaml * Added OpenCV library folder * Try to include opencv2 includes * Should not use that include dir like that * Install opencv from binaries on Windows attempt * Install opencv, add to path, tell cmake * Set env vars with logging commands * Don't bother with OpenCV for x86 builds * removed files that snuck in * Don't get OpenCV unless it's a 64-bit OS * Don't try OpenCV if we're building for x86 * no space * fail when decoding fails * Compile opencv example properly * Modify build because we need to know target arch * removed endif which causes compilation failure * Fixed up warning * Attempt to be able to use one or two cameras * Should properly check arch now for installing OpenCV * Needed quotes * Attempt to clean up azure pipelines logic * I don't actually know Azure Pipelines * Attempted cmake config fix * use variables better? * Don't think I should use expressions there * Another attempt to fix Azure Pipelines issues * Fixed weird opencv error by using BGRA not MJPG * One-device and two-device greenscreen modes work * Fixed OpenCV example test * Clarified comment * Temporarily disable Linux testing until test infra updated * attempt to fix occasional OpenCV download failures * Need PS6 for retry options * Don't install OpenCV unless specified. Fixes Linux build, hopefully * Add options for calibration timeouts and greenscreen duration * Now no longer assume OpenCV is required on Linux * Added single and double camera greenscreen example tests * Adjusted numbers in script for different calibration board in testing * See if issue is PATH or similar * Added better logging for error for functional unit tests * install opencv on test machine * Hopefully fix some of the issues with functional tests * Factor out install of opencv into a script * OpenCV-based tests should now not run unless OpenCV is installed * Don't install OpenCV on test machine but make sure it's there * typo * Try again to install OpenCV on test * Remove install opencv now that it's installed * Fixed a lingering "checkerboard" to "chessboard" * Use an Ubuntu 18.04 image and try to use the Ubuntu functional tests * Properly add the OpenCV tests if it's available * Don't bootstrap ubuntu because we have a docker image now * Don't install OpenCV, it's already in the Docker container * Remove confusing offset for devices in MultiDeviceCapturer * Build with Clang * No braces needed * A few more fixes from not using a vector for configs * More updates to README * Workaround for debug version of OpenCV on Windows * Explanations for the OpenCV LIBS issue and for green screen logic * Re-expanded correct sync window until firmware is updated * Greenscreen with background, not green * More modern CMake * No need to find package here * Added findopencv so no need to specify -DOpenCV_DIR
2019-08-31 03:11:58 +03:00
# CMake doesn't set the target processor correctly for MSVC
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
if ("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "")
set(K4A_BINARY_DIR_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(K4A_BINARY_DIR_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
else()
set(K4A_BINARY_DIR_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug)
set(K4A_BINARY_DIR_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/RelWithDebInfo)
endif()
# Check what architecture we are building for. This assumes all 64-bit architectures are amd64, which will break
# if we decide to support arm.
if ("${TARGET_ARCH}" STREQUAL "x86_64")
Add Green Screen example (#619) * Added beginnings of greenscreen example * More progress, try/catch * runs and sometimes gets all captures * WIP, but closer. * Single-camera greenscreen works! But it's slow * it's getting closer to working now and that's cool * further progress, not compiling * Calibration runs, unclear if correct * still WIP but coming along * still not working- calibration may not even be necessary * closer to working, sane results but not similar when moving calibration board * Still not perfect but consistently good * homogeneous matrix constructed reasonably * Greening partially working * CLeanup and fix averaging incorrectness * Added fix for reversed calibration points bug * Mostly comments * Working on a refactor and adding lots of explanation * Started refactor, fixed images desynchronizing * Better debugging and not dropping as many frames * debug commit * fixed slowness, starting to come together * More refactoring, mostly towards fewer vectors * yet more refactoring * Comment changes and made some long code a function * Removed unnecessary try-catch * More comments, cleanup, and less output params * Less output parameters * deleted extraneous function * Refactor a function to not have output args * another output param refactor * reformat comments * Added command-line options and fixed chessboard size issues * Explain some constants * Account for subordinate color-to-depth delay * threshold now a command line arg * Use Matx and factored transformation code mostly out * Only use one configuration object for each * Moved synchronization logic to MultiDeviceCapturer * minor comment clarifications * Cleaned up displaying a bit * Improved greenscreening logic * Calibration now uses many images * Minor cleanup * Fixed unclear indentation of comments * It's 'green screen', not 'greenscreen' * clangformat wants this, though it's not very clear * Set background completely green * Fixed incorrect usage of calibration * Added WIP README that provides info + background * Changed master-sub to main-backup in main to clarify purpose of devices * Hopefully sets up OpenCV as a dependency properly * Fixed typo in opencv install * Pre-search was failing, so don't pre-search * Construct new calibration object, not modify old * Consistency in camera name ordering * Fix out-of-date comment * More explanatory comment on transformations * Added copyright headers * Backup to secondary, hopefully more clear * Added more and better error messages * Refactor to not have vector of devices exposed * Remove GetOpt dependency, debug viz * Fixed issues with the merge * Attempt to get OpenCV conditionally required * Fix up some CMake issues and installation issues * Missed update to yaml * Added OpenCV library folder * Try to include opencv2 includes * Should not use that include dir like that * Install opencv from binaries on Windows attempt * Install opencv, add to path, tell cmake * Set env vars with logging commands * Don't bother with OpenCV for x86 builds * removed files that snuck in * Don't get OpenCV unless it's a 64-bit OS * Don't try OpenCV if we're building for x86 * no space * fail when decoding fails * Compile opencv example properly * Modify build because we need to know target arch * removed endif which causes compilation failure * Fixed up warning * Attempt to be able to use one or two cameras * Should properly check arch now for installing OpenCV * Needed quotes * Attempt to clean up azure pipelines logic * I don't actually know Azure Pipelines * Attempted cmake config fix * use variables better? * Don't think I should use expressions there * Another attempt to fix Azure Pipelines issues * Fixed weird opencv error by using BGRA not MJPG * One-device and two-device greenscreen modes work * Fixed OpenCV example test * Clarified comment * Temporarily disable Linux testing until test infra updated * attempt to fix occasional OpenCV download failures * Need PS6 for retry options * Don't install OpenCV unless specified. Fixes Linux build, hopefully * Add options for calibration timeouts and greenscreen duration * Now no longer assume OpenCV is required on Linux * Added single and double camera greenscreen example tests * Adjusted numbers in script for different calibration board in testing * See if issue is PATH or similar * Added better logging for error for functional unit tests * install opencv on test machine * Hopefully fix some of the issues with functional tests * Factor out install of opencv into a script * OpenCV-based tests should now not run unless OpenCV is installed * Don't install OpenCV on test machine but make sure it's there * typo * Try again to install OpenCV on test * Remove install opencv now that it's installed * Fixed a lingering "checkerboard" to "chessboard" * Use an Ubuntu 18.04 image and try to use the Ubuntu functional tests * Properly add the OpenCV tests if it's available * Don't bootstrap ubuntu because we have a docker image now * Don't install OpenCV, it's already in the Docker container * Remove confusing offset for devices in MultiDeviceCapturer * Build with Clang * No braces needed * A few more fixes from not using a vector for configs * More updates to README * Workaround for debug version of OpenCV on Windows * Explanations for the OpenCV LIBS issue and for green screen logic * Re-expanded correct sync window until firmware is updated * Greenscreen with background, not green * More modern CMake * No need to find package here * Added findopencv so no need to specify -DOpenCV_DIR
2019-08-31 03:11:58 +03:00
configure_file(k4a.props.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/k4a.x64.props)
configure_file(StubGenerator.xml.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/StubGenerator.x64.xml)
elseif("${TARGET_ARCH}" STREQUAL "i686")
Add Green Screen example (#619) * Added beginnings of greenscreen example * More progress, try/catch * runs and sometimes gets all captures * WIP, but closer. * Single-camera greenscreen works! But it's slow * it's getting closer to working now and that's cool * further progress, not compiling * Calibration runs, unclear if correct * still WIP but coming along * still not working- calibration may not even be necessary * closer to working, sane results but not similar when moving calibration board * Still not perfect but consistently good * homogeneous matrix constructed reasonably * Greening partially working * CLeanup and fix averaging incorrectness * Added fix for reversed calibration points bug * Mostly comments * Working on a refactor and adding lots of explanation * Started refactor, fixed images desynchronizing * Better debugging and not dropping as many frames * debug commit * fixed slowness, starting to come together * More refactoring, mostly towards fewer vectors * yet more refactoring * Comment changes and made some long code a function * Removed unnecessary try-catch * More comments, cleanup, and less output params * Less output parameters * deleted extraneous function * Refactor a function to not have output args * another output param refactor * reformat comments * Added command-line options and fixed chessboard size issues * Explain some constants * Account for subordinate color-to-depth delay * threshold now a command line arg * Use Matx and factored transformation code mostly out * Only use one configuration object for each * Moved synchronization logic to MultiDeviceCapturer * minor comment clarifications * Cleaned up displaying a bit * Improved greenscreening logic * Calibration now uses many images * Minor cleanup * Fixed unclear indentation of comments * It's 'green screen', not 'greenscreen' * clangformat wants this, though it's not very clear * Set background completely green * Fixed incorrect usage of calibration * Added WIP README that provides info + background * Changed master-sub to main-backup in main to clarify purpose of devices * Hopefully sets up OpenCV as a dependency properly * Fixed typo in opencv install * Pre-search was failing, so don't pre-search * Construct new calibration object, not modify old * Consistency in camera name ordering * Fix out-of-date comment * More explanatory comment on transformations * Added copyright headers * Backup to secondary, hopefully more clear * Added more and better error messages * Refactor to not have vector of devices exposed * Remove GetOpt dependency, debug viz * Fixed issues with the merge * Attempt to get OpenCV conditionally required * Fix up some CMake issues and installation issues * Missed update to yaml * Added OpenCV library folder * Try to include opencv2 includes * Should not use that include dir like that * Install opencv from binaries on Windows attempt * Install opencv, add to path, tell cmake * Set env vars with logging commands * Don't bother with OpenCV for x86 builds * removed files that snuck in * Don't get OpenCV unless it's a 64-bit OS * Don't try OpenCV if we're building for x86 * no space * fail when decoding fails * Compile opencv example properly * Modify build because we need to know target arch * removed endif which causes compilation failure * Fixed up warning * Attempt to be able to use one or two cameras * Should properly check arch now for installing OpenCV * Needed quotes * Attempt to clean up azure pipelines logic * I don't actually know Azure Pipelines * Attempted cmake config fix * use variables better? * Don't think I should use expressions there * Another attempt to fix Azure Pipelines issues * Fixed weird opencv error by using BGRA not MJPG * One-device and two-device greenscreen modes work * Fixed OpenCV example test * Clarified comment * Temporarily disable Linux testing until test infra updated * attempt to fix occasional OpenCV download failures * Need PS6 for retry options * Don't install OpenCV unless specified. Fixes Linux build, hopefully * Add options for calibration timeouts and greenscreen duration * Now no longer assume OpenCV is required on Linux * Added single and double camera greenscreen example tests * Adjusted numbers in script for different calibration board in testing * See if issue is PATH or similar * Added better logging for error for functional unit tests * install opencv on test machine * Hopefully fix some of the issues with functional tests * Factor out install of opencv into a script * OpenCV-based tests should now not run unless OpenCV is installed * Don't install OpenCV on test machine but make sure it's there * typo * Try again to install OpenCV on test * Remove install opencv now that it's installed * Fixed a lingering "checkerboard" to "chessboard" * Use an Ubuntu 18.04 image and try to use the Ubuntu functional tests * Properly add the OpenCV tests if it's available * Don't bootstrap ubuntu because we have a docker image now * Don't install OpenCV, it's already in the Docker container * Remove confusing offset for devices in MultiDeviceCapturer * Build with Clang * No braces needed * A few more fixes from not using a vector for configs * More updates to README * Workaround for debug version of OpenCV on Windows * Explanations for the OpenCV LIBS issue and for green screen logic * Re-expanded correct sync window until firmware is updated * Greenscreen with background, not green * More modern CMake * No need to find package here * Added findopencv so no need to specify -DOpenCV_DIR
2019-08-31 03:11:58 +03:00
configure_file(k4a.props.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/k4a.x86.props)
configure_file(StubGenerator.xml.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/StubGenerator.x86.xml)
else()
message(FATAL_ERROR "Unknown architecture for MSVC: ${TARGET_ARCH}")
Add Green Screen example (#619) * Added beginnings of greenscreen example * More progress, try/catch * runs and sometimes gets all captures * WIP, but closer. * Single-camera greenscreen works! But it's slow * it's getting closer to working now and that's cool * further progress, not compiling * Calibration runs, unclear if correct * still WIP but coming along * still not working- calibration may not even be necessary * closer to working, sane results but not similar when moving calibration board * Still not perfect but consistently good * homogeneous matrix constructed reasonably * Greening partially working * CLeanup and fix averaging incorrectness * Added fix for reversed calibration points bug * Mostly comments * Working on a refactor and adding lots of explanation * Started refactor, fixed images desynchronizing * Better debugging and not dropping as many frames * debug commit * fixed slowness, starting to come together * More refactoring, mostly towards fewer vectors * yet more refactoring * Comment changes and made some long code a function * Removed unnecessary try-catch * More comments, cleanup, and less output params * Less output parameters * deleted extraneous function * Refactor a function to not have output args * another output param refactor * reformat comments * Added command-line options and fixed chessboard size issues * Explain some constants * Account for subordinate color-to-depth delay * threshold now a command line arg * Use Matx and factored transformation code mostly out * Only use one configuration object for each * Moved synchronization logic to MultiDeviceCapturer * minor comment clarifications * Cleaned up displaying a bit * Improved greenscreening logic * Calibration now uses many images * Minor cleanup * Fixed unclear indentation of comments * It's 'green screen', not 'greenscreen' * clangformat wants this, though it's not very clear * Set background completely green * Fixed incorrect usage of calibration * Added WIP README that provides info + background * Changed master-sub to main-backup in main to clarify purpose of devices * Hopefully sets up OpenCV as a dependency properly * Fixed typo in opencv install * Pre-search was failing, so don't pre-search * Construct new calibration object, not modify old * Consistency in camera name ordering * Fix out-of-date comment * More explanatory comment on transformations * Added copyright headers * Backup to secondary, hopefully more clear * Added more and better error messages * Refactor to not have vector of devices exposed * Remove GetOpt dependency, debug viz * Fixed issues with the merge * Attempt to get OpenCV conditionally required * Fix up some CMake issues and installation issues * Missed update to yaml * Added OpenCV library folder * Try to include opencv2 includes * Should not use that include dir like that * Install opencv from binaries on Windows attempt * Install opencv, add to path, tell cmake * Set env vars with logging commands * Don't bother with OpenCV for x86 builds * removed files that snuck in * Don't get OpenCV unless it's a 64-bit OS * Don't try OpenCV if we're building for x86 * no space * fail when decoding fails * Compile opencv example properly * Modify build because we need to know target arch * removed endif which causes compilation failure * Fixed up warning * Attempt to be able to use one or two cameras * Should properly check arch now for installing OpenCV * Needed quotes * Attempt to clean up azure pipelines logic * I don't actually know Azure Pipelines * Attempted cmake config fix * use variables better? * Don't think I should use expressions there * Another attempt to fix Azure Pipelines issues * Fixed weird opencv error by using BGRA not MJPG * One-device and two-device greenscreen modes work * Fixed OpenCV example test * Clarified comment * Temporarily disable Linux testing until test infra updated * attempt to fix occasional OpenCV download failures * Need PS6 for retry options * Don't install OpenCV unless specified. Fixes Linux build, hopefully * Add options for calibration timeouts and greenscreen duration * Now no longer assume OpenCV is required on Linux * Added single and double camera greenscreen example tests * Adjusted numbers in script for different calibration board in testing * See if issue is PATH or similar * Added better logging for error for functional unit tests * install opencv on test machine * Hopefully fix some of the issues with functional tests * Factor out install of opencv into a script * OpenCV-based tests should now not run unless OpenCV is installed * Don't install OpenCV on test machine but make sure it's there * typo * Try again to install OpenCV on test * Remove install opencv now that it's installed * Fixed a lingering "checkerboard" to "chessboard" * Use an Ubuntu 18.04 image and try to use the Ubuntu functional tests * Properly add the OpenCV tests if it's available * Don't bootstrap ubuntu because we have a docker image now * Don't install OpenCV, it's already in the Docker container * Remove confusing offset for devices in MultiDeviceCapturer * Build with Clang * No braces needed * A few more fixes from not using a vector for configs * More updates to README * Workaround for debug version of OpenCV on Windows * Explanations for the OpenCV LIBS issue and for green screen logic * Re-expanded correct sync window until firmware is updated * Greenscreen with background, not green * More modern CMake * No need to find package here * Added findopencv so no need to specify -DOpenCV_DIR
2019-08-31 03:11:58 +03:00
endif()
endif()
add_subdirectory(examples)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(tools)
if (K4A_BUILD_DOCS)
find_package(Doxygen 1.8.14 EXACT)
if (DOXYGEN_FOUND)
set(DOXYGEN_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/mainpage.md)
set(DOXYGEN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/include/k4a
${CMAKE_CURRENT_SOURCE_DIR}/include/k4arecord
${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/sdk
${DOXYGEN_MAINPAGE})
set(DOXYGEN_LAYOUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/DoxygenLayout.xml)
# These variables are used in Doxyfile.in
string(REPLACE ";" " " DOXYGEN_INPUT "${DOXYGEN_SOURCES}")
set(DOXYGEN_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/docs)
set(DOXYGEN_PROJECT_LOGO ${CMAKE_CURRENT_SOURCE_DIR}/docs/logo.png)
set(DOXYGEN_TEMPLATE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
set(DOXYGEN_PROJECT_NUMBER ${SOURCE_BRANCH})
configure_file(doxygen/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
add_custom_command(
OUTPUT ${DOXYGEN_OUTPUT_DIRECTORY}/html/index.html
COMMAND ${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
MAIN_DEPENDENCY doxygen/Doxyfile.in
DEPENDS ${DOXYGEN_SOURCES}
)
add_custom_target(k4adocs ALL DEPENDS ${DOXYGEN_OUTPUT_DIRECTORY}/html/index.html)
endif()
endif()
option(K4A_VALIDATE_CLANG_FORMAT "Validate clang-format results as part of build" Yes)
set (CLANG_FORMAT_ROOT
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/examples
${CMAKE_CURRENT_SOURCE_DIR}/tests
${CMAKE_CURRENT_SOURCE_DIR}/tools)
find_program(CLANG_FORMAT clang-format DOC "Clang format tool")
if (${CLANG_FORMAT} STREQUAL "CLANG_FORMAT-NOTFOUND")
message(STATUS "Clang-format not found")
else()
set(VALID_CLANG_FORMAT_VERSION "6\.0\.0")
execute_process(COMMAND ${CLANG_FORMAT} -version OUTPUT_VARIABLE CLANG_VERSION_STRING)
message(STATUS "clang-format version: ${CLANG_VERSION_STRING}")
if (${CLANG_VERSION_STRING} MATCHES "^.*${VALID_CLANG_FORMAT_VERSION}.*$")
find_package(Python3 COMPONENTS Interpreter)
if (NOT ${Python3_FOUND})
message(FATAL_ERROR "Could not find Python3")
endif()
set(CLANG_FORMAT_SOURCES)
foreach(root ${CLANG_FORMAT_ROOT})
file(GLOB_RECURSE CLANG_FORMAT_SOURCES_X CONFIGURE_DEPENDS
${root}/*.c
${root}/*.cpp
${root}/*.h
${root}/*.hpp)
list(APPEND CLANG_FORMAT_SOURCES ${CLANG_FORMAT_SOURCES_X})
endforeach()
set(VALIDATE_RESULT_LIST)
set(REFORMAT_RESULT_LIST)
foreach(file ${CLANG_FORMAT_SOURCES})
file(RELATIVE_PATH filerelpath ${CMAKE_CURRENT_SOURCE_DIR} ${file})
set(validateoutput "${CMAKE_CURRENT_BINARY_DIR}/${filerelpath}.clang-validate-result")
set(reformatoutput "${CMAKE_CURRENT_BINARY_DIR}/${filerelpath}.clang-reformat-result")
add_custom_command(
OUTPUT ${validateoutput}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ValidateFormat.py --clangformat "${CLANG_FORMAT}" --file ${file} --output ${validateoutput}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DEPENDS ${file}
COMMENT "Validating format of ${file}"
)
list(APPEND VALIDATE_RESULT_LIST ${validateoutput})
add_custom_command(
OUTPUT ${reformatoutput}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ValidateFormat.py --reformat --clangformat "${CLANG_FORMAT}" --file ${file} --output ${reformatoutput}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DEPENDS ${file}
COMMENT "Reformatting ${file}"
)
list(APPEND REFORMAT_RESULT_LIST ${reformatoutput})
endforeach()
if (${K4A_VALIDATE_CLANG_FORMAT})
add_custom_target(validateclangformat ALL DEPENDS ${VALIDATE_RESULT_LIST})
else()
add_custom_target(validateclangformat DEPENDS ${VALIDATE_RESULT_LIST})
endif()
add_custom_target(clangformat DEPENDS ${REFORMAT_RESULT_LIST})
else()
message(STATUS "Need clang-format version ${VALID_CLANG_FORMAT_VERSION}")
message(STATUS "Not validating source format")
endif()
endif()
# Generate .NET Version file.
configure_file(VersionInfo.cs.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/VersionInfo.cs)
# Packaging support
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
set(CPACK_PACKAGE_VENDOR "Microsoft")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "C/C++ SDK for Kinect for Azure")
set(CPACK_PACKAGE_DESCRIPTION "C/C++ SDK for Kinect for Azure")
set(CPACK_PACKAGE_VERSION_MAJOR ${K4A_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${K4A_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${K4A_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${K4A_VERSION_STR})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_NAME "k4asdk")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${K4A_VERSION_STR}.${CMAKE_SYSTEM_NAME}.${TARGET_ARCH}.${CMAKE_BUILD_TYPE}")
set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP")
set(CPACK_GENERATOR "TGZ" "ZIP")
include(CPack)
cpack_add_component(
runtime
DISPLAY_NAME
Runtime
DESCRIPTION
"Dynamic Libraries for Azure Kinect Runtime"
REQUIRED)
cpack_add_component(
development
DISPLAY_NAME
Development
DESCRIPTION
"Headers and cmake files needed for Azure Kinect Development"
REQUIRED
DEPENDS
runtime)
cpack_add_component(
tools
DISPLAY_NAME
Tools
DESCRIPTION
"Tools for Azure Kinect Development"
REQUIRED
DEPENDS
runtime)