From 35914e183b848f431dabaff24cef6ee23021e546 Mon Sep 17 00:00:00 2001 From: David Gobbi <david.gobbi@gmail.com> Date: Thu, 31 Oct 2024 06:48:54 -0600 Subject: [PATCH] Fix java build failure for 'make' Recent changes to fix the dependencies of vtkjava_tests for Ninja have caused problems with dependencies for Unix Makefiles. This change makes those previous fixes specific to Ninja, in order to get the build working properly with Unix Makefiles again. --- Wrapping/Java/CMakeLists.txt | 9 +++++---- Wrapping/Java/Testing/Java/CMakeLists.txt | 16 +++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Wrapping/Java/CMakeLists.txt b/Wrapping/Java/CMakeLists.txt index 62b39ce3326..2d923d9ad9d 100644 --- a/Wrapping/Java/CMakeLists.txt +++ b/Wrapping/Java/CMakeLists.txt @@ -275,10 +275,11 @@ install( DESTINATION "${vtk_cmake_destination}" COMPONENT "development") -# We need this for targets that depends in vtkjava to -# delay its source code compilation until the vtkjava JAR file is -# generated. -add_custom_target(vtkjava_jar DEPENDS "$<TARGET_FILE:vtkjava>") +if (CMAKE_GENERATOR MATCHES "Ninja") + # We need this for targets that depends in vtkjava to delay its + # source code compilation until the vtkjava JAR file is generated. + add_custom_target(vtkjava_jar DEPENDS "$<TARGET_FILE:vtkjava>") +endif () if (VTK_BUILD_TESTING AND TARGET VTK::TestingRendering) add_subdirectory(Testing) diff --git a/Wrapping/Java/Testing/Java/CMakeLists.txt b/Wrapping/Java/Testing/Java/CMakeLists.txt index 835935e84e6..83bfad06888 100644 --- a/Wrapping/Java/Testing/Java/CMakeLists.txt +++ b/Wrapping/Java/Testing/Java/CMakeLists.txt @@ -34,11 +34,17 @@ target_compile_options(vtkjava_tests target_link_libraries(vtkjava_tests PRIVATE VTK::vtkjava) -# Apparently the Java compilation doesn't set up dependencies properly, -# Thus we need to depend on vtkjava_jar which symbolized that the vtkjava -# jar file has been created. This is needed since compiling every java file -# requires to have the jars in the classpath of its dependencies. -add_dependencies(vtkjava_tests vtkjava_jar WrapJava) +if (TARGET vtkjava_jar) + # Apparently the Java compilation doesn't set up dependencies properly, + # Thus we need to depend on vtkjava_jar which symbolized that the vtkjava + # jar file has been created. This is needed since compiling every java file + # requires to have the jars in the classpath of its dependencies. + add_dependencies(vtkjava_tests vtkjava_jar WrapJava) +else () + # If 'vtkjava_jar' doesn't exist, we assume that dependencies are properly + # handled via the 'vtkjava' target for the vtk.jar file + add_dependencies(vtkjava_tests vtkjava) +endif () set(vtk_test_classpath "$<TARGET_FILE:vtkjava_tests>" -- GitLab