From f32328babc784f317508da953fb216b8c4126858 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 18 Oct 2024 17:34:24 +0200 Subject: [PATCH] Introduce a workaround to consider nlohmann_json installed on system and nlohmann_json used as a built in 3rdparty by VTK > 9.2.0 when PCL is enabled. Fixes #1485. --- ci/docker/ubuntu-dep-src/Dockerfile | 18 +++--- ci/docker/ubuntu-dep-src/README.md | 73 ++++++++++++++++++++++ cmake/templates/vpConfig.h.in | 8 +++ modules/gui/src/pointcloud/vpPclViewer.cpp | 2 +- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 ci/docker/ubuntu-dep-src/README.md diff --git a/ci/docker/ubuntu-dep-src/Dockerfile b/ci/docker/ubuntu-dep-src/Dockerfile index 63ab7d1914..ea2f86fc66 100644 --- a/ci/docker/ubuntu-dep-src/Dockerfile +++ b/ci/docker/ubuntu-dep-src/Dockerfile @@ -91,8 +91,8 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && git clone --depth 1 --branch $LATEST_TAG $GIT_ADDRESS \ && cd OpenBLAS \ && mkdir install \ - && make -j$(nproc) \ - && make -j$(nproc) install PREFIX=$(pwd)/install + && make -j$(($(nproc) / 2)) \ + && make -j$(($(nproc) / 2)) install PREFIX=$(pwd)/install ENV OpenBLAS_HOME=${HOME}/visp-ws/3rdparty/OpenBLAS/install @@ -107,7 +107,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && cmake .. -DVTK_ANDROID_BUILD=OFF -DVTK_BUILD_DOCUMENTATION=OFF -DVTK_BUILD_EXAMPLES=OFF -DVTK_BUILD_EXAMPLES=OFF \ -DCMAKE_BUILD_TYPE=Release -DVTK_GROUP_ENABLE_Imaging=DONT_WANT -DVTK_GROUP_ENABLE_MPI=DONT_WANT \ -DVTK_GROUP_ENABLE_Web=DONT_WANT -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/VTK/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV VTK_DIR=${HOME}/visp-ws/3rdparty/VTK/build/install @@ -121,7 +121,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/opencv/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV OpenCV_DIR=${HOME}/visp-ws/3rdparty/opencv/build/install @@ -135,7 +135,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/librealsense/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV REALSENSE2_DIR=${HOME}/visp-ws/3rdparty/librealsense/build/install @@ -149,7 +149,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_tools=OFF -DBUILD_global_tests=OFF -DPCL_DISABLE_GPU_TESTS=ON -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/pcl/build/install \ - && make -j10 install + && make -j$(($(nproc) / 3)) install ENV PCL_DIR=${HOME}/visp-ws/3rdparty/pcl/build/install @@ -160,7 +160,7 @@ RUN mkdir -p ${HOME}/visp-ws \ && echo "export VISP_WS=${HOME}/visp-ws" >> ${HOME}/.bashrc \ && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc -# Download ViSP fork +# Download ViSP RUN cd ${HOME}/visp-ws \ && git clone ${GIT_URL} ${GIT_BRANCH_CMD} @@ -169,7 +169,7 @@ RUN cd ${HOME}/visp-ws \ && mkdir visp-build \ && cd visp-build \ && cmake ../visp -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/visp-build/install \ - && make -j$(nproc) developer_scripts \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) developer_scripts \ + && make -j$(($(nproc) / 2)) install CMD ["/bin/bash"] diff --git a/ci/docker/ubuntu-dep-src/README.md b/ci/docker/ubuntu-dep-src/README.md new file mode 100644 index 0000000000..d51ede189d --- /dev/null +++ b/ci/docker/ubuntu-dep-src/README.md @@ -0,0 +1,73 @@ +# Docker dedicated to check compatibility with 3rd party last releases + +## Build docker image from Dockerfile + +- We suppose here that you already installed docker. +If this is not the case, follow instructions provided for [Ubuntu](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_ubuntu) or [MacOS](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_mac). + +- Get ViSP source code + ``` + $ cd $VISP_WS/ + $ git clone https://github.com/lagadic/visp + ``` + +- Build docker image from Dockerfile running the following: + ``` + $ cd $VISP_WS/visp/ci/docker/ubuntu-dep-src + $ docker build -t vispci/vispci:ubuntu-dep-src . + ``` + The version of ViSP that is considered is by default the master branch from github official repo in + https://github.com/lagadic/visp + + There is also the possibility to build visp from a specific repo and branch using `GIT_URL` and `GIT_BRANCH_NAME` + args, like + ``` + $ cd $VISP_WS/visp/ci/docker/ubuntu-dep-src + $ docker build -t vispci/vispci:ubuntu-dep-src --build-arg GIT_URL=https://github.com/lagadic/visp --build-arg GIT_BRANCH_NAME=master . + ``` + +## Start the container + +### On Ubuntu host + +- On your computer running Ubuntu, allow access to the X11 server + ``` + $ xhost +local:docker + non-network local connections being added to access control list + ``` +- Run your Docker container. The following command connects to the ubuntu-dep-src Docker container. + ``` + $ docker run --rm -it --network=host --privileged \ + --env=DISPLAY \ + --env=QT_X11_NO_MITSHM=1 \ + --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \ + --volume=/dev:/dev \ + vispci/vispci:ubuntu-dep-src + vispci@6c8d67579659:~$ pwd + /home/vispci + ``` + +### On MacOS host + +- Get your MacOS computer IP address + ``` + $ IP=$(/usr/sbin/ipconfig getifaddr en0) + $ echo $IP + $ 192.168.1.18 + ``` +- Allow connections from MacOS to XQuartz + ``` + $ xhost + "$IP" + 192.168.1.18 being added to access control list + ``` +- Run your Docker container. The following command connects to the ubuntu-dep-src Docker container. + ``` + $ docker run --rm -it --network=host --privileged \ + --env=DISPLAY="${IP}:0" \ + --env=QT_X11_NO_MITSHM=1 \ + --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \ + --volume=/dev:/dev \ + vispci/vispci:ubuntu-dep-src + vispci@6c8d67579659:~$ pwd + /home/vispci + ``` diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index dd4643bae9..17d3be781c 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -527,6 +527,14 @@ namespace vp = VISP_NAMESPACE_NAME; // Defined if nlohmann json parser is found #cmakedefine VISP_HAVE_NLOHMANN_JSON +// Workaround for issue https://github.com/lagadic/visp/issues/1485 +#if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_PCL_VISUALIZATION) +#include +#if VTK_VERSION_NUMBER_QUICK >= VTK_VERSION_CHECK(9, 2, 0) +#include +#endif +#endif + // Define c++ standard values also available in __cplusplus when gcc is used #define VISP_CXX_STANDARD_98 ${VISP_CXX_STANDARD_98} #define VISP_CXX_STANDARD_11 ${VISP_CXX_STANDARD_11} diff --git a/modules/gui/src/pointcloud/vpPclViewer.cpp b/modules/gui/src/pointcloud/vpPclViewer.cpp index 94adb3c48a..dd866f50e8 100644 --- a/modules/gui/src/pointcloud/vpPclViewer.cpp +++ b/modules/gui/src/pointcloud/vpPclViewer.cpp @@ -37,7 +37,7 @@ #include #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS) // PCL -#include +#include // ViSP #include