【问题标题】:CGAL example on Ubuntu 18.04Ubuntu 18.04 上的 CGAL 示例
【发布时间】:2020-01-13 11:52:38
【问题描述】:

我在 ubuntu 18.04 LTS 上通过包管理器安装了 CGAL。然后如https://doc.cgal.org/latest/Manual/usage.html 所述,以编译示例程序。当我发布时:

cmake -DCMAKE_BUILD_TYPE=Release .

要配置示例,我收到以下错误:

CMake Error at CMakeLists.txt:29 (create_single_source_cgal_program):
  Unknown CMake command "create_single_source_cgal_program".


-- Configuring incomplete, errors occurred!

请帮助;我该怎么办?

CmakeLists.txt

# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.


cmake_minimum_required(VERSION 3.1...3.15)
project( Triangulation_2_Examples )


if(NOT POLICY CMP0070 AND POLICY CMP0053)
  # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
  cmake_policy(SET CMP0053 OLD)
endif()

if(POLICY CMP0071)
  cmake_policy(SET CMP0071 NEW)
endif()

find_package(CGAL COMPONENTS Qt5)

if(CGAL_Qt5_FOUND)
  add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()

if ( CGAL_FOUND )

  # create a target per cppfile
  file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
  foreach(cppfile ${cppfiles})
    create_single_source_cgal_program( "${cppfile}" )
  endforeach()

  if(CGAL_Qt5_FOUND)
    target_link_libraries(draw_triangulation_2 PUBLIC CGAL::CGAL_Qt5)
  else()
    message(STATUS "NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled.")
  endif()

else()

    message(STATUS "This program requires the CGAL library, and will not be compiled.")

endif()

【问题讨论】:

  • 您使用的是 CGAL 示例中的 cmake 脚本还是您编写的脚本?还要确保有find_library(CGAL)if (CGAL_FOUND)
  • 这是 CMake 发出的第一个错误吗?在此之前可能有一个可以解释第二个错误。
  • @sloriot 我现在只是想运行 CGAL 示例...我没有写任何东西...我也附上了 CMakeLists.txt 文件...请检查。
  • @Irineau 不,这不是第一个错误......它显示了一些丢失的包,但是在安装了相应的包之后......只剩下这个错误
  • 你从哪里得到的例子?您是否安装了 libcgal-demo,或者您是否下载了 CGAL-5.0 并查看了那些示例(与您安装的 CGAL 版本不匹配)?

标签: geometry ubuntu-18.04 computational-geometry cgal


【解决方案1】:

看起来我们应该在安装 CGAL 期间立即构建所有 CGAL 示例(使用cmake 选项-DWITH_examples=ON)。示例和子示例很多,构建起来需要很长时间。

但是,我能够有选择地一个一个地构建这些示例(见下文)。我不是 CGAL 开发人员,所以我的方法可能不是他们想要的——但无论如何我希望它对 CGAL 社区有用。我假设已经安装了 CGAL,但没有示例。

第 1 步。使用您想要的任何名称为 CGAL 示例创建一个目录,然后输入此目录:

mkdir CGAL
cd GGAL

第 2 步。将 CGAL 发行版中的 examples 目录复制到该目录中,并确保它是可写的:

cp -r <CGAL distribution>/examples .
chmod -R u+w examples

第 3 步。运行cmake 以生成Makefile。如果您将 CGAL 安装到某个不寻常的位置,您将需要 CMAKE_INSTALL_PREFIX 选项来告诉 cmake 这个位置:

cmake -DCMAKE_INSTALL_PREFIX=<CGAL location> examples

第 4 步。运行make help 以查看您可以制作的所有可能示例。您可以选择所有示例,这些示例可以显示一些内容:

make help | grep draw

第 5 步。构建Triangulation_2 示例之一:

make draw_triangulation_2

第 6 步。进入示例目录,运行示例:

cd examples/Triangulation_2
./draw_triangulation_2&

顺便说一句,由于某种原因,第一次运行 draw_triangulation_2 在我的盒子上显示了一个空窗口,但第二次运行显示了正确的图片。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 2021-12-01
    • 2018-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多