1

CMake 各种报错报警

 1 year ago
source link: https://charon-cheung.github.io/2023/01/03/cmake%20qmake/CMake%20%E5%90%84%E7%A7%8D%E6%8A%A5%E9%94%99%E6%8A%A5%E8%AD%A6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CMake 各种报错报警

CMake 各种报错报警
2023-01-03|cmake/qmake|
Word count: 355|Reading time: 1 min
  • integer_sequence’ is not a member of ‘std’

编译工程时报错 integer_sequence’ is not a member of ‘std’
CMake中添加 set(CMAKE_CXX_FLAGS "-std=c++14")

  • CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake

我升级CMake后出现的报警,虽然不影响,但是一旦工程多了以后,这个报警会很烦人。只需要修改cmake_minimum_required (VERSION 3.19.0)

但是有时CMakeLists太多了,不可能一一去修改,使用sed命令集体修改:

sed -i "s/2.8.3/3.19/g" `grep 2.8.3 -rl . --include="*.txt" `

这个命令不要滥用,否则可能更改过多
  • 涉及PCL的一个警告
CMake Warning (dev) at /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
The package name passed to `find_package_handle_standard_args` (PCL_KDTREE)
does not match the name of the calling package (PCL). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.

find_package(PCL REQUIRED)之前加上

if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
endif()
  • No rule to make target

有时明明写好了,但编译会出现报错,看上去是CMakeLists中没有编译规则

make[2]: *** No rule to make target 'package/CMakeFiles/test_bin.dir/build'。 停止。
CMakeFiles/Makefile2:3192: recipe for target 'package/CMakeFiles/test_bin.dir/all' failed
make[1]: *** [package/CMakeFiles/test_bin.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

此时再重新编译仍然报错,只要把CMakeLists改一下,再编译就通过了

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK