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 552b435d9a4..7fd18c6944b 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 @@ -156,6 +156,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/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 8afc7721d61..f16e99d4a1a 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -957,12 +957,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 4e7345aeaea..fe7c45751d1 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/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}) 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 diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 1428689fa6b..bf473a7d7cb 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) @@ -82,6 +84,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) diff --git a/Mesh_3/examples/Mesh_3/CMakeLists.txt b/Mesh_3/examples/Mesh_3/CMakeLists.txt index 028d1217f04..dcaedc3629a 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/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 313305843f9..866dcf9f74f 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -230,6 +230,7 @@ if(CGAL_Qt5_FOUND AND Qt5_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)