我想建立一个简单的CGAL + Qt程序。简而言之,我想采取以下措施:
并使用Qt打印出来。我编译上面没有问题:
cgal_create_CMakeLists -c Core
cmake -DCGAL_DIR=/usr/share/CGAL/ .
make
并且能够使用qmake编译各种Qt程序,但是我在conics.cpp文件中使用Qt遇到了困难。
我的问题是:
更新
我一直在尝试找出如何使用Qt标头编译程序。在多边形演示之后,我添加了:
// Qt headers
#include <QtGui>
#include <QString>
#include <QFileDialog>
#include <QInputDialog>
#include <QGraphicsLineItem>
至conics.cpp。我也没有运气:
cgal_create_cmake_script
或:
cgal_create_CMakeLists -c Core:Qt5
到目前为止,有效的方法是将Polygon演示中的CMakeLists.txt修改为:
project (Qt_Demo)
cmake_minimum_required(VERSION 3.1)
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()
find_package(CGAL COMPONENTS Qt5 Core)
include(${CGAL_USE_FILE})
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
include_directories (BEFORE ../../include)
if ( CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND )
add_definitions(-DQT_NO_KEYWORDS)
if( CGAL_Core_FOUND)
add_definitions(-DCGAL_USE_CORE)
endif()
#--------------------------------
# Demo: Polygon_2
#--------------------------------
# UI files (Qt Designer files)
#qt5_wrap_ui( DT_UI_FILES Polygon_2.ui )
# qrc files (resources files, that contain icons, at least)
#qt5_add_resources ( CGAL_Qt5_RESOURCE_FILES ./Polygon_2.qrc )
# use the Qt MOC preprocessor on classes that derives from QObject
qt5_generate_moc( conics.cpp "${CMAKE_CURRENT_BINARY_DIR}/conics.moc" )
# add_library( CGAL SHARED IMPORTED )
# SET_PROPERTY(TARGET CGAL PROPERTY IMPORTED_LOCATION ${CGAL_LIBRARY} )
# The executable itself.
add_executable ( conics conics.cpp conics.moc ${DT_UI_FILES} ${DT_RESOURCE_FILES} ${CGAL_Qt5_RESOURCE_FILES} ${CGAL_Qt5_MOC_FILES} )
qt5_use_modules(conics Xml Script OpenGL Svg)
add_to_cached_list( CGAL_EXECUTABLE_TARGETS conics )
# Link with Qt libraries
target_link_libraries( conics ${QT_LIBRARIES} )
# And with CGAL libraries
target_link_libraries( conics ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
else()
message(STATUS "NOTICE: This demo requires CGAL, CGAL_Core, and Qt5, and will not be compiled.")
endif()
真的,应该有一个更简单的方法!