1
- cmake_minimum_required (VERSION 3.10 )
1
+ cmake_minimum_required (VERSION 3.11 )
2
2
project (pym3t LANGUAGES CXX)
3
3
4
- find_package (pybind11 CONFIG REQUIRED)
4
+ option (USE_AZURE_KINECT "Use Azure Kinect" OFF )
5
+ option (USE_REALSENSE "Use RealSense D435" ON )
6
+ option (USE_GTEST "Use gtest" OFF )
5
7
6
- # TODO: find a way to pass these options as command line arguments
7
- set (USE_AZURE_KINECT OFF CACHE BOOL "Use Azure Kinect" )
8
- set (USE_REALSENSE ON CACHE BOOL "Use RealSense D435" )
9
- set (USE_GTEST OFF CACHE BOOL "Use gtest" )
8
+ cmake_policy (SET CMP0148 OLD) # required for current pybind11
10
9
11
- set (CMAKE_BUILD_TYPE "RELEASE" )
12
- # set(CMAKE_BUILD_TYPE "DEBUG")
10
+ # set(CMAKE_BUILD_TYPE "RELEASE") set(CMAKE_BUILD_TYPE "DEBUG")
13
11
14
- set (CMAKE_CXX_STANDARD 17)
15
-
16
- # We need libraries to be generated with Position Independent Code
17
- # otherwise compilation error in the pybind11 code
18
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
19
-
20
- add_subdirectory (extern/3DObjectTracking/M3T)
12
+ include (FetchContent)
13
+ FetchContent_Declare(
14
+ pybind11
15
+ GIT_REPOSITORY "https://github.com/pybind/pybind11"
16
+ GIT_TAG "v2.11.1" )
17
+ FetchContent_Declare(
18
+ m3t
19
+ GIT_REPOSITORY "https://github.com/DLR-RM/3DObjectTracking.git"
20
+ GIT_TAG "master"
21
+ SOURCE_SUBDIR "M3T" CMAKE_ARGS "-DUSE_AZURE_KINECT=${USE_AZURE_KINECT} "
22
+ "-DUSE_REALSENSE=${USE_REALSENSE} " "-DUSE_GTEST=${USE_GTEST} " )
23
+ FetchContent_MakeAvailable(pybind11 m3t)
21
24
22
25
# Create library for the extensions to m3t
23
- add_library (m3t_ext src/dummy_camera.cpp)
24
- target_include_directories (m3t_ext PUBLIC include )
26
+ add_library (m3t_ext src/dummy_camera.cpp include /pym3t/dummy_camera.h)
27
+ target_compile_features (m3t_ext PUBLIC cxx_std_17)
28
+ target_include_directories (
29
+ m3t_ext
30
+ PUBLIC $<INSTALL_INTERFACE:include >
31
+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include >
32
+ $<BUILD_INTERFACE:${m3t_SOURCE_DIR} /include >)
25
33
target_link_libraries (m3t_ext PUBLIC m3t)
26
34
27
35
pybind11_add_module(_pym3t_mod MODULE src/pym3t.cpp)
28
- target_link_libraries (_pym3t_mod PUBLIC m3t)
29
36
target_link_libraries (_pym3t_mod PUBLIC m3t_ext)
30
- target_compile_features (_pym3t_mod PUBLIC cxx_std_17)
31
- target_include_directories (_pym3t_mod PUBLIC include )
37
+ target_include_directories (
38
+ _pym3t_mod PUBLIC $<INSTALL_INTERFACE:include >
39
+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR} /include >)
32
40
33
- install (TARGETS _pym3t_mod DESTINATION pym3t)
41
+ install (TARGETS _pym3t_mod DESTINATION pym3t)
0 commit comments