From 462e765ddc04e65a7a125dbf0fb3daede4eb52fb Mon Sep 17 00:00:00 2001
From: "Christian W. Zuckschwerdt" <christian@zuckschwerdt.org>
Date: Thu, 29 Feb 2024 10:34:12 +0100
Subject: [PATCH] build: Add Package maintainer note

---
 .ci/scripts/do_build.sh |  3 +--
 CMakeLists.txt          |  1 +
 docs/BUILDING.md        | 45 ++++++++++++++++++-----------------------
 3 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/.ci/scripts/do_build.sh b/.ci/scripts/do_build.sh
index 46a6184a..96dc4c13 100755
--- a/.ci/scripts/do_build.sh
+++ b/.ci/scripts/do_build.sh
@@ -16,9 +16,8 @@ SOAPYSDR="${SOAPYSDR:-AUTO}"
 OPENSSL="${OPENSSL:-AUTO}"
 set -- -DENABLE_RTLSDR=$RTLSDR -DENABLE_SOAPYSDR=$SOAPYSDR -DENABLE_OPENSSL=$OPENSSL
 
-mkdir -p build
 if [ -n "$CMAKE_TOOLCHAIN_FILE" ] ; then
-    cmake $@ -DCMAKE_TOOLCHAIN_FILE=../$CMAKE_TOOLCHAIN_FILE -GNinja -B build
+    cmake $@ -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -GNinja -B build
 else
     cmake $@ -GNinja -B build
 fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91ed92a8..e7366579 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -199,6 +199,7 @@ find_package(OpenSSL)
 pkg_check_modules(PC_OPENSSL QUIET openssl)
 if(PC_OPENSSL_FOUND AND NOT WIN32)
     set(OPENSSL_LIBRARIES ${PC_OPENSSL_LINK_LIBRARIES})
+    message(STATUS "Using OpenSSL: ${OPENSSL_LIBRARIES}")
 endif()
 if(OPENSSL_FOUND)
     message(STATUS "OpenSSL TLS support will be compiled. Found version ${OPENSSL_VERSION}")
diff --git a/docs/BUILDING.md b/docs/BUILDING.md
index 8d3b2546..91ed527f 100644
--- a/docs/BUILDING.md
+++ b/docs/BUILDING.md
@@ -75,28 +75,19 @@ Get the `rtl_433` git repository if needed:
 Installation using CMake and Make (commonly available):
 
     cd rtl_433/
-    mkdir build
-    cd build
-    cmake ..
-    make
-    make install
+    cmake -B build
+    cmake --build build --target install
 
 Installation using CMake and Ninja (newer and faster):
 
     cd rtl_433/
-    mkdir build
-    cd build
-    cmake -DFORCE_COLORED_BUILD:BOOL=ON -GNinja ..
-    cmake --build . -j 4
-    cmake --build . -- install
+    cmake -DFORCE_COLORED_BUILD:BOOL=ON -GNinja -B build
+    cmake --build build -j 4
+    cmake --build build --target install
 
 If installing to a global prefix (e.g. the default `/usr/local`) then instead run `make install` with privileges, .i.e.
 
-    sudo make install
-
-or
-
-    sudo cmake --build . -- install
+    sudo cmake --build build --target install
 
 Use CMake with `-DENABLE_SOAPYSDR=ON` (default: `AUTO`) to require SoapySDR (e.g. with Debian needs the package `libsoapysdr-dev`), use `-DENABLE_RTLSDR=OFF` (default: `ON`) to disable RTL-SDR if needed.
 E.g. use:
@@ -109,6 +100,14 @@ Purge all SoapySDR packages and source installation from /usr/local.
 Then install only from packages (version 0.7) or only from source (version 0.8).
 :::
 
+## Package maintainers
+
+To properly configure builds without relying on automatic feature detection you should set all options explicitly, e.g.
+
+    cmake -DENABLE_RTLSDR=ON -DENABLE_SOAPYSDR=ON -DENABLE_OPENSSL=ON -DBUILD_DOCUMENTATION=OFF -DCMAKE_BUILD_TYPE=Release -GNinja -B build
+    cmake --build build -j 10
+    DESTDIR=/tmp/destdir cmake --build build --target install
+
 ## Windows
 
 ### Visual Studio 2017
@@ -136,10 +135,8 @@ To start a build use in the menu e.g. "CMake" > "Build all"
 Or build at the Command Prompt without opening Visual Studio. Clone rtl_433 sources, then
 
     cd rtl_433
-    mkdir build
-    cd build
-    cmake -G "Visual Studio 15 2017 Win64" ..
-    cmake --build .
+    cmake -G "Visual Studio 15 2017 Win64" -B build
+    cmake --build build
 
 ### MinGW-w64
 
@@ -194,15 +191,13 @@ SET(Threads_FOUND TRUE)
 ```
 
 * open a MinGW terminal in the librtlsdr folder
-* create build folder and go into it: `mkdir build && cd build`
-* generate makefiles for MinGW: `cmake -G "MinGW Makefiles" ..`
-* build the librtlsdr library: `mingw32-make`
+* generate makefiles for MinGW: `cmake -G "MinGW Makefiles" -B build`
+* build the librtlsdr library: `cmake --build build`
 
 #### rtl_433
 
 * clone the rtl_433 repository and cd into it
-* create a build folder and go into it: `mkdir build && cd build`
-* run `cmake -G "MinGW Makefiles" .. ` in the build directory
+* run `cmake -G "MinGW Makefiles" -B build` in the build directory
 * run cmake-gui (this is easiest)
 * set the source (the rtl_433 source code directory) and the build directory (one might create a build directory in the source directory)
 * click configure
@@ -211,7 +206,7 @@ SET(Threads_FOUND TRUE)
 * point the `LIBRTLSDR_INCLUDE_DIRS` to the include folder of the librtlsdr source
 * point the `LIBRTLSDR_LIBRARIES` to the `librtlsdr.dll.a` file in the <librtlsdr_source>/build/src folder
     * that's the one you've built earlier
-* start a MinGW terminal and run `mingw32-make` to build
+* start a MinGW terminal and run `cmake --build build` to build
     * when something in the tests folder doesn't build, you can disable it by commenting out `add_subdirectory(tests)` in the CMakeLists.txt file in the source folder of rtl_433
 * rtl_433.exe should be built now
 * you need to place it in the same folder as librtlsdr.dll and libusb-1.0.dll (you should have seen both of them by now)