Skip to content

Commit 7b56f26

Browse files
authored
Merge pull request #16 from tim-devereux/main
Cmake and Docker Improvements
2 parents 69aa036 + d6af0fc commit 7b56f26

File tree

5 files changed

+201
-54
lines changed

5 files changed

+201
-54
lines changed

CMakeLists.txt

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ if(WITH_LAS)
6262
list(APPEND RAYTOOLS_INCLUDE ${libLAS_INCLUDE_DIRS})
6363
list(APPEND RAYTOOLS_LINK ${libLAS_LIBRARIES})
6464
endif(WITH_LAS)
65+
6566
if(WITH_QHULL)
6667
# Find the qhull that provides a config with targets first
6768
find_package(Qhull CONFIG QUIET)
@@ -73,18 +74,36 @@ if(WITH_QHULL)
7374
list(APPEND RAYTOOLS_INCLUDE ${QHULL_INCLUDE_DIRS})
7475
list(APPEND RAYTOOLS_LINK ${QHULL_LIBRARIES})
7576
endif(WITH_QHULL)
76-
if(WITH_TIFF)
77-
find_package(GeoTIFF REQUIRED)
78-
find_package(PROJ REQUIRED COMPONENTS proj)
79-
list(APPEND RAYTOOLS_INCLUDE ${GEOTIFF_INCLUDE_DIR})
80-
list(APPEND RAYTOOLS_LINK ${GEOTIFF_LIBRARIES})
81-
find_package(TIFF REQUIRED)
82-
list(APPEND RAYTOOLS_INCLUDE ${TIFF_INCLUDE_DIRS})
83-
list(APPEND RAYTOOLS_LINK ${TIFF_LIBRARIES})
84-
find_package(PROJ REQUIRED CONFIG)
85-
list(APPEND RAYTOOLS_INCLUDE ${PROJ_INCLUDE_DIR})
86-
list(APPEND RAYTOOLS_LINK ${PROJ_LIBRARIES})
87-
endif(WITH_TIFF)
77+
78+
if (WITH_TIFF)
79+
# Find and configure GeoTIFF
80+
find_package(GeoTIFF REQUIRED)
81+
82+
if(GeoTIFF_FOUND)
83+
list(APPEND RAYTOOLS_INCLUDE ${GeoTIFF_INCLUDE_DIR})
84+
list(APPEND RAYTOOLS_LINK ${GeoTIFF_LIBRARIES})
85+
else()
86+
message(FATAL_ERROR "GeoTIFF library not found.")
87+
endif()
88+
89+
# Find and configure TIFF
90+
find_package(TIFF REQUIRED)
91+
if (TIFF_FOUND)
92+
list(APPEND RAYTOOLS_INCLUDE ${TIFF_INCLUDE_DIRS})
93+
list(APPEND RAYTOOLS_LINK ${TIFF_LIBRARIES})
94+
else()
95+
message(FATAL_ERROR "TIFF library not found.")
96+
endif()
97+
98+
# Find and configure PROJ
99+
find_package(PROJ REQUIRED)
100+
if (PROJ_FOUND)
101+
list(APPEND RAYTOOLS_INCLUDE ${PROJ_INCLUDE_DIRS})
102+
list(APPEND RAYTOOLS_LINK ${PROJ_LIBRARIES})
103+
else()
104+
message(FATAL_ERROR "PROJ library not found.")
105+
endif()
106+
endif (WITH_TIFF)
88107

89108
if(WITH_TBB)
90109
# Helper macro to Find TBB prefering TBBConfig, falling back to FindTBB. TBB_LIBRARIES will be defined in both cases.

cmake/FindGeoTIFF.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# FindGeoTIFF.cmake
2+
3+
# Try to find the GeoTIFF library and headers
4+
find_path(GeoTIFF_INCLUDE_DIR NAMES geotiff.h
5+
HINTS
6+
${CMAKE_INSTALL_PREFIX}/include
7+
/usr/local/include/geotiff
8+
/usr/include
9+
)
10+
11+
find_library(GeoTIFF_LIBRARY NAMES geotiff
12+
HINTS
13+
${CMAKE_INSTALL_PREFIX}/lib
14+
/usr/local/lib
15+
/usr/lib
16+
/usr/lib/x86_64-linux-gnu
17+
)
18+
19+
# Handle the result
20+
include(FindPackageHandleStandardArgs)
21+
find_package_handle_standard_args(GeoTIFF REQUIRED_VARS GeoTIFF_INCLUDE_DIR GeoTIFF_LIBRARY)
22+
23+
if(GeoTIFF_FOUND)
24+
set(GeoTIFF_LIBRARIES ${GeoTIFF_LIBRARY})
25+
else()
26+
set(GeoTIFF_LIBRARIES "")
27+
endif()
28+
29+
mark_as_advanced(GeoTIFF_INCLUDE_DIR GeoTIFF_LIBRARY)

cmake/FindPROJ.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# FindPROJ.cmake
2+
3+
if (PROJ_FOUND)
4+
# PROJ is already found, no need to search again
5+
return()
6+
endif()
7+
8+
# Find the PROJ library
9+
find_package_handle_standard_args(PROJ DEFAULT_MSG PROJ_LIBRARY PROJ_INCLUDE_DIR)
10+
11+
# Define the PROJ library
12+
find_library(PROJ_LIBRARY
13+
NAMES proj
14+
PATHS ${CMAKE_LIBRARY_PATH}
15+
NO_DEFAULT_PATH
16+
)
17+
18+
# Define the PROJ include directory
19+
find_path(PROJ_INCLUDE_DIR
20+
NAMES proj.h
21+
PATHS ${CMAKE_INCLUDE_PATH}
22+
NO_DEFAULT_PATH
23+
)
24+
25+
# Handle the results
26+
include(FindPackageHandleStandardArgs)
27+
find_package_handle_standard_args(PROJ
28+
REQUIRED_VARS PROJ_LIBRARY PROJ_INCLUDE_DIR
29+
VERSION_VAR PROJ_VERSION
30+
)
31+
32+
# Provide variables for the library and include directory
33+
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
34+
set(PROJ_LIBRARIES ${PROJ_LIBRARY})
35+
36+
# Provide version information if available
37+
if (PROJ_VERSION)
38+
set(PROJ_VERSION_STRING "${PROJ_VERSION}")
39+
else()
40+
set(PROJ_VERSION_STRING "unknown")
41+
endif()

docker/Dockerfile

Lines changed: 94 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,112 @@
1-
FROM alpine:3
1+
FROM ubuntu:22.04
22

3-
RUN apk update
3+
# Avoid prompts from apt
4+
ENV DEBIAN_FRONTEND=noninteractive
45

5-
RUN apk add make cmake g++ git proj-dev eigen-dev boost-dev libgeotiff-dev gtest-dev && \
6-
cd /usr/share/cmake/Modules && \
7-
wget https://raw.githubusercontent.com/ufz/geotiff/master/cmake/FindGeoTIFF.cmake
6+
# Set LC_ALL and unset LANGUAGE
7+
ENV LC_ALL=C
8+
ENV LANGUAGE=
89

9-
RUN cd /home && \
10-
git clone https://github.com/ethz-asl/libnabo.git && \
11-
cd libnabo && \
12-
git checkout tags/1.0.7 && \
13-
mkdir build && cd build && \
14-
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && \
15-
make -j$(nproc) && make install
10+
# Update, install dependencies and cleanup
11+
RUN apt-get update && apt-get upgrade -y && \
12+
apt-get install -y \
13+
git \
14+
build-essential \
15+
cmake \
16+
clang-tidy \
17+
libeigen3-dev \
18+
libproj-dev \
19+
libgeotiff-dev \
20+
libboost-all-dev && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
# Create a directory for building packages
24+
RUN mkdir -p /build && \
25+
cd /build
1626

17-
RUN cd /home && \
18-
git clone https://github.com/LASzip/LASzip.git && \
27+
# Clone, build and clean up LASzip
28+
RUN git clone https://github.com/LASzip/LASzip.git && \
1929
cd LASzip && \
2030
git checkout tags/2.0.1 && \
21-
mkdir build && cd build && \
31+
mkdir build && cd build && \
2232
cmake .. && \
23-
make -j$(nproc) && make install
33+
make -j$(nproc) && \
34+
make install && \
35+
cp bin/Release/liblas* /usr/lib/ && \
36+
cd ../.. && rm -rf LASzip
2437

25-
RUN cd /home && \
26-
git clone https://github.com/libLAS/libLAS.git && \
27-
cd libLAS && \
38+
# Clone, build and clean up libLAS
39+
RUN git clone https://github.com/libLAS/libLAS.git && \
40+
cd libLAS && \
2841
mkdir build && cd build && \
2942
cmake .. -DWITH_LASZIP=ON -DWITH_GEOTIFF=OFF -DCMAKE_CXX_STANDARD=11 && \
30-
make -j$(nproc) && make install
43+
make -j$(nproc) && \
44+
make install && \
45+
cd ../.. && rm -rf libLAS
3146

32-
RUN cd /home && \
33-
git clone http://github.com/qhull/qhull.git && \
47+
# Clone, build and clean up Qhull
48+
RUN git clone https://github.com/qhull/qhull.git && \
3449
cd qhull && \
3550
git checkout tags/v7.3.2 && \
36-
mkdir -p build && cd build && \
51+
cd build && \
3752
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true && \
38-
make -j$(nproc) && make install
53+
make -j$(nproc) && \
54+
make install && \
55+
cd ../.. && rm -rf qhull
3956

40-
RUN cd /home && \
41-
git clone https://github.com/csiro-robotics/raycloudtools.git && \
42-
cd raycloudtools && \
57+
# Clone, build and clean up libnabo
58+
RUN git clone https://github.com/ethz-asl/libnabo.git && \
59+
cd libnabo && \
60+
git checkout tags/1.0.7 && \
4361
mkdir build && cd build && \
44-
cmake .. -DGEOTIFF_LIBRARIES=/usr/lib/libgeotiff.so -DWITH_QHULL=ON -DWITH_LAS=ON -DWITH_TIFF=ON -DRAYCLOUD_BUILD_TESTS=ON && \
45-
make -j$(nproc) && make install
46-
47-
RUN cd /home && \
48-
git clone https://github.com/csiro-robotics/treetools.git && \
62+
cmake .. -DCMAKE_BUILD_TYPE=Release && \
63+
make -j$(nproc) && \
64+
make install && \
65+
cd ../.. && rm -rf libnabo
66+
67+
# Clone, build and install raycloudtools
68+
RUN git clone https://github.com/tim-devereux/raycloudtools.git && \
69+
cd raycloudtools && \
70+
mkdir build && \
71+
cd build && \
72+
cmake .. \
73+
-DGeoTIFF_INCLUDE_DIR=/usr/include/geotiff \
74+
-DGeoTIFF_LIBRARY=/usr/lib/x86_64-linux-gnu/libgeotiff.so \
75+
-DPROJ_INCLUDE_DIR=/usr/include/proj \
76+
-DPROJ_LIBRARY=/usr/lib/x86_64-linux-gnu/libproj.so \
77+
-DWITH_QHULL=ON \
78+
-DWITH_LAS=ON \
79+
-DDOUBLE_RAYS=ON \
80+
-DWITH_TIFF=ON \
81+
-DCMAKE_BUILD_TYPE=Release && \
82+
make -j$(nproc) && \
83+
make install && \
84+
cd ../.. && \
85+
rm -rf raycloudtools
86+
87+
# Clone and build TreeTools
88+
RUN git clone https://github.com/tim-devereux/treetools.git && \
4989
cd treetools && \
50-
mkdir build && cd build && \
51-
cmake .. -DWITH_TIFF=ON && \
52-
make -j$(nproc) && make install
90+
mkdir -p build && \
91+
cd build && \
92+
cmake .. \
93+
-DPROJ_INCLUDE_DIR=/usr/include/proj \
94+
-DPROJ_LIBRARY=/usr/lib/x86_64-linux-gnu/libproj.so \
95+
-DWITH_TIFF=ON \
96+
-DCMAKE_BUILD_TYPE=Release && \
97+
make -j$(nproc) && \
98+
make install && \
99+
cd ../.. && \
100+
rm -rf treetools
101+
102+
# Update ldconfig
103+
RUN ldconfig /usr/local/lib
104+
105+
# Clean up build directory
106+
RUN rm -rf /build
107+
108+
# Set the working directory
109+
WORKDIR /workspace
53110

54-
WORKDIR /data
111+
# Set the entrypoint
112+
ENTRYPOINT ["/bin/bash"]

docker/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
#### date: June 24, 2023
66
---
77

8-
The provided docker file allows easy building from a lightweight linux image ([Alpine v3](https://hub.docker.com/_/alpine/)).
8+
The provided dockerfile allows easy building. It is based on [Ubuntu22.04](https://hub.docker.com/_/ubuntu/).
99

1010
Be sure to have the latest [Docker](https://docs.docker.com/engine/install/) installed in your system. To build the raycloudtools image, run:
1111

1212
```
13-
docker build -f Dockerfile -t raytools .
13+
docker build -f Dockerfile -t raycloudtools .
1414
```
1515

16-
This image will download and compile raycloudtools and all its dependencies (including treetools, so you can process rayextract outputs). You can then run the `raytools` image as a standalone executable. The basic command is `docker run -v your/local/datadir:/data raytools` followed by the specific ray tool you want to use, as in:
16+
This image will download and compile raycloudtools and all its dependencies (including treetools, so you can process rayextract outputs). You can then run the `raycloudtools` image as a standalone executable. The basic command is `docker run -v your/local/datadir:/data raycloudtools` followed by the specific tool you want to use, as in:
1717

1818
```
19-
docker run -v your/local/datadir:/data raytools rayimport --help
19+
docker run -v your/local/datadir:/data raycloudtools rayimport
2020
```
2121

2222
Here's an example of a pipeline to process a forest plot:
@@ -28,7 +28,7 @@ cd mydata
2828
2929
# [optional] create a local environment variable with the arguments you
3030
# want to pass to docker - so you don't have to rewrite it everytime
31-
CMD="run --rm -u $(id -u $USER) -v $PWD:/data raytools"
31+
CMD="run --rm -u $(id -u $USER) -v $PWD:/data raycloudtools"
3232
3333
# generate some sample data
3434
docker $CMD raycreate forest 3
@@ -48,4 +48,4 @@ docker $CMD rayextract trees forest.ply forest_mesh.ply
4848
docker $CMD rayextract leaves forest.ply forest_trees.txt
4949
```
5050

51-
The outputs from the above commands will be at your local directory. You can visually inspect the `ply` files using software such as [CloudCompare](https://www.danielgm.net/cc/).
51+
The outputs from the above commands will be at your local directory. You can visually inspect the `ply` files using software such as [CloudCompare](https://www.danielgm.net/cc/).

0 commit comments

Comments
 (0)