我有一个简单的项目,正在Windows for Linux上交叉编译。 我使用CPack将项目成功构建,安装并打包到tarball中。
现在,我想将跨工具链中的运行时依赖项(libc,libcrypto,ipbthread等)添加到tarball中。
乍一看,似乎include(InstallRequiredSystemLibraries)
应该可以解决问题。但是,我似乎无法将RequiredSystemLibraries
复制到输出文件夹。另外,下面的跟踪消息始终返回空CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
。
使用跨工具链时,include(InstallRequiredSystemLibraries)
机制如何工作?这种机制如何确定我的Linux应用程序的运行时依赖关系?
这是我项目的CMakeLists.txt
:
cmake_minimum_required(VERSION 3.12)
project(Test_App CXX)
[...]
add_subdirectory(Test_App)
[...]
# Set packagement management configuration
set(CPACK_GENERATOR "TBZ2")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
include (InstallRequiredSystemLibraries)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "os_dep")
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
include (CPack)
message(STATUS "CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS :
${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}")
这是我的跨工具链文件:
cmake_minimum_required(VERSION 3.12)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
# specify the cross compiler
set(tools c:/cygwin64/opt/x-tools/x86_64-kepware-linux-gnu)
set(CMAKE_C_COMPILER ${tools}/bin/x86_64-kepware-linux-gnu-gcc.exe)
set(CMAKE_CXX_COMPILER ${tools}/bin/x86_64-kepware-linux-gnu-g++.exe)
set(CMAKE_SYSROOT ${tools}/x86_64-kepware-linux-gnu/sysroot)
# specify the target environment
set(CMAKE_FIND_ROOT_PATH ${tools}/x86_64-kepware-linux-gnu/sysroot)
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
这就是我调用CMake的方式:
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=./cmake/crosstoolchain_x86_64-kepware-linux-gnu.cmake -DCMAKE_INSTALL_PREFIX=<where ever you want> ..
make
make install
cpack