From 374e1778e5724bbfa2877298e27cccc09eaa3569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 24 Jun 2020 17:39:29 +0200 Subject: [PATCH] Fix CGAL_USE_VTK/OpenMesh being defined for all programs but not all programs are linked! --- BGL/examples/BGL_polyhedron_3/CMakeLists.txt | 2 +- BGL/test/BGL/CMakeLists.txt | 41 ++++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt index 01378916001..f8e280b8aae 100644 --- a/BGL/examples/BGL_polyhedron_3/CMakeLists.txt +++ b/BGL/examples/BGL_polyhedron_3/CMakeLists.txt @@ -31,7 +31,6 @@ find_package( OpenMesh QUIET ) if ( OpenMesh_FOUND ) include( UseOpenMesh ) - add_definitions( -DCGAL_USE_OPENMESH ) else() message(STATUS "Examples that use OpenMesh will not be compiled.") endif() @@ -69,6 +68,7 @@ create_single_source_cgal_program( "copy_polyhedron.cpp" ) if(OpenMesh_FOUND) target_link_libraries( copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES} ) + target_compile_definitions( copy_polyhedron PRIVATE -DCGAL_USE_OPENMESH ) endif() if( METIS_FOUND ) diff --git a/BGL/test/BGL/CMakeLists.txt b/BGL/test/BGL/CMakeLists.txt index cdfa4773c72..b213ccb8ae4 100644 --- a/BGL/test/BGL/CMakeLists.txt +++ b/BGL/test/BGL/CMakeLists.txt @@ -4,39 +4,27 @@ cmake_minimum_required(VERSION 3.1...3.15) project( BGL_Tests ) - - - - # CGAL and its components find_package( CGAL QUIET COMPONENTS ) -find_package(VTK QUIET COMPONENTS - vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources) if ( NOT CGAL_FOUND ) - message(STATUS "This project requires the CGAL library, and will not be compiled.") return() - endif() # Boost and its components find_package( Boost ) - if ( NOT Boost_FOUND ) message(STATUS "This project requires the Boost library, and will not be compiled.") return() endif() find_package( OpenMesh QUIET ) - if ( OpenMesh_FOUND ) include( UseOpenMesh ) - add_definitions( -DCGAL_USE_OPENMESH ) else() message(STATUS "Tests that use OpenMesh will not be compiled.") endif() - # include for local package # Creating entries for all .cpp/.C files with "main" routine @@ -102,25 +90,36 @@ create_single_source_cgal_program( "test_Properties.cpp" ) create_single_source_cgal_program( "bench_read_from_stream_vs_add_face_and_add_faces.cpp" ) if(OpenMesh_FOUND) - target_link_libraries( test_clear PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_graph_traits PRIVATE ${OPENMESH_LIBRARIES} ) - target_link_libraries( test_Properties PRIVATE ${OPENMESH_LIBRARIES}) - target_link_libraries( test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES}) + target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_Euler_operations PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_Collapse_edge PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_Face_filtered_graph PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_graph_traits PRIVATE ${OPENMESH_LIBRARIES} ) + target_compile_definitions(test_graph_traits PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_Properties PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_Properties PRIVATE -DCGAL_USE_OPENMESH) + target_link_libraries(test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES}) + target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_OPENMESH) endif() + +find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources) if (VTK_FOUND) if(VTK_USE_FILE) include(${VTK_USE_FILE}) endif() + if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) if(TARGET VTK::CommonCore) set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources) endif() + if(VTK_LIBRARIES) - add_definitions(-DCGAL_USE_VTK) - target_link_libraries( test_bgl_read_write PRIVATE ${VTK_LIBRARIES}) + target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES}) + target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK) else() message(STATUS "Tests that use VTK will not be compiled.") endif()