Skip to content

Commit

Permalink
refactor: force remote vtk for packaging
Browse files Browse the repository at this point in the history
* When building the wheel package we should force usage for the remote VTK to ensure a valid linking configuration.

* Wheel builds should be built with `SKBUILD_CONFIGURE_OPTIONS="-DVIENNALS_PACKAGE_PYTHON"`
  • Loading branch information
Curve committed Apr 18, 2024
1 parent 72fd60a commit 706896a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaLS
LANGUAGES CXX
VERSION 3.1.1)
VERSION 3.2.0)

# --------------------------------------------------------------------------------------------------------
# Library options
Expand All @@ -16,9 +16,8 @@ option(VIENNALS_STATIC_BUILD "Build dependencies as static libraries" OFF)
option(VIENNALS_ENABLE_SANITIZER "Enable Sanitizer for debug buidlds" OFF)
option(VIENNALS_USE_SANITIZER "Enable Sanitizer (Requires GCC or Clang)" OFF)

option(VIENNALS_PACKAGE_PYTHON "Build python bindings with intent to publish wheel" OFF)
option(VIENNALS_BUILD_PYTHON "Build python bindings" OFF)
option(VIENNALS_PYTHON_FORCE_VTK
"Include VTK in python bindings installation even if present as system dependency" OFF)

option(VIENNALS_BUILD_EXAMPLES "Build examples" OFF)
option(VIENNALS_BUILD_TESTS "Build tests" OFF)
Expand All @@ -28,6 +27,13 @@ option(VIENNALS_BUILD_TESTS "Build tests" OFF)
# └ See: https://github.com/ViennaTools/ViennaPS/blob/c76e371817a797dfe2800691f00cb93317b731fa/CMakeLists.txt#L30
# --------------------------------------------------------------------------------------------------------

if(VIENNALS_PACKAGE_PYTHON)
message(STATUS "[ViennaLS] Using remote VTK due to 'VIENNALS_PACKAGE_PYTHON', the build will take a long time!")

set(CPM_DOWNLOAD_ALL ON)
set(VIENNALS_BUILD_PYTHON ON)
endif()

if(VIENNALS_BUILD_PYTHON)
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)
endif()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Issues = "https://github.com/ViennaTools/ViennaLS/issues"

[tool.scikit-build]
build-dir = "build"
cmake.args = ["-DVIENNALS_BUILD_PYTHON=ON", "-DVIENNALS_PYTHON_FORCE_VTK=ON"]
cmake.args = ["-DVIENNALS_BUILD_PYTHON=ON"]
8 changes: 3 additions & 5 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ add_custom_target(${PROJECT_NAME} ALL)
# --------------------------------------------------------------------------------------------------------

set(CMAKE_MACOSX_RPATH ON)

set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)

if(NOT APPLE)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../viennals.libs")
list(APPEND CMAKE_BUILD_RPATH "$ORIGIN")
list(APPEND CMAKE_BUILD_RPATH "$ORIGIN/../viennals.libs")
else()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../viennals.libs")
list(APPEND CMAKE_BUILD_RPATH "@loader_path")
list(APPEND CMAKE_BUILD_RPATH "@loader_path/../viennals.libs")
endif()

# --------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -77,7 +75,7 @@ setup_binding(viennals3d -DVIENNALS_PYTHON_DIMENSION=3)

set(VIENNALS_LIB_FOLDER "${VIENNALS_LIBRARY_OUTPUT_DIR}/viennals.libs")

if(NOT VIENNALS_SYSTEM_VTK OR VIENNALS_PYTHON_FORCE_VTK)
if(NOT VIENNALS_SYSTEM_VTK OR VIENNALS_PACKAGE_PYTHON)
setup_vtk_env(${MODULE_NAME} "${VIENNALS_LIB_FOLDER}")
install(DIRECTORY "${VIENNALS_LIB_FOLDER}" DESTINATION .)
endif()

0 comments on commit 706896a

Please sign in to comment.