Ubuntu下打包Qt共享库时mentorsmsConfig.cmake生成异常求助
Qt共享库打包Ubuntu deb后CMake find_package报错问题
我开发了一个Qt共享库,希望打包成Ubuntu可安装的标准库,但在应用中使用find_package(mentorsms REQUIRED)时触发CMake错误,错误指向已安装的mentorsmsConfig.cmake文件,错误信息:
/usr/lib/mentorsms/cmake/mentorsmsConfig.cmake:8: error: configure_file Problem configuring file CMakeLists.txt:18 (find_package)
关键文件目录结构
mentorsms --mentorsmslib-1.0 ----debian ------control ------rules ----build ------debugrelease --------Makefile --------mentorsmsConfig.cmake ----src ------CMakeLists.txt ------cmake --------mentorsmsConfig.cmake.in
相关文件内容
mentorsmsConfig.cmake.in
set(PACKAGE_NAME "@PACKAGE_NAME@") set(PACKAGE_VERSION "@PACKAGE_VERSION@") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@") set(PACKAGE_URL "@PACKAGE_URL@") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/mentorsmsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/mentorsmsConfig.cmake" @ONLY@ )
生成后的mentorsmsConfig.cmake
set(PACKAGE_NAME "") set(PACKAGE_VERSION "") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "") set(PACKAGE_URL "") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/mentorsmsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/mentorsmsConfig.cmake" )
疑问点
我暂时不在意变量为空的问题,CMakeLists.txt是Qt共享库项目的默认配置,本以为debuild会自动处理相关变量,但configure_file部分的@ONLY@标记未被正确替换。另外,我的rules文件里包含三个cmake命令,会不会是这些命令导致配置文件生成异常?
rules文件内容
#!/usr/bin/make -f %: dh $@ override_dh_auto_clean: rm -fr $$(pwd)/build/debugrelease/* ; \ rm -fr $$(pwd)/debian/mentorsmslib/* ; \ rm -fr $$(pwd)/debian/mentorsmslib-dev/* ; \ rm -fr $$(pwd)/debian/mentorsmslib-src/* override_dh_auto_configure: cmake -H$$(pwd)/src -B$$(pwd)/build/debugrelease -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=mentorsms override_dh_auto_build: cmake --build $$(pwd)/build/debugrelease --target all override_dh_auto_install: mkdir -p $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms ; \ cmake --install $$(pwd)/build/debugrelease --config RelWithDebInfo --prefix $$(pwd)/debian/mentorsmslib/usr/lib ; \ mv $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so.1.0 ; \ ln -s $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so.1.0 $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so.1 ; \ ln -s $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so.1.0 $$(pwd)/debian/mentorsmslib/usr/lib/mentorsms/libmentorsms.so ; \ mkdir -p $$(pwd)/debian/mentorsmslib-dev/usr/include/mentorsms ; \ mkdir -p $$(pwd)/debian/mentorsmslib-src/usr/src/mentorsms ; \ find $$(pwd)/src -name "*.h" -type f -exec cp {} $$(pwd)/debian/mentorsmslib-dev/usr/include/mentorsms \; ; \ cp -R $$(pwd)/src $$(pwd)/debian/mentorsmslib-src/usr/src/mentorsms ; \ rm -f -- $$(pwd)/debian/mentorsmslib-src/usr/src/mentorsms/CMakeLists.txt.user override_dh_installudev: dh_installudev --name=serial --priority=99 ; \ dh_installudev --name=hid --priority=99
内容的提问来源于stack exchange,提问作者smsware
相关产品推荐
相关产品推荐

