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
相关推荐
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
apocelipes1 天前
常用编程语言和库的正则表达式性能对比
c语言·c++·python·性能优化·golang·开发工具和环境
用户120487221611 天前
Linux驱动编译与加载
linux·嵌入式
用户805533698031 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
郝学胜_神的一滴2 天前
CMake 034:生成器表达式:解耦构建时序、精简分支逻辑的终极利器
c++·cmake
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux
见过夏天3 天前
C++ 基础入门完全指南
c++