From 035181f8d213b038650e7b718939526b52cac874 Mon Sep 17 00:00:00 2001 From: Tobias Triffterer <tobias@ep1.ruhr-uni-bochum.de> Date: Thu, 29 Apr 2021 16:12:10 +0200 Subject: [PATCH] Adapt Cling C++ Header Search Paths to Flatpak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds additional directories to the CMake variable CLING_CXX_HEADERS, whose content is later on compiled into the ROOT libraries. Cling requires access to the header files even at runtime, but a Flatpak runtime environment does not contain them, only the SDK used at compilation time does. The /usr tree inside a Flatpak sanbox is immutable, everything the application needs in addition to the underlying runtime has to be shipped in /app. This patch adds these paths under /app to the search paths of Cling so that it does work inside a Flatpak sandbox. This behaviour is controlled by the new boolean build option “BUILD_FOR_FLATPAKâ€. However, this patch alone does not do the trick. The Flatpak build manifest needs to contain commands to create the “/app/include†directory and copy all the include files there from the SDK as well as to install the include files from ROOT under “/app/include/rootâ€. --- .../cling/lib/Interpreter/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/interpreter/cling/lib/Interpreter/CMakeLists.txt b/interpreter/cling/lib/Interpreter/CMakeLists.txt index c68ca4d3ed6..0702ee0b444 100644 --- a/interpreter/cling/lib/Interpreter/CMakeLists.txt +++ b/interpreter/cling/lib/Interpreter/CMakeLists.txt @@ -282,6 +282,25 @@ if (UNIX) endif() endif() + # Modification for Fp311Online@Ruhr-Universität + option(BUILD_FOR_FLATPAK "Add include paths under /app to allow Cling to work in the Flatpak sandbox. (Please note that the Flatpak build manifest has to copy include files there in addition to setting this flag.)" OFF) + if (${BUILD_FOR_FLATPAK}) + set(CLING_CXX_HEADERS "${CLING_CXX_HEADERS}:/app/include:/app/include/root") + + file(GLOB flatpaksdk_cpp_inc_dirs LIST_DIRECTORIES TRUE "/usr/include/c++/*") + foreach(flatpaksdk_cpp_inc_dir ${flatpaksdk_cpp_inc_dirs}) + get_filename_component(flatpaksdk_cpp_version ${flatpaksdk_cpp_inc_dir} NAME) + set(CLING_CXX_HEADERS "${CLING_CXX_HEADERS}:/app/include/c++/${flatpaksdk_cpp_version}") + file(GLOB flatpaksdk_cpp_arch_dirs LIST_DIRECTORIES TRUE "/usr/include/c++/${flatpaksdk_cpp_version}/*linux*") + foreach(flatpaksdk_cpp_arch_dir ${flatpaksdk_cpp_arch_dirs}) + get_filename_component(flatpaksdk_cpp_arch ${flatpaksdk_cpp_arch_dir} NAME) + set(CLING_CXX_HEADERS "${CLING_CXX_HEADERS}:/app/include/c++/${flatpaksdk_cpp_version}/${flatpaksdk_cpp_arch}") + endforeach() + endforeach() + + endif (${BUILD_FOR_FLATPAK}) + # End Modification + MESSAGE(STATUS "Cling will look for C++ headers in '${CLING_CXX_HEADERS}' at runtime.") # In modules builds we 'mount' our own stl modulemap for libstdc++. In order to do this, -- GitLab