生成RealSense Python包装时出现CMake错误:无法为目标“PRIVATE”指定源

2024-05-23 16:57:13 发布

您现在位置:Python中文网/ 问答频道 /正文

背景

我想用Python3.6中的realseense深度摄影机制作一个程序。但是,包装器仅适用于python 2,但是根据它们的github page,可以由用户自己构建:

Windows users can install the RealSense SDK 2.0 from the release tab to get pre-compiled binaries of the wrapper, for both x86 and x64 architectures. (Note that these binaries are built with Python 2.7, and cannot be import using Python 3).

还有一个issues

Unfortunately no, the only way at the moment is by building it from source. We are planing to provide a PyPI package that will allow you to simply pip install pyrealsense2 and it will have both python 2 and 3 support, but it is still work in progress...

因此,我决定在恢复到python2.x之前尝试自己构建它。 我遵循了github documentation上的解释,对于从未真正构建过任何东西的人来说,这有点过于基本。我有点困惑,但我碰到了一堵墙,CMake文档、stackoverflow和通用的google搜索对我没有帮助。这可能是由于我缺乏理解,但我决定伸出援手,看看我能学到什么。在

我的问题

目前我遇到了一个错误:

CMake Error at core/CMakeLists.txt:3 (target_sources):
  Cannot specify sources for target "PRIVATE" which is not built by this
  project.
Call Stack (most recent call first):
  CMakeLists.txt:5 (include)

我试着理解CMakeLists.txt文件看起来像这样:

^{pr2}$

在查看了文档之后,我决定将PRIVATE更改为PUBLIC,但这导致了相同的错误(但是使用public而不是private)。在

对于这个错误的字面搜索(在引号之间)没有返回任何结果,其他的测试也没有进一步帮助我。在

我现在假设问题出在${LRS_TARGET}变量上,但我不知道该在哪里查找。我似乎找不到应该在哪里定义它,而在CMake gui中将其设置为“Entry”会使错误显示为“value”而不是“PRIVATE”。在

有人能帮我吗?提前谢谢!在

我的设置

使用以下cmake设置:

  • “源代码在哪里:”=D:/librealseness master/src
  • “在哪里构建二进制文件:”=D:/librealseness master/bin
  • BUILD_PYTHON_BINDINGS=True
  • -DPYTHON_EXECUTABLE=D:/Anaconda3/python.exe在

剩下的,我什么也没做,只有一些条目出现了,我自己做了。在

我解决的问题

因为有人可能正在尝试和我一样的事情,我将提到我到现在为止所采取的步骤:

  1. 我得到的第一个问题是我需要在main的顶部添加以下行CMakeLists.txt文件文件:

    cmake_minimum_required(VERSION 3.14)
    
  2. 然后我发现我需要安装visualstudio

  3. <> LI>

    发现只有Visual Studio不够,需要用C++ “工作负载”

    来添加桌面开发

Tags: installand文件thetofromgithubtxt