CMake 将绝对 CMAKE_SYSROOT 路径添加到 pkg-config pc 文件

问题描述

我正在尝试交叉编译 webkit。

在我的工具链文件中设置:

set(CMAKE_SYSROOT "/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot")

在配置期间我指定安装目录

-DCMAKE_INSTALL_PREFIX:PATH=/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot/usr 

包的其中一个 CMakeLists 生成一个 pkg-config *.PC 文件,其中包含:

    prefix=/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot/usr
    exec_prefix=${prefix}
    includedir=${prefix}/include
    libdir=${exec_prefix}/lib    
    Name: wpe-1.0
    Description: The wpe library
    Version: 1.8.0
    Requires: xkbcommon
    Cflags: -I${includedir}/wpe-1.0
    Libs: -L${libdir} -lwpe-1.0

这是错误的,pkg-config cflags 应该指向目标上的 /usr 而不是 sysroot 路径。

pkgconfig 文件的来源,使用 cmake 的 configure_file 编辑:

prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: wpe-@WPE_API_VERSION@
Description: The wpe library
Version: @PROJECT_VERSION@
Requires: xkbcommon
Cflags: -I${includedir}/wpe-@WPE_API_VERSION@
Libs: -L${libdir} -lwpe-@WPE_API_VERSION@

我是否正确使用了 CMAKE_INSTALL_PREFIX?或者它可以以某种方式相对 CMAKE_SYSROOT?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)