Fix CGAL_USE_VTK/OpenMesh being defined for all programs

but not all programs are linked!
This commit is contained in:
Mael Rouxel-Labbé 2020-06-24 17:39:29 +02:00
parent 093af2caec
commit 374e1778e5
2 changed files with 21 additions and 22 deletions

View File

@ -31,7 +31,6 @@ find_package( OpenMesh QUIET )
if ( OpenMesh_FOUND ) if ( OpenMesh_FOUND )
include( UseOpenMesh ) include( UseOpenMesh )
add_definitions( -DCGAL_USE_OPENMESH )
else() else()
message(STATUS "Examples that use OpenMesh will not be compiled.") message(STATUS "Examples that use OpenMesh will not be compiled.")
endif() endif()
@ -69,6 +68,7 @@ create_single_source_cgal_program( "copy_polyhedron.cpp" )
if(OpenMesh_FOUND) if(OpenMesh_FOUND)
target_link_libraries( copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES} ) target_link_libraries( copy_polyhedron PRIVATE ${OPENMESH_LIBRARIES} )
target_compile_definitions( copy_polyhedron PRIVATE -DCGAL_USE_OPENMESH )
endif() endif()
if( METIS_FOUND ) if( METIS_FOUND )

View File

@ -4,39 +4,27 @@
cmake_minimum_required(VERSION 3.1...3.15) cmake_minimum_required(VERSION 3.1...3.15)
project( BGL_Tests ) project( BGL_Tests )
# CGAL and its components # CGAL and its components
find_package( CGAL QUIET COMPONENTS ) find_package( CGAL QUIET COMPONENTS )
find_package(VTK QUIET COMPONENTS
vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources)
if ( NOT CGAL_FOUND ) if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.") message(STATUS "This project requires the CGAL library, and will not be compiled.")
return() return()
endif() endif()
# Boost and its components # Boost and its components
find_package( Boost ) find_package( Boost )
if ( NOT Boost_FOUND ) if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.") message(STATUS "This project requires the Boost library, and will not be compiled.")
return() return()
endif() endif()
find_package( OpenMesh QUIET ) find_package( OpenMesh QUIET )
if ( OpenMesh_FOUND ) if ( OpenMesh_FOUND )
include( UseOpenMesh ) include( UseOpenMesh )
add_definitions( -DCGAL_USE_OPENMESH )
else() else()
message(STATUS "Tests that use OpenMesh will not be compiled.") message(STATUS "Tests that use OpenMesh will not be compiled.")
endif() endif()
# include for local package # include for local package
# Creating entries for all .cpp/.C files with "main" routine # 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" ) create_single_source_cgal_program( "bench_read_from_stream_vs_add_face_and_add_faces.cpp" )
if(OpenMesh_FOUND) if(OpenMesh_FOUND)
target_link_libraries( test_clear PRIVATE ${OPENMESH_LIBRARIES}) target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES})
target_link_libraries( test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES}) target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH)
target_link_libraries( test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES}) target_link_libraries(test_Euler_operations PRIVATE ${OPENMESH_LIBRARIES})
target_link_libraries( test_Face_filtered_graph PRIVATE ${OPENMESH_LIBRARIES}) target_compile_definitions(test_Euler_operations PRIVATE -DCGAL_USE_OPENMESH)
target_link_libraries( test_graph_traits PRIVATE ${OPENMESH_LIBRARIES} ) target_link_libraries(test_Collapse_edge PRIVATE ${OPENMESH_LIBRARIES})
target_link_libraries( test_Properties PRIVATE ${OPENMESH_LIBRARIES}) target_compile_definitions(test_Collapse_edge PRIVATE -DCGAL_USE_OPENMESH)
target_link_libraries( test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES}) 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() endif()
find_package(VTK QUIET COMPONENTS vtkCommonCore vtkIOCore vtkIOLegacy vtkIOXML vtkFiltersCore vtkFiltersSources)
if (VTK_FOUND) if (VTK_FOUND)
if(VTK_USE_FILE) if(VTK_USE_FILE)
include(${VTK_USE_FILE}) include(${VTK_USE_FILE})
endif() endif()
if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) if ("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5)
if(TARGET VTK::CommonCore) if(TARGET VTK::CommonCore)
set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources) set(VTK_LIBRARIES VTK::CommonCore VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::FiltersCore VTK::FiltersSources)
endif() endif()
if(VTK_LIBRARIES) 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() else()
message(STATUS "Tests that use VTK will not be compiled.") message(STATUS "Tests that use VTK will not be compiled.")
endif() endif()