admin管理员组

文章数量:1312931

Stil in the learning CMake phase, I want to move the build of an existing APR based application to this build system. But, in the same time I want to use APR and APR-Util libraries as Git submodules. The folder structure is simple and it looks like this:

adsp
|
---- build
|
---- deps
|    |
|    ---- apr ---> [email protected]:apache/apr.git
|    |
|    ---- apr-util ---> [email protected]:apache/apr-util.git
|
---- distro
|
CMakeLists.txt
main.c

The CMakeLists.txt

cmake_minimum_required(VERSION 3.31)
project(adsp C)
set(CMAKE_C_STANDARD 11)

set(APR_MINIMAL_BUILD "ON")
set(INSTALL_PDB "OFF")
set(CMAKE_INSTALL_PREFIX "../distro")

add_subdirectory(deps/apr)

after execution of the commands

cmake -S . -B build && cmake --build build --target install -j6

produces a successful build and the APR library is installed into the distro folder.

But, when I add the APR-Util library to the CMakeLists.list

...
add_subdirectory(deps/apr-util)
...

it fails:

CMake Error at deps/apr-util/CMakeLists.txt:32 (FIND_PACKAGE):
  By not providing "FindAPR.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "APR", but
  CMake did not find one.

  Could not find a package configuration file provided by "APR" with any of
  the following names:

    APRConfig.cmake
    apr-config.cmake

  Add the installation prefix of "APR" to CMAKE_PREFIX_PATH or set "APR_DIR"
  to a directory containing one of the above files.  If "APR" provides a
  separate development package or SDK, be sure it has been installed.

I tried to introduce the dependency, but I got the same error:

target_link_libraries(APR-Util PUBLIC APR)

As the error suggested, I defined this variable

set(APR_DIR "../distro/lib/cmake/apr")

but even so, I got the same error.

What else could I do, to get APR-Util built?

KI

本文标签: aprFailing CMake buildGit submodules as dependenciesStack Overflow