首页 > 解决方案 > 构建 CGAL 5.0 演示 GraphicsView 的问题

问题描述

我已经在我的 Ubuntu 18.04.3 机器上安装了 CGAL 5.0(进入我的主目录)并尝试构建一些可视化演示 - 没有成功。例如演示目录<my CGAL root>/demo/GraphicsView包含以下CMakeLists.txt文件:

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

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

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)

find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)

if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND )

  add_definitions(-DQT_NO_KEYWORDS)
  set(CMAKE_INCLUDE_CURRENT_DIR ON)

  add_executable  ( min min.cpp  ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES})

  add_to_cached_list( CGAL_EXECUTABLE_TARGETS min )

  target_link_libraries( min PRIVATE
    CGAL::CGAL CGAL::CGAL_Qt5 Qt5::Gui )

  include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake)
  cgal_add_compilation_test(min)
else()

  message(STATUS "NOTICE: This demo requires CGAL and Qt5, and will not be compiled.")

endif()

该命令cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<my CGAL root> .生成以下输出:

-- Found Boost: /usr/include (found version "1.65.1")  
-- Found Boost: /usr/include (found suitable version "1.65.1", minimum required is "1.48")  
-- Boost include dirs: /usr/include
-- Boost libraries:    
-- libCGAL_Qt5 is missing the dependencies:  <CGAL/Qt/*.h> headers cannot be configured.
-- NOTICE: The CGAL_Qt5 library was not configured.
-- NOTICE: This demo requires CGAL and Qt5, and will not be compiled.
...

<my CGAL root>/include/CGAL/Qt目录存在并包含很多标头 - 因此,消息<CGAL/Qt/*.h>标头无法配置”看起来非常可疑。

我可以尝试什么来克服这个问题?

更新#1。这仅是 CGAL 5.0 的问题,并且当它使用 option 构建时CGAL_HEADER_ONLY=OFF。罪魁祸首很可能在 CGAL 5.0*.cmake文件中。

更新#2。我使用我的脚本(如下)来构建和安装 CGAL 5.0。

PKG_NAME=CGAL
PKG_VER=5.0
PKG_FULL_NAME=${PKG_NAME}-${PKG_VER}

sudo apt install libgmp-dev
sudo apt install libmpfr-dev
sudo apt install qt5-default
sudo apt install qtscript5-dev

DST_DIR=${HOME}/apps/CGAL/CGAL-5.0
ZIP_DIR=${HOME}/soft

cd /tmp
tar xJvf ${ZIP_DIR}/${PKG_FULL_NAME}.tar.xz
cd ${PKG_FULL_NAME}

mkdir -p build && pushd build
cmake -DCMAKE_INSTALL_PREFIX=${DST_DIR} -DCMAKE_BUILD_TYPE=Release -DCGAL_HEADER_ONLY=OFF ..
make
make install
popd

cp -pr demo ${DST_DIR}
cp -pr examples ${DST_DIR}

cd ..
rm -fr ${PKG_FULL_NAME}

标签: cmakeqt5ubuntu-18.04cgal

解决方案


(Thanks for your patience in reporting the bug.)

There is indeed a logic error in CGAL-5.0, when installed in non-header-only mode. I will issue a fix soon. And a new release CGAL-5.0.1.

Can you please try with this patch?

diff --git a/Installation/cmake/modules/CGALConfig_install.cmake.in b/Installation/cmake/modules/CGALConfig_install.cmake.in
index 873fa8c6a9e..cb51524dcfa 100644
--- a/Installation/cmake/modules/CGALConfig_install.cmake.in
+++ b/Installation/cmake/modules/CGALConfig_install.cmake.in
@@ -55,7 +55,7 @@ set(CGAL_ImageIO_USE_ZLIB                 "@CGAL_ImageIO_USE_ZLIB@" )
 set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}")

 set(CGAL_USE_FILE "${CGAL_MODULES_DIR}/UseCGAL.cmake" )
-set(CGAL_GRAPHICSVIEW_PACKAGE_DIR "${CGAL_INCLUDE_DIRS}/CGAL/" CACHE INTERNAL "Directory containing the GraphicsView package")
+set(CGAL_GRAPHICSVIEW_PACKAGE_DIR "${CGAL_INSTALL_PREFIX}" CACHE INTERNAL "Directory containing the GraphicsView package")

 if ( CGAL_FIND_REQUIRED )
   set( CHECK_CGAL_COMPONENT_MSG_ON_ERROR TRUE        )

The patch applies to CGAL-5.0/ with patch -p2. Once the patch is applied, please reinstall CGAL.

Update: here is the pull-request, in Github: https://github.com/CGAL/cgal/pull/4459


推荐阅读