Skip to content

Commit

Permalink
Introduce a workaround to consider nlohmann_json installed on system …
Browse files Browse the repository at this point in the history
…and nlohmann_json used as a built in 3rdparty by VTK > 9.2.0 when PCL is enabled. Fixes #1485.
  • Loading branch information
fspindle committed Oct 18, 2024
1 parent a65eebc commit f32328b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 10 deletions.
18 changes: 9 additions & 9 deletions ci/docker/ubuntu-dep-src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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}

Expand All @@ -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"]
73 changes: 73 additions & 0 deletions ci/docker/ubuntu-dep-src/README.md
Original file line number Diff line number Diff line change
@@ -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
```
8 changes: 8 additions & 0 deletions cmake/templates/vpConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vtkVersion.h>
#if VTK_VERSION_NUMBER_QUICK >= VTK_VERSION_CHECK(9, 2, 0)
#include <pcl/visualization/pcl_visualizer.h>
#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}
Expand Down
2 changes: 1 addition & 1 deletion modules/gui/src/pointcloud/vpPclViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS)
// PCL
#include<pcl/io/pcd_io.h>
#include <pcl/io/pcd_io.h>

// ViSP
#include <visp3/gui/vpPclViewer.h>
Expand Down

0 comments on commit f32328b

Please sign in to comment.