Skip to content

Commit 2b4568b

Browse files
committed
Simplify CMake botan handling
Use the CMake builtin botan configuration for finding botan Set BOTAN_LIBRARY based on static or shared library Update docker
1 parent e872210 commit 2b4568b

File tree

3 files changed

+18
-112
lines changed

3 files changed

+18
-112
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,17 @@ set(version_file "${CMAKE_CURRENT_BINARY_DIR}/Version.cpp")
9999
##############################
100100
# Botan #
101101
##############################
102-
find_package(Botan 2.14.0 REQUIRED)
102+
find_package(Botan REQUIRED)
103+
# Check if the static target exists; otherwise fallback to the shared target.
104+
if(TARGET Botan::Botan-static)
105+
set(BOTAN_LIBRARY Botan::Botan-static)
106+
message(STATUS "Using Botan static library")
107+
elseif(TARGET Botan::Botan)
108+
set(BOTAN_LIBRARY Botan::Botan)
109+
message(STATUS "Using Botan shared library")
110+
else()
111+
message(FATAL_ERROR "No valid Botan target found")
112+
endif()
103113
include_directories(${BOTAN_INCLUDE_DIRS})
104114

105115
##############################

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN apt-get -y update && apt-get -y upgrade \
2222
&& apt-get -y install cmake \
2323
&& apt-get -y install git \
2424
# Install required library packages
25-
&& apt-get install -y libbotan-2-dev \
25+
&& apt-get install -y libbotan-3-dev \
2626
&& apt-get install -y libmysqlcppconn-dev \
2727
&& apt-get install -y zlib1g-dev \
2828
&& apt-get install -y libpcre3-dev \
@@ -31,7 +31,11 @@ RUN apt-get -y update && apt-get -y upgrade \
3131
&& tar -zxf boost_1_87_0.tar.gz \
3232
&& cd boost_1_87_0 \
3333
&& ./bootstrap.sh --with-libraries=system,program_options,headers \
34-
&& ./b2 link=static install -d0 -j 2 cxxflags="-std=c++23"
34+
&& ./b2 link=static install -d0 -j 2 cxxflags="-std=c++23" \
35+
# Create the missing botan include folder for the cmake config file
36+
&& mkdir -p /usr/lib/include \
37+
&& rm -rf /usr/lib/include/botan-3 \
38+
&& cp -R /usr/include/botan-3 /usr/lib/include/botan-3
3539

3640
# Copy source
3741
ARG working_dir=/usr/src/ember
@@ -54,8 +58,6 @@ RUN --mount=type=cache,target=build \
5458
-DBUILD_OPT_TOOLS=${build_optional_tools} \
5559
-DPCRE_STATIC_LIB=${pcre_static_lib} \
5660
-DDISABLE_EMBER_THREADS=${disable_threads} \
57-
-DBOTAN_ROOT_DIR=/usr/include/botan-2/ \
58-
-DBOTAN_LIBRARY=/usr/lib/x86_64-linux-gnu/libbotan-2.so \
5961
&& cd build && make -j$(nproc) install \
6062
&& cp -r ${working_dir}/tests/ . \
6163
&& make test
@@ -65,7 +67,7 @@ ARG install_dir=/usr/local/bin
6567
ARG working_dir=/usr/src/ember
6668
WORKDIR ${install_dir}
6769
RUN apt-get -y update \
68-
&& apt-get install -y libbotan-2-19 \
70+
&& apt-get install -y libbotan-3-7 \
6971
&& apt-get install -y libmysqlcppconn7v5 \
7072
&& apt-get install -y mysql-client
7173
COPY --from=builder ${install_dir} ${install_dir}

cmake/FindBotan.cmake

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)