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
相关推荐
小丑西瓜6661 小时前
CMake基础用法,cmake_minimum_required,project,add_executable
linux·服务器·c++·camke
晚风吹长发1 小时前
初步了解Linux中的命名管道及简单应用和简单日志
linux·运维·服务器·开发语言·数据结构·c++·算法
fpcc1 小时前
设计心得——隔离隐藏的初步实践
c++
C++ 老炮儿的技术栈1 小时前
不调用C++/C的字符串库函数,编写函数strcpy
c语言·开发语言·c++·windows·git·postman·visual studio
大熊背1 小时前
多核架构中,RTOS小核跑sensor 的normal模式,大核linux核跑WDR模式,将小核的曝光时间映射到WDR模式中的曝光时间的方法
linux·自动曝光·wdr
fyzy2 小时前
C++写后端实现,实现前后端分离
开发语言·c++
全栈测试笔记2 小时前
异步函数与异步生成器
linux·服务器·前端·数据库·python
weixin_462446232 小时前
Linux 下使用 xfreerdp3 远程连接 Windows(从安装到实战使用)
linux·运维·windows
EndingCoder2 小时前
配置 tsconfig.json:高级选项
linux·前端·ubuntu·typescript·json
CSDN_RTKLIB2 小时前
C++谓词
c++·stl