Skip to content

Commit

Permalink
refactor(cmake): check for vtk existance
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Jun 9, 2024
1 parent 9b14eb4 commit 8aca88f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
# --------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions cmake/vtk.cmake
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
8 changes: 3 additions & 5 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 8aca88f

Please sign in to comment.