CMakeFile调试

bash 复制代码
cmake_minimum_required (VERSION 3.1)
set (EXE_NAME ch347-nor-prog)
project (${EXE_NAME} C CXX)
find_package(PkgConfig)
pkg_check_modules(libusb-1.0 REQUIRED IMPORTED_TARGET libusb-1.0)

include_directories(/usr/local/include)

add_executable(${EXE_NAME} ch347.c spi-op.cpp main.cpp misc.cpp spi_flash.cpp spi_ids.cpp stdafx.cpp)
set_property(TARGET ${EXE_NAME} PROPERTY C_STANDARD 99)

include(CMakePrintHelpers)
cmake_print_variables(libusb-1.0_INCLUDE_DIRS)
cmake_print_variables(libusb-1.0_LINK_LIBRARIES)

target_link_libraries(${EXE_NAME}  ${libusb-1.0_LINK_LIBRARIES})
#target_link_libraries(${EXE_NAME}  PkgConfig::libusb-1.0)

在编译项目时,常常需要打印环境变量,不同的版本间, 定义也不一致

bash 复制代码
include(CMakePrintHelpers)
cmake_print_variables(libusb-1.0_INCLUDE_DIRS)
cmake_print_variables(libusb-1.0_LINK_LIBRARIES)

引入工具可以节省许多时间

libusb1.0 not found

bash 复制代码
ss@SSdeiMac ch347-nor-prog % brew list libusb
/usr/local/Cellar/libusb/1.0.27/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.27/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.27/lib/pkgconfig/libusb-1.0.pc
/usr/local/Cellar/libusb/1.0.27/lib/ (2 other files)
/usr/local/Cellar/libusb/1.0.27/sbom.spdx.json
/usr/local/Cellar/libusb/1.0.27/share/libusb/ (9 files)

依赖管理很方便

bash 复制代码
ss@SSdeiMac ch347-nor-prog % cmake .
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- libusb-1.0_INCLUDE_DIRS="/usr/local/Cellar/libusb/1.0.27/include/libusb-1.0"
-- libusb-1.0_LINK_LIBRARIES="/usr/local/Cellar/libusb/1.0.27/lib/libusb-1.0.dylib"
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/ss/Desktop/ch347-nor-prog
相关推荐
Johny_Zhao7 小时前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
blasit15 小时前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
肆忆_2 天前
# 用 5 个问题学懂 C++ 虚函数(入门级)
c++
chlk1232 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑2 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件2 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
不想写代码的星星2 天前
虚函数表:C++ 多态背后的那个男人
c++
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI3 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github