Skip to content

Commit

Permalink
Add support for finding VTKCompileTools and passing cross-compilation…
Browse files Browse the repository at this point in the history
… variables (#7)

Pass the variable VTKCompileTools_DIR only to the main project (the VTK module itself)

Pass the following variables to the main project and also all external projects
added to the VTK module SuperBuild directory:
- CMAKE_CROSSCOMPILING
- CMAKE_CROSSCOMPILING_EMULATOR
- CMAKE_SYSTEM_NAME
  • Loading branch information
jcfr authored Aug 31, 2023
1 parent b03e854 commit 37ade3c
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ if(DEFINED Python3_EXECUTABLE)
mark_as_superbuild(Python3_EXECUTABLE:FILEPATH)
endif()

option(BUILD_PYTHON_WRAPPERS "Build python wrappers" ON)
option(VTK_WHEEL_BUILD "Build wheel version of libraries." OFF)
option(BUILD_JAVA_WRAPPERS "Build java wrappers" OFF)

# Adapted from "VTK/CMake/vtkCrossCompiling.cmake"
if(CMAKE_CROSSCOMPILING
AND NOT VTKCompileTools_FOUND
AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR
AND (BUILD_JAVA_WRAPPERS OR BUILD_PYTHON_WRAPPERS))
# if CMAKE_CROSSCOMPILING is true and crosscompiling emulator is not available, we need
# to import build-tools targets.
find_package(VTKCompileTools REQUIRED)
endif()

find_package(VTK REQUIRED)
if(DEFINED VTK_DIR)
mark_as_superbuild(VTK_DIR:PATH)
Expand All @@ -91,10 +105,7 @@ if (VTK_MODULE_CMAKE_MODULE_PATH)
endif ()

# Wrap Python option
if (VTK_WRAP_PYTHON)
option(BUILD_PYTHON_WRAPPERS "Build python wrappers" ON)
option(VTK_WHEEL_BUILD "Build wheel version of libraries." OFF)
else ()
if (NOT VTK_WRAP_PYTHON)
unset(BUILD_PYTHON_WRAPPERS CACHE)
unset(VTK_WHEEL_BUILD CACHE)
endif ()
Expand All @@ -105,9 +116,7 @@ mark_as_superbuild(
)

# Wrap Java option
if (VTK_WRAP_JAVA)
option(BUILD_JAVA_WRAPPERS "Build java wrappers" OFF)
else ()
if (NOT VTK_WRAP_JAVA)
unset(BUILD_JAVA_WRAPPERS CACHE)
endif ()
mark_as_superbuild(BUILD_JAVA_WRAPPERS:BOOL)
Expand Down Expand Up @@ -217,12 +226,23 @@ if(VTK_MODULE_SUPERBUILD)
CMAKE_CXX_STANDARD_REQUIRED
CMAKE_CXX_EXTENSIONS
SKBUILD
VTKCompileTools_DIR
)
if(DEFINED ${varname})
mark_as_superbuild(${varname})
endif()
endforeach()

foreach(varname IN ITEMS
CMAKE_CROSSCOMPILING
CMAKE_CROSSCOMPILING_EMULATOR
CMAKE_SYSTEM_NAME
)
if(DEFINED ${varname})
mark_as_superbuild(VARS ${varname} ALL_PROJECTS)
endif()
endforeach()

if(DEFINED VTK_MODULE_EXTERNAL_PROJECT_CMAKE_CACHE_ARGS)
foreach(varname IN LISTS VTK_MODULE_EXTERNAL_PROJECT_CMAKE_CACHE_ARGS)
if(DEFINED ${varname})
Expand Down

0 comments on commit 37ade3c

Please sign in to comment.