Features: - Cross-platform support (Windows/Linux/macOS) - CAN and CANFD protocol support - USB communication (WinUSB/libusb) - Device management and configuration - Message transmission and reception - Filter configuration - CMake build system - Comprehensive examples and tests
54 lines
983 B
CMake
54 lines
983 B
CMake
/**
|
|
* @file CMakeLists.txt
|
|
* @brief 测试目录构建文件
|
|
*/
|
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
project(usb2can_tests)
|
|
|
|
# 设置C++标准
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# 添加USB2CAN库
|
|
add_subdirectory(..)
|
|
|
|
# 查找需要的包
|
|
find_package(Threads REQUIRED)
|
|
|
|
# 添加测试源文件
|
|
set(TEST_SOURCES
|
|
main.cpp
|
|
test_platform.cpp
|
|
test_usb.cpp
|
|
test_can.cpp
|
|
test_device.cpp
|
|
test_api.cpp
|
|
)
|
|
|
|
# 创建测试可执行文件
|
|
add_executable(usb2can_tests ${TEST_SOURCES})
|
|
|
|
# 链接USB2CAN库
|
|
target_link_libraries(usb2can_tests
|
|
PRIVATE
|
|
usb2can
|
|
Threads::Threads
|
|
)
|
|
|
|
# 添加包含目录
|
|
target_include_directories(usb2can_tests
|
|
PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
|
)
|
|
|
|
# 设置输出目录
|
|
set_target_properties(usb2can_tests PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/tests
|
|
)
|
|
|
|
# 启用测试
|
|
enable_testing()
|
|
|
|
# 添加测试
|
|
add_test(NAME usb2can_tests COMMAND usb2can_tests) |