From 1fbeec436757a5ef8792e8e1982305ed35755bc7 Mon Sep 17 00:00:00 2001 From: Iordan Iordanov Date: Wed, 3 Feb 2016 17:48:58 +0100 Subject: [PATCH] Corrections for CMakeLists.txt and minor changes regarding Qt5 moc requirements --- .../Hyperbolic_triangulation_2/CMakeLists.txt | 166 ++++-------------- .../Hyperbolic_Dirichlet_region_2_demo.cpp | 3 +- ...launay_hyperbolic_triangulation_2_demo.cpp | 2 +- 3 files changed, 41 insertions(+), 130 deletions(-) diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt index 113e18f26ba..6cb1c1b5847 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt @@ -1,143 +1,53 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. -project (Hyperbolic_Triangulation_2_demo) +project (Hyperbolic_triangulation_2_demo) -cmake_minimum_required(VERSION 2.6.2) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) + +cmake_minimum_required(VERSION 2.8.11) +if(POLICY CMP0043) + cmake_policy(SET CMP0043 OLD) endif() -project( Hyperbolic_triangulation_2 ) +find_package(CGAL COMPONENTS Qt5) +include(${CGAL_USE_FILE}) +find_package(Qt5 QUIET COMPONENTS Widgets) -cmake_minimum_required(VERSION 2.6.2) -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6) - if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3) - cmake_policy(VERSION 2.8.4) - else() - cmake_policy(VERSION 2.6) - endif() -endif() +include_directories (BEFORE ../../include include ui) -set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) - -if ( COMMAND cmake_policy ) - - cmake_policy( SET CMP0003 NEW ) - -endif() - -# CGAL and its components -find_package( CGAL QUIET COMPONENTS Qt5Core Qt5Giu Qt5Widgets ) - -# Find the QtWidgets library -find_package(Qt5Core) -find_package(Qt5Gui) -find_package(Qt5Widgets) - -# Add the include directories for the Qt 5 Widgets module to -# the compile lines. -include_directories(${Qt5Core_INCLUDE_DIRS}) -include_directories(${Qt5Gui_INCLUDE_DIRS}) -include_directories(${Qt5Widgets_INCLUDE_DIRS}) - -# Use the compile definitions defined in the Qt 5 Widgets module -add_definitions(${Qt5Core_DEFINITIONS}) -add_definitions(${Qt5Gui_DEFINITIONS}) -add_definitions(${Qt5Widgets_DEFINITIONS}) - -# Add compiler flags for building executables (-fPIE) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") - -include(${QT_USE_FILE}) - -#-------------------------------- -# The "Delaunay" demo: Delaunay_triangulation_2 -#-------------------------------- -# UI files (Qt Designer files) -qt4_wrap_ui( DT_UI_FILES ../../../GraphicsView/demo/Triangulation_2/Delaunay_triangulation_2.ui ) +# ui files, created with Qt Designer +qt5_wrap_ui( uis Hyperbolic_translations_2.ui ) # qrc files (resources files, that contain icons, at least) -qt4_add_resources ( DT_RESOURCE_FILES ../../../GraphicsView/demo/Triangulation_2/Delaunay_triangulation_2.qrc ) - -# use the Qt MOC preprocessor on classes that derives from QObject -qt4_generate_moc( "Hyperbolic_Delaunay_triangulation_2_demo.cpp" "${CMAKE_CURRENT_BINARY_DIR}/Hyperbolic_Delaunay_triangulation_2_demo.moc" ) - -# The executable itself. -add_executable ( Hyperbolic_Delaunay_triangulation_2_demo Hyperbolic_Delaunay_triangulation_2_demo.cpp Hyperbolic_Delaunay_triangulation_2_demo.moc ${DT_UI_FILES} ${DT_RESOURCE_FILES} ) - -add_to_cached_list( CGAL_EXECUTABLE_TARGETS Hyperbolic_Delaunay_triangulation_2_demo ) - -# Link with Qt libraries -target_link_libraries( Hyperbolic_Delaunay_triangulation_2_demo ${QT_LIBRARIES} ) -# Link with CGAL -target_link_libraries( Hyperbolic_Delaunay_triangulation_2_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}) - -#-------------------------------- -# The "hyperbolic" demo: Hyperbolic_translations_2 -#-------------------------------- -# UI files (Qt Designer files) -qt4_wrap_ui( DT_UI_FILES ui/Hyperbolic_translations_2.ui ) - -# qrc files (resources files, that contain icons, at least) -qt4_add_resources ( DT_RESOURCE_FILES resources/Hyperbolic_translations_2.qrc ) - -# use the Qt MOC preprocessor on classes that derives from QObject -qt4_generate_moc( "Hyperbolic_translations_2_demo.cpp" "${CMAKE_CURRENT_BINARY_DIR}/Hyperbolic_translations_2_demo.moc" ) - -# The executable itself. -add_executable ( Hyperbolic_translations_2_demo Hyperbolic_translations_2_demo.cpp Hyperbolic_translations_2_demo.moc ${DT_UI_FILES} ${DT_RESOURCE_FILES} ) - -add_to_cached_list( CGAL_EXECUTABLE_TARGETS Hyperbolic_translations_2_demo ) - -# Creating entries for all .cpp/.C files with "main" routine -# ########################################################## - -#-------------------------------- -# The "Periodic Delaunay hyperbolic " demo: -#-------------------------------- - -qt5_generate_moc( Hyperbolic_Delaunay_triangulation_2_demo.cpp Hyperbolic_Delaunay_triangulation_2_demo.moc ) -create_single_source_cgal_program( "Hyperbolic_Delaunay_triangulation_2_demo.cpp" ) -target_link_libraries(Hyperbolic_Delaunay_triangulation_2_demo CGAL CGAL_Qt5 Qt5::Core Qt5::Gui Qt5::Widgets) - -################ - - -qt5_generate_moc( Hyperbolic_Dirichlet_region_2_demo.cpp Hyperbolic_Dirichlet_region_2_demo.moc ) -create_single_source_cgal_program( "Hyperbolic_Dirichlet_region_2_demo.cpp" ) -target_link_libraries(Hyperbolic_Dirichlet_region_2_demo CGAL CGAL_Qt5 Qt5::Core Qt5::Gui Qt5::Widgets) - -################ - - -qt5_generate_moc( Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.moc ) -create_single_source_cgal_program( "Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp" ) -target_link_libraries(Periodic_2_Delaunay_hyperbolic_triangulation_2_demo CGAL CGAL_Qt5 Qt5::Core Qt5::Gui Qt5::Widgets) - -################ - -qt5_generate_moc( Hyperbolic_translations_2_demo.cpp Hyperbolic_translations_2_demo.moc ) -create_single_source_cgal_program( "Hyperbolic_translations_2_demo.cpp" ) -target_link_libraries(Hyperbolic_translations_2_demo CGAL CGAL_Qt5 Qt5::Core Qt5::Gui Qt5::Widgets) - - - - -# Link with Qt libraries -target_link_libraries( Hyperbolic_Dirichlet_region_2_demo ${QT_LIBRARIES} ) -# Link with CGAL -target_link_libraries( Hyperbolic_Dirichlet_region_2_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}) +qt5_add_resources ( RESOURCE_FILES resources/Hyperbolic_translations_2.qrc ) else() - message(STATUS "NOTICE: This demo requires CGAL and Qt4, and will not be compiled.") +# cpp files +add_executable ( Hyperbolic_Dirichlet_region_2_demo Hyperbolic_Dirichlet_region_2_demo.cpp ) +add_executable ( Hyperbolic_Delaunay_triangulation_2_demo Hyperbolic_Delaunay_triangulation_2_demo.cpp ) +add_executable ( Periodic_2_Delaunay_hyperbolic_triangulation_2_demo Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp ) +add_executable ( Hyperbolic_translations_2_demo Hyperbolic_translations_2_demo.cpp ) + +qt5_use_modules( Hyperbolic_Dirichlet_region_2_demo Widgets) +qt5_use_modules( Hyperbolic_Delaunay_triangulation_2_demo Widgets) +qt5_use_modules( Periodic_2_Delaunay_hyperbolic_triangulation_2_demo Widgets) +qt5_use_modules( Hyperbolic_translations_2_demo Widgets) + +add_to_cached_list( CGAL_EXECUTABLE_TARGETS Hyperbolic_Dirichlet_region_2_demo ) +add_to_cached_list( CGAL_EXECUTABLE_TARGETS Hyperbolic_Delaunay_triangulation_2_demo ) +add_to_cached_list( CGAL_EXECUTABLE_TARGETS Periodic_2_Delaunay_hyperbolic_triangulation_2_demo ) +add_to_cached_list( CGAL_EXECUTABLE_TARGETS Hyperbolic_translations_2_demo ) + +target_link_libraries( Hyperbolic_Dirichlet_region_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} ) +target_link_libraries( Hyperbolic_Delaunay_triangulation_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} ) +target_link_libraries( Periodic_2_Delaunay_hyperbolic_triangulation_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} ) +target_link_libraries( Hyperbolic_translations_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} ) + -endif() diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Hyperbolic_Dirichlet_region_2_demo.cpp b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Hyperbolic_Dirichlet_region_2_demo.cpp index 58f7e47c253..adcdf4dbfe5 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Hyperbolic_Dirichlet_region_2_demo.cpp +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Hyperbolic_Dirichlet_region_2_demo.cpp @@ -54,6 +54,7 @@ #include "ui_Delaunay_triangulation_2.h" #include + typedef CGAL::Exact_predicates_inexact_constructions_kernel InR; typedef CGAL::Exact_predicates_exact_constructions_kernel R; typedef CGAL::Triangulation_hyperbolic_traits_2 K; @@ -804,7 +805,7 @@ MainWindow::on_actionRecenter_triggered() } -#include "Hyperbolic_Delaunay_triangulation_2_demo.moc" +#include "Hyperbolic_Dirichlet_region_2_demo.moc" int main(int argc, char **argv) { diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp index 5854bacd085..e1bedb7d92a 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.cpp @@ -404,7 +404,7 @@ MainWindow::on_actionRecenter_triggered() } -#include "Hyperbolic_Delaunay_triangulation_2_demo.moc" +#include "Periodic_2_Delaunay_hyperbolic_triangulation_2_demo.moc" int main(int argc, char **argv) {