From f45c16f815ba01c7be73c6acd930308ae945c779 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 25 Jul 2019 15:34:03 +0200 Subject: [PATCH 1/4] Add a new custom target ALL_CGAL_TARGETS to track all targets That will include also targets with `EXCLUDE_FROM_ALL`. --- Installation/CMakeLists.txt | 7 ++++++- Installation/cmake/modules/CGAL_add_test.cmake | 4 ++++ Installation/src/CMakeLists.txt | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 7084d430d83..2ab41173d4f 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -959,12 +959,17 @@ endif() # #-------------------------------------------------------------------------------------------------- +if(NOT TARGET ALL_CGAL_TARGETS) + add_custom_target( ALL_CGAL_TARGETS ) +endif() + macro( add_programs subdir target ON_OFF ) cache_set( CGAL_EXECUTABLE_TARGETS "" ) add_custom_target( ${target} ) - + add_dependencies( ALL_CGAL_TARGETS ${target} ) + option( WITH_${target} "Select ${target}" ${ON_OFF} ) if ( WITH_${target} ) add_subdirectory( ${subdir} EXCLUDE_FROM_ALL ) diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index c25390304d7..057a603a050 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -98,8 +98,12 @@ function(cgal_add_compilation_test exe_name) COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${exe_name}") set_property(TEST "compilation_of__${exe_name}" APPEND PROPERTY LABELS "${PROJECT_NAME}") + if(NOT TARGET ALL_CGAL_TARGETS) + add_custom_target( ALL_CGAL_TARGETS ) + endif() if(NOT TARGET cgal_check_build_system) add_custom_target(cgal_check_build_system) + add_dependencies( ALL_CGAL_TARGETS cgal_check_build_system ) endif() if(NOT TEST check_build_system) add_test(NAME "check_build_system" diff --git a/Installation/src/CMakeLists.txt b/Installation/src/CMakeLists.txt index 09db484fd6e..7ed919fab92 100644 --- a/Installation/src/CMakeLists.txt +++ b/Installation/src/CMakeLists.txt @@ -72,7 +72,10 @@ function (collect_cgal_library LIBRARY_NAME ADDITIONAL_FILES) # CMakeLists.txt can be the target like if it was an imported # target. add_library(CGAL::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) - + if(NOT TARGET ALL_CGAL_TARGETS) + add_custom_target( ALL_CGAL_TARGETS ) + endif() + add_dependencies( ALL_CGAL_TARGETS ${LIBRARY_NAME} ) if(CGAL_AUTO_LINK_ENABLED) if (NOT CGAL_HEADER_ONLY) set_target_properties( ${LIBRARY_NAME} PROPERTIES From b8c7cb21bdae70c591323b25830b5106c15b2e80 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 25 Jul 2019 15:35:14 +0200 Subject: [PATCH 2/4] Add a hook to track targets without dependent --- ...GAL_enable_end_of_configuration_hook.cmake | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake index 6f8e423af1d..e0f001f0d4b 100644 --- a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake +++ b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake @@ -9,7 +9,7 @@ get_property(PROPERTY_CGAL_run_at_the_end_of_configuration_INCLUDED GLOBAL PROPERTY CGAL_run_at_the_end_of_configuration_INCLUDED) -if(PROPERTY_CGAL_run_at_the_end_of_configuration_INCLUDED) +if(CGAL_SKIP_CMAKE_HOOKS OR PROPERTY_CGAL_run_at_the_end_of_configuration_INCLUDED) return() endif() @@ -17,11 +17,38 @@ function(CGAL_run_at_the_end_of_configuration variable access value current_list if(NOT access STREQUAL "MODIFIED_ACCESS") return() endif() - if(CGAL_CHECK_UNUSED_CPP_FILES - AND NOT current_list_file STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" - AND stack STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt") + if(current_list_file STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OR NOT stack STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OR stack MATCHES doc/CMakeLists.txt + OR stack MATCHES demo/Polyhedron/) + return() + endif() + get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) + if(CGAL_CHECK_UNREFERENCES_TARGETS) + set(_list_of_deps) + set(_special_targets demos examples tests ALL_CGAL_TARGETS CGAL_Qt5_moc_and_resources uninstall install_FindCGAL) + foreach(t ${_special_targets}) + if(NOT TARGET ${t}) + continue() + endif() + get_property(_deps TARGET ${t} PROPERTY MANUALLY_ADDED_DEPENDENCIES) +# message(" deps of ${t}: ${_deps}") + list(APPEND _list_of_deps ${_deps}) + endforeach() + list(APPEND _list_of_deps ${CGAL_EXECUTABLE_TARGETS}) +# message(STATUS " all deps: ${_list_of_deps}") + foreach(target ${_targets}) +# message(STATUS " new target: ${target}") + if(${target} IN_LIST _special_targets) + continue() + endif() + if(NOT ${target} IN_LIST _list_of_deps) + message(AUTHOR_WARNING " orphan target: ${target}") + endif() + endforeach() + endif() + if(CGAL_CHECK_UNUSED_CPP_FILES) file(GLOB _cppfiles ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) if(_targets AND _cppfiles) set(_sources) foreach(_target ${_targets}) From 94d654b9ab2f0f0653077abdbaf82b691250ebde Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 25 Jul 2019 15:36:38 +0200 Subject: [PATCH 3/4] Fill CGAL_EXECUTABLE_TARGETS wherever that was missing --- .../test/Arrangement_on_surface_2/cgal_test.cmake | 1 + .../demo/Hyperbolic_triangulation_2/CMakeLists.txt | 1 + Installation/test/Installation/CMakeLists.txt | 4 +++- Mesh_3/examples/Mesh_3/CMakeLists.txt | 1 + .../demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt | 1 + Polyhedron/demo/Polyhedron/CMakeLists.txt | 1 + 6 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake index 4753352d565..4b5a6bbc779 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake @@ -152,6 +152,7 @@ function(cgal_arr_2_add_target exe_name source_file) set(name ${exe_name}_${suffix}) endif() add_executable(${name} ${source_file}) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${name} ) separate_arguments(flags UNIX_COMMAND "${TESTSUITE_CXXFLAGS}") target_compile_options(${name} PRIVATE ${flags}) cgal_debug_message(STATUS "# -> target ${name} with TESTSUITE_CXXFLAGS: ${flags}") diff --git a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt index 21160f9701d..1e2e306c294 100644 --- a/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/demo/Hyperbolic_triangulation_2/CMakeLists.txt @@ -27,6 +27,7 @@ if(CGAL_FOUND AND CGAL_Qt5_FOUND AND Qt5_FOUND AND CGAL_Core_FOUND) # cpp files add_executable ( HDT2 HDT2.cpp ${CGAL_Qt5_RESOURCE_FILES} ${RESOURCE_FILES} ${UIS}) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS HDT2 ) target_link_libraries ( HDT2 CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_Core Qt5::Widgets) else() message(STATUS "NOTICE: This demo requires CGAL, CGAL_Core, and Qt5 and will not be compiled.") diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index c5d6f6c02db..5058a0ce440 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -23,7 +23,9 @@ macro(create_link_to_program COMPONENT ) else() target_link_libraries(link_to_${COMPONENT} CGAL::${COMPONENT} ${CGAL_3RD_PARTY_LIBRARIES} ${${COMPONENT}_3RD_PARTY_LIBRARIES} ) endif() - + + add_to_cached_list( CGAL_EXECUTABLE_TARGETS link_to_${COMPONENT} ) + endmacro() find_package(CGAL QUIET COMPONENTS Core) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index ecb2e646bc1..e977911acaf 100644 --- a/Mesh_3/examples/Mesh_3/CMakeLists.txt +++ b/Mesh_3/examples/Mesh_3/CMakeLists.txt @@ -94,6 +94,7 @@ if ( CGAL_FOUND ) add_executable ( mesh_3D_gray_vtk_image mesh_3D_gray_vtk_image.cpp ) target_link_libraries( mesh_3D_gray_vtk_image ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${VTK_LIBRARIES}) cgal_add_test( mesh_3D_gray_vtk_image ) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS mesh_3D_gray_vtk_image ) endif() create_single_source_cgal_program( "mesh_3D_gray_image.cpp" ) diff --git a/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt b/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt index e0eb6720e8b..2958d748955 100644 --- a/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt +++ b/Periodic_4_hyperbolic_triangulation_2/demo/Periodic_4_hyperbolic_triangulation_2/CMakeLists.txt @@ -47,6 +47,7 @@ if(CGAL_FOUND AND CGAL_Core_FOUND AND Qt5_FOUND AND CGAL_Qt5_FOUND) target_link_libraries( P4HDT2 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${Boost_LIBRARIES} ) #target_link_libraries( Periodic_4_hyperbolic_billiards_demo ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} ${Boost_LIBRARIES} ) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS P4HDT2 ) else() message(STATUS "NOTICE: This demo requires Qt5 and will not be compiled.") endif() diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index c471d3c9653..53b1bc8933b 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -232,6 +232,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND ) PUBLIC demo_framework ${CGAL_LIBRARIES} Qt5::OpenGL Qt5::Gui Qt5::Script Qt5::Widgets) cgal_add_compilation_test(${item_name}) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${item_name} ) endmacro(add_item) add_item(scene_c3t3_item Scene_c3t3_item.cpp) From 1ec8dc9db8e909dae44a0d8d844473d37fe99277 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 26 Jul 2019 11:43:50 +0200 Subject: [PATCH 4/4] Remaining unregistered target --- Installation/test/Installation/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 5058a0ce440..4d0f56bdd37 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -87,6 +87,7 @@ if ( CGAL_FOUND ) add_executable(test_gmp_mpfr_dll test_gmp_mpfr_dll.cpp) target_link_libraries(test_gmp_mpfr_dll version) CGAL_add_test(test_gmp_mpfr_dll) + add_to_cached_list( CGAL_EXECUTABLE_TARGETS test_gmp_mpfr_dll ) endif() find_package( LEDA QUIET)