On 24. 9. 25 14:53, Graf László wrote:
Hi,
I am working on an APR based project, built using GNU make.
But now, besides feature and bug issues, I have one to introduce a CMake
based build. This needs a dedicated package finder for APR.
Serf's CMake build is experimental, so problems are expected.
And here comes the serf, it has one for ARP. Reading the CMakeLists.txt I
noticed that it is enough to set APR_HOME and it will use the installed APR
library.
But, unfortunately, even with APR_ROOT set, I get errors during the build.
It would be helpful if you showed us the errors, otherwise it's kind of
hard to guess what the problem is.
Checking the FindAPRE.cmake, I can see that it gets the directory of the
set APR_ROOT but it doesn't use it later (ex. in _apru_find_win_version.
etc).
The Windows build isn't extensively tested. It works if you put all your
dependencies in one place using vcpkg. Here's an example, I use this
script on a Windows ARM64 virtual machine:
set src=C:\dev\src\serf
set bld=build-serf
set tgt=ARM64
set arch=ARM64
set dst=C:\dev\install
set dep=C:\dev\vcpkg_installed\arm64-windows
C:
cd \dev\
rmdir /S/Q %bld%
mkdir %bld%
cmake -A %arch% ^
-B %bld% ^
-G "Visual Studio 17 2022" ^
-DCMAKE_GENERATOR_PLATFORM=%tgt% ^
-DCMAKE_INSTALL_PREFIX=%dst% ^
-DCMAKE_PREFIX_PATH=%dep% ^
%src%
In this case, the vcpkg packages are iinstalled in
C:\dev\vcpkg_installed\arm64-windows. I have this in my vcpkg.json file:
"dependencies": [
"apr",
"apr-util",
"brotli",
"lz4",
"openssl",
"sqlite3",
"utf8proc",
"zlib"
]
In my opinion, all those functions, where find_path is called, should add
this APR_ROOT as an additional search path, in case of a defined APR_ROOT:
find_path(${_include_varname} "${_header_basename}.h"
PATHS
"${APR_ROOT}"
PATH_SUFFIXES
"include"
"${CMAKE_INSTALL_INCLUDEDIR}"
"include/apr-2"
"${CMAKE_INSTALL_INCLUDEDIR}/apr-2"
"include/apr-1"
"${CMAKE_INSTALL_INCLUDEDIR}/apr-1"
)
Remais one single, maybe rhetorical, question. Why does serf define this
package finder and not the APR itself?
It does, it installs apr-config.cmake and a few other files (but only on
Windows). The non-rhetorical answer is that, as I said above, Serf's
CMake build is experimental, it just doesn't use those parts yet. (It
doesn't install a serf-config.cmake, either.)
-- Brane