-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
130 lines (112 loc) · 4.26 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.2.0)
project(radio_tool VERSION 0.2.2)
option(BUILD_TESTING "Enable tests" OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
if(NOT CMAKE_GENERATOR_PLATFORM)
set(CMAKE_GENERATOR_PLATFORM x64)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#Git version
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_describe(GIT_SHA1_SHORT "--always")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp" @ONLY)
#FindLIBUSB
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
find_package(LibUSB REQUIRED)
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(VCPKG_INCLUDE_DIR $ENV{VCPKG_ROOT}\\installed\\${CMAKE_GENERATOR_PLATFORM}-windows\\include)
if(${CMAKE_BUILD_TYPE_LOWER} STREQUAL release)
set(VCPKG_LIB_DIR $ENV{VCPKG_ROOT}\\installed\\${CMAKE_GENERATOR_PLATFORM}-windows\\lib)
elseif (${CMAKE_BUILD_TYPE_LOWER} STREQUAL debug)
set(VCPKG_LIB_DIR $ENV{VCPKG_ROOT}\\installed\\${CMAKE_GENERATOR_PLATFORM}-windows\\debug\\lib)
endif()
message("-- VCPKG include dir: ${VCPKG_INCLUDE_DIR}")
message("-- VCPKG lib dir: ${VCPKG_LIB_DIR}")
add_definitions(-DNOMINMAX -DVC_EXTRALEAN -DWIN32_LEAN_AND_MEAN)
endif()
if(BUILD_TESTING)
include(CTest)
enable_testing()
add_subdirectory(test)
endif()
set(ALL_SRC
src/radio_tool.cpp
src/dfu.cpp
src/h8sx.cpp
src/radio_factory.cpp
src/usb_radio_factory.cpp
src/serial_radio_factory.cpp
src/tyt_radio.cpp
src/ymodem_device.cpp
src/tyt_dfu.cpp
src/tyt_fw.cpp
src/tyt_fw_sgl.cpp
src/cs_fw.cpp
src/ailunce_radio.cpp
src/ailunce_fw.cpp
src/yaesu_radio.cpp
src/yaesu_fw.cpp
src/fymodem.c
src/rdt.cpp
src/hid.cpp
src/tyt_hid.cpp
src/tyt_sgl_radio.cpp
"${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp"
)
file(GLOB_RECURSE ALL_HEADERS include false "*.h*")
add_library(radiotool ${ALL_SRC} ${ALL_HEADERS})
target_include_directories(radiotool PUBLIC include)
add_executable(radio_tool src/radio_tool.cpp)
target_include_directories(radio_tool PUBLIC include)
target_link_libraries(radio_tool radiotool)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
target_link_libraries(radiotool pthread)
target_link_libraries(radiotool PkgConfig::LibUSB)
target_link_libraries(radio_tool PkgConfig::LibUSB)
target_include_directories(radiotool PUBLIC ${LibUSB_INCLUDEDIR})
target_include_directories(radio_tool PUBLIC ${LibUSB_INCLUDEDIR})
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
target_include_directories(radiotool PUBLIC ${VCPKG_INCLUDE_DIR})
target_link_directories(radiotool PRIVATE ${VCPKG_LIB_DIR})
target_include_directories(radio_tool PUBLIC ${VCPKG_INCLUDE_DIR})
target_link_directories(radio_tool PRIVATE ${VCPKG_LIB_DIR})
target_link_libraries(radiotool libusb-1.0)
target_link_libraries(radio_tool libusb-1.0)
endif()
if(XOR_TOOL_INC)
if (EXISTS "${XOR_TOOL_INC}/xor_tool.hpp")
message("-- XOR Tool found")
add_definitions(-DXOR_TOOL)
include_directories(${XOR_TOOL_INC})
else()
message(SEND_ERROR "xor_tool.hpp not found (Make sure to specifiy an absolute path)")
endif()
endif()
install(TARGETS radio_tool RUNTIME DESTINATION bin)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION "Universal radio firmware tool")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/v0l/radio_tool")
set(CPACK_PACKAGE_CONTACT "v0l <radio_tool@v0l.io>")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
set(CPACK_GENERATOR "DragNDrop")
else()
set(CPACK_GENERATOR "DEB" "TGZ" "TXZ")
endif()
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_STRIP_FILES true)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0")
set(CPACK_DEBIAN_PACKAGE_SECTION "hamradio")
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
include(CPack)