建立 MAG160C 逆向工程交接仓库
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(mag160c LANGUAGES C CXX)
|
||||
|
||||
option(MAG160C_BUILD_TESTS "Build MAG160C tests" ON)
|
||||
option(MAG160C_BUILD_CLI "Build MAG160C CLI tools" ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(LIBUSB QUIET libusb-1.0)
|
||||
endif()
|
||||
|
||||
if(MAG160C_BUILD_CLI)
|
||||
add_executable(mag160c-cli tools/mag160c_cli.cpp)
|
||||
target_link_libraries(mag160c-cli PRIVATE mag160c_core)
|
||||
endif()
|
||||
|
||||
add_library(mag160c_core SHARED
|
||||
src/core/error.cpp
|
||||
src/core/context.cpp
|
||||
src/core/tcm_frame.cpp
|
||||
src/core/tcm_device.cpp
|
||||
src/core/device.cpp
|
||||
src/core/ir_device.cpp
|
||||
src/core/ir_frame.cpp
|
||||
src/c_api.cpp
|
||||
)
|
||||
|
||||
target_include_directories(mag160c_core
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
target_compile_definitions(mag160c_core PRIVATE MAG160C_BUILDING_LIBRARY)
|
||||
|
||||
if(LIBUSB_FOUND)
|
||||
set(MAG160C_HAS_LIBUSB_VALUE 1)
|
||||
target_compile_definitions(mag160c_core PRIVATE MAG160C_HAS_LIBUSB=1)
|
||||
target_include_directories(mag160c_core PRIVATE ${LIBUSB_INCLUDE_DIRS})
|
||||
target_link_directories(mag160c_core PRIVATE ${LIBUSB_LIBRARY_DIRS})
|
||||
target_link_libraries(mag160c_core PRIVATE ${LIBUSB_LIBRARIES})
|
||||
target_compile_options(mag160c_core PRIVATE ${LIBUSB_CFLAGS_OTHER})
|
||||
else()
|
||||
set(MAG160C_HAS_LIBUSB_VALUE 0)
|
||||
target_compile_definitions(mag160c_core PRIVATE MAG160C_HAS_LIBUSB=0)
|
||||
endif()
|
||||
|
||||
if(MAG160C_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
add_executable(test_c_api tests/cpp/test_c_api.cpp)
|
||||
target_link_libraries(test_c_api PRIVATE mag160c_core)
|
||||
target_compile_definitions(test_c_api PRIVATE MAG160C_HAS_LIBUSB=${MAG160C_HAS_LIBUSB_VALUE})
|
||||
|
||||
add_test(NAME test_c_api COMMAND test_c_api)
|
||||
|
||||
add_executable(test_tcm_frame tests/cpp/test_tcm_frame.cpp)
|
||||
target_link_libraries(test_tcm_frame PRIVATE mag160c_core)
|
||||
target_include_directories(test_tcm_frame PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
add_test(NAME test_tcm_frame COMMAND test_tcm_frame)
|
||||
|
||||
add_executable(test_tcm_device tests/cpp/test_tcm_device.cpp)
|
||||
target_link_libraries(test_tcm_device PRIVATE mag160c_core)
|
||||
target_include_directories(test_tcm_device PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
add_test(NAME test_tcm_device COMMAND test_tcm_device)
|
||||
|
||||
add_executable(test_device_model tests/cpp/test_device_model.cpp)
|
||||
target_link_libraries(test_device_model PRIVATE mag160c_core)
|
||||
target_include_directories(test_device_model PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
add_test(NAME test_device_model COMMAND test_device_model)
|
||||
|
||||
add_executable(test_ir_skeleton tests/cpp/test_ir_skeleton.cpp)
|
||||
target_link_libraries(test_ir_skeleton PRIVATE mag160c_core)
|
||||
|
||||
add_test(NAME test_ir_skeleton COMMAND test_ir_skeleton)
|
||||
|
||||
add_executable(test_ir_frame tests/cpp/test_ir_frame.cpp)
|
||||
target_link_libraries(test_ir_frame PRIVATE mag160c_core)
|
||||
target_include_directories(test_ir_frame PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
add_test(NAME test_ir_frame COMMAND test_ir_frame)
|
||||
endif()
|
||||
Reference in New Issue
Block a user