Skip to content

Commit

Permalink
refactor: expose setup_vtk_env, use generator expressions, fix fold…
Browse files Browse the repository at this point in the history
…er name casing
  • Loading branch information
Curve committed Mar 10, 2024
1 parent c3a6bb4 commit 7541b8a
Show file tree
Hide file tree
Showing 111 changed files with 20 additions and 29 deletions.
19 changes: 9 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ endif()
# --------------------------------------------------------------------------------------------------------

target_include_directories(
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/viennals>
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/viennals>
$<INSTALL_INTERFACE:include/viennals-${PROJECT_VERSION}>)

# --------------------------------------------------------------------------------------------------------
# Setup Dependencies
# --------------------------------------------------------------------------------------------------------

include("cmake/cpm.cmake")
include("cmake/vtk.cmake")

CPMAddPackage(
NAME PackageProject
Expand All @@ -101,6 +102,10 @@ target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX ViennaHRLE)

if(VIENNALS_USE_VTK)
enable_language(C)

find_package(VTK QUIET)
set(VIENNALS_SYSTEM_VTK ${VTK_FOUND})

CPMFindPackage(
NAME VTK
# TODO: Change to 9.3.1 as soon as it's released
Expand Down Expand Up @@ -151,12 +156,6 @@ if(VIENNALS_USE_VTK)
VTK::FiltersCore
VTK::FiltersGeneral
VTK::FiltersGeometry)

if(MSVC)
set(VTK_LIBS "${VTK_BINARY_DIR}/bin/$<CONFIG>")
else()
set(VTK_LIBS "${VTK_BINARY_DIR}/lib")
endif()
endif()

# --------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -184,7 +183,7 @@ endif()

if(VIENNALS_BUILD_EXAMPLES)
message(STATUS "[ViennaLS] Building Examples")
add_subdirectory(Examples)
add_subdirectory(examples)
endif()

# --------------------------------------------------------------------------------------------------------
Expand All @@ -195,7 +194,7 @@ if(VIENNALS_BUILD_TESTS)
message(STATUS "[ViennaLS] Building Tests")

enable_testing()
add_subdirectory(Tests)
add_subdirectory(tests)
endif()

# --------------------------------------------------------------------------------------------------------
Expand All @@ -204,7 +203,7 @@ endif()

if(VIENNALS_BUILD_PYTHON)
message(STATUS "[ViennaLS] Building Python Bindings")
add_subdirectory(Python)
add_subdirectory(python)
endif()

# --------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 2 additions & 8 deletions cmake/vtk.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
macro(setup_vtk_env TARGET OUTPUT)
if(NOT WIN32)
message(
STATUS "[ViennaLS] Skipping VTK-Environment setup for ${TARGET} (Only required on Windows)")
else()
message(STATUS "[ViennaLS] Setting up VTK for ${TARGET}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/${OUTPUT}>)
message(STATUS "[ViennaLS] Setting up VTK-Environment for ${TARGET}")

add_custom_command(
TARGET ${TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${VTK_LIBS} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
COMMAND ${CMAKE_COMMAND} -E copy_directory $<TARGET_FILE_DIR:VTK> ${OUTPUT})
endmacro()
File renamed without changes.
6 changes: 3 additions & 3 deletions Examples/CMakeLists.txt → examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_custom_target(ViennaLS_Examples ALL)

if(NOT VTK_DIR)
include("../cmake/vtk.cmake")
setup_vtk_env(ViennaLS_Examples "examples")
if(WIN32 AND NOT VIENNALS_SYSTEM_VTK)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/examples>)
setup_vtk_env(ViennaLS_Examples ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

file(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions Python/CMakeLists.txt → python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ endif()

include("../cmake/vtk.cmake")

if(WIN32 AND NOT VTK_DIR)
setup_vtk_env(${PROJECT_NAME} vtk_env)
set(VTK_DIR "${PROJECT_BINARY_DIR}/vtk_env")
elseif(NOT VTK_DIR)
set(VTK_DIR "${VTK_LIBS}")
if(WIN32 AND NOT VIENNALS_SYSTEM_VTK)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/vtk_env>)
setup_vtk_env(ViennaLS_Examples ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

# --------------------------------------------------------------------------------------------------------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions Tests/CMakeLists.txt → tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_custom_target(ViennaLS_Tests ALL)

if(NOT VTK_DIR)
include("../cmake/vtk.cmake")
setup_vtk_env(ViennaLS_Tests "tests")
if(WIN32 AND NOT VIENNALS_SYSTEM_VTK)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${PROJECT_BINARY_DIR}/tests>)
setup_vtk_env(ViennaLS_Tests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

file(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7541b8a

Please sign in to comment.