From 471e7a93be69fb44cf12858811ed811a4d38c03f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 16 Mar 2018 11:41:56 +0100 Subject: [PATCH] Deal with Qt5 and Boost imported targets, when CGAL is imported When CGAL_Qt5 or CGAL_Core targets are imported, then we need to call `find_package(Qt5)` and `find_package(Boost)` to re-import the targets of Qt5 or `Boost::thread`. Otherwise, there is that CMake warning: CMake Warning (dev) at /mnt/testsuite/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake:49 (add_executable): Policy CMP0028 is not set: Double colon in target name means ALIAS or IMPORTED target. Run "cmake --help-policy CMP0028" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Target "test_Min_circle" links to target "Boost::thread" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? Call Stack (most recent call first): CMakeLists.txt:22 (create_single_source_cgal_program) This warning is for project developers. Use -Wno-dev to suppress it. and then that link error: /usr/bin/ld: cannot find -lBoost::thread Ref: https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-4.12-Ic-200/Bounding_volumes/TestReport_lrineau_Fedora-Release.gz --- Installation/cmake/modules/CGAL_Macros.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Installation/cmake/modules/CGAL_Macros.cmake b/Installation/cmake/modules/CGAL_Macros.cmake index 1bcc7ca201c..23049fbb26e 100644 --- a/Installation/cmake/modules/CGAL_Macros.cmake +++ b/Installation/cmake/modules/CGAL_Macros.cmake @@ -287,6 +287,21 @@ if( NOT CGAL_MACROS_FILE_INCLUDED ) add_to_list( CGAL_3RD_PARTY_DEFINITIONS ${CGAL_${component}_3RD_PARTY_DEFINITIONS} ) add_to_list( CGAL_3RD_PARTY_LIBRARIES_DIRS ${CGAL_${component}_3RD_PARTY_LIBRARIES_DIRS} ) + # To deal with imported targets of Qt5 and Boost, when CGAL + # targets are themselves imported by another project. + if(NOT CGAL_BUILDING_LIBS) + if (NOT MSVC AND "${component}" STREQUAL "Core") + # See the release notes of CGAL-4.10: CGAL_Core now requires + # Boost.Thread, with all compilers but MSVC. + find_package( Boost 1.48 REQUIRED thread system ) + add_to_list( CGAL_3RD_PARTY_LIBRARIES ${Boost_LIBRARIES} ) + endif() + + if (${component} STREQUAL "Qt5") + find_package(Qt5 COMPONENTS OpenGL Gui Core Script ScriptTools QUIET) + endif() + endif() + else(WITH_CGAL_${component}) # now we are talking about 3rd party libs