You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by Graf László <gr...@gmail.com> on 2025/09/24 12:53:48 UTC

A proper finder for APR

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.

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.

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).

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?

Best regards,
Laszlo Graf

Re: A proper finder for APR

Posted by Daniel Sahlberg <da...@gmail.com>.
Den ons 24 sep. 2025 kl 14:54 skrev Graf László <gr...@gmail.com>:

> 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.
>
> 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.
>

What are the exact error messages you get and what does your install layout
look like?


>
> 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).
>

Since r1926254 we don't explicitly rely on APR_ROOT: "Instead, rely on
CMake's find_package default behaviour" (quoted from svn log).

The CMake documentation[1] states that, from version 3.12,
<PackageName>_ROOT CMake variable is the first default search path of
find_path(). So it seems to me that CMake would include APR_ROOT
automatically.


> 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?
>

Because APR doesn't include a Find-module yet. Personally, I'd love to see
it included there instead.


>
> Best regards,
> Laszlo Graf
>

Cheers,
Daniel

[1] https://cmake.org/cmake/help/v3.31/command/find_path.html

Re: A proper finder for APR

Posted by Branko Čibej <br...@apache.org>.
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