From d767f09b47f29b6ed76cb4dbc73093fe79955f93 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com> Date: Tue, 2 May 2017 00:47:28 -0400 Subject: [PATCH] cmake: Add support for CMAKE_CROSSCOMPILING_EMULATOR This commit updates the build systems to allow cross-compiling VTK using toolchain defining CMAKE_CROSSCOMPILING_EMULATOR. It simplifies the cross-compilation removing the need to independently compile the "VTKCompileTools". See https://cmake.org/cmake/help/v3.8/variable/CMAKE_CROSSCOMPILING_EMULATOR.html#variable:CMAKE_CROSSCOMPILING_EMULATOR --- CMake/vtkModuleMacros.cmake | 2 +- CMakeLists.txt | 5 +++-- Utilities/EncodeString/CMakeLists.txt | 2 +- Utilities/HashSource/CMakeLists.txt | 2 +- Utilities/ParseOGLExt/CMakeLists.txt | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMake/vtkModuleMacros.cmake b/CMake/vtkModuleMacros.cmake index 0acb46bb5a..d0006ccb35 100644 --- a/CMake/vtkModuleMacros.cmake +++ b/CMake/vtkModuleMacros.cmake @@ -517,7 +517,7 @@ endfunction() # rules for the target unless NO_INSTALL argument is specified or # VTK_INSTALL_NO_DEVELOPMENT variable is set. function(vtk_compile_tools_target _name) - if (CMAKE_CROSSCOMPILING) + if (CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR) message(AUTHOR_WARNING "vtk_compile_tools_target is being called when CMAKE_CROSSCOMPILING is true. " "This generally signifies a script issue. compile-tools are not expected " diff --git a/CMakeLists.txt b/CMakeLists.txt index a8377f9564..057c554c73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,8 +248,9 @@ if(NOT VTK_BUILD_PYTHON_MODULE_DIR) PATH "Directory where python modules will be put inside the build tree") mark_as_advanced(VTK_BUILD_PYTHON_MODULE_DIR) endif() -if (CMAKE_CROSSCOMPILING AND NOT COMPILE_TOOLS_IMPORTED) - # if CMAKE_CROSSCOMPILING is true, we need to import build-tools targets. +if (CMAKE_CROSSCOMPILING AND NOT COMPILE_TOOLS_IMPORTED AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR) + # if CMAKE_CROSSCOMPILING is true and CMAKE_CROSSCOMPILING_EMULATOR is not set, we need + # to import build-tools targets. find_package(VTKCompileTools REQUIRED) set (COMPILE_TOOLS_IMPORTED TRUE) endif() diff --git a/Utilities/EncodeString/CMakeLists.txt b/Utilities/EncodeString/CMakeLists.txt index d3d841d2d7..baf9d790a4 100644 --- a/Utilities/EncodeString/CMakeLists.txt +++ b/Utilities/EncodeString/CMakeLists.txt @@ -10,7 +10,7 @@ set(VTK_BUILD_FORWARDING_EXECUTABLES FALSE) vtk_module_export_info() -IF(NOT CMAKE_CROSSCOMPILING) +IF(NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING_EMULATOR) VTK_ADD_EXECUTABLE(vtkEncodeString vtkEncodeString.cxx) vtk_compile_tools_target(vtkEncodeString) ENDIF() diff --git a/Utilities/HashSource/CMakeLists.txt b/Utilities/HashSource/CMakeLists.txt index 0dc4b25d24..24921c1c07 100644 --- a/Utilities/HashSource/CMakeLists.txt +++ b/Utilities/HashSource/CMakeLists.txt @@ -12,7 +12,7 @@ vtk_module_export_info() # launcher for it and should always use the RPATH to find shared libs. SET(CMAKE_SKIP_RPATH 0) -IF(NOT CMAKE_CROSSCOMPILING) +IF(NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING_EMULATOR) ADD_EXECUTABLE(vtkHashSource vtkHashSource.cxx) TARGET_LINK_LIBRARIES(vtkHashSource vtksys) vtk_compile_tools_target(vtkHashSource) diff --git a/Utilities/ParseOGLExt/CMakeLists.txt b/Utilities/ParseOGLExt/CMakeLists.txt index 2dff579691..31c5f4007d 100644 --- a/Utilities/ParseOGLExt/CMakeLists.txt +++ b/Utilities/ParseOGLExt/CMakeLists.txt @@ -23,7 +23,7 @@ vtk_module_export_info() -IF(NOT CMAKE_CROSSCOMPILING) +IF(NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING_EMULATOR) ADD_EXECUTABLE(vtkParseOGLExt Tokenizer.cxx ParseOGLExt.cxx) vtk_compile_tools_target(vtkParseOGLExt) ENDIF() -- GitLab