From 8aca88fed70b921af9fa8f453dfb59a106f4ecc9 Mon Sep 17 00:00:00 2001 From: Curve Date: Sun, 9 Jun 2024 20:09:37 +0200 Subject: [PATCH] refactor(cmake): check for vtk existance --- CMakeLists.txt | 15 --------------- cmake/vtk.cmake | 5 +++++ examples/CMakeLists.txt | 2 +- python/CMakeLists.txt | 8 +++----- tests/CMakeLists.txt | 2 +- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a20c7dd..c0633056 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,11 +128,6 @@ if(VIENNALS_USE_VTK AND VIENNALS_VTK_PYTHON_LIBS) elseif(VIENNALS_USE_VTK) enable_language(C) - find_package(VTK QUIET) - set(VIENNALS_SYSTEM_VTK - ${VTK_FOUND} - CACHE INTERNAL "") - CPMFindPackage( NAME VTK # TODO: Change to 9.3.1 as soon as it's released @@ -194,16 +189,6 @@ if(VIENNALS_ENABLE_SANITIZER) viennacore_enable_sanitizer() endif() -# -------------------------------------------------------------------------------------------------------- -# Check need for environment setups -# -------------------------------------------------------------------------------------------------------- - -if(NOT VIENNALS_VTK_PYTHON_LIBS AND (NOT VIENNALS_SYSTEM_VTK OR VIENNALS_PACKAGE_PYTHON)) - set(VIENNALS_VTK_ENV - ON - CACHE INTERNAL "") -endif() - # -------------------------------------------------------------------------------------------------------- # Setup Shared/Static Library # -------------------------------------------------------------------------------------------------------- diff --git a/cmake/vtk.cmake b/cmake/vtk.cmake index 07ce095b..34cd2f85 100644 --- a/cmake/vtk.cmake +++ b/cmake/vtk.cmake @@ -1,6 +1,11 @@ macro(setup_vtk_env TARGET OUTPUT) message(STATUS "[ViennaLS] Setting up VTK-Environment for ${TARGET}") + if (NOT TARGET vtksys) + message(WARNING "[ViennaLS] Could not find VTK-Target") + return() + endif() + # We expect all of the VTK binaries to be present in the same directory to which "vtksys" is # built. This is currently the case, and has been the case for prior vtk versions - However we # should keep an eye on this. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 06e15523..06934e7f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,6 @@ add_custom_target(ViennaLS_Examples ALL) -if(WIN32 AND VIENNALS_VTK_ENV) +if(WIN32) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/examples>) setup_vtk_env(ViennaLS_Examples ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 60638200..013ff596 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -69,9 +69,7 @@ target_compile_definitions(viennals3d PRIVATE -DVIENNALS_PYTHON_DIMENSION=3 set(VIENNALS_LIB_FOLDER ${VIENNALS_LIBRARY_OUTPUT_DIR}/viennals.libs) -if(NOT VIENNALS_VTK_ENV) - return() -endif() +# Not required for both targets, one will suffice +setup_vtk_env(viennals2d ${VIENNALS_LIB_FOLDER}) -setup_vtk_env(viennals2d ${VIENNALS_LIB_FOLDER}) # Not required for both targets, one will suffice -install(DIRECTORY ${VIENNALS_LIB_FOLDER} DESTINATION .) +install(DIRECTORY ${VIENNALS_LIB_FOLDER} DESTINATION . OPTIONAL) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 26b1cbf2..90239287 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ add_custom_target(ViennaLS_Tests ALL) -if(WIN32 AND VIENNALS_VTK_ENV) +if(WIN32) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/tests>) setup_vtk_env(ViennaLS_Tests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif()