Skip to content

Commit bddc71b

Browse files
committed
First commit.
0 parents  commit bddc71b

76 files changed

Lines changed: 5635 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
cmake_minimum_required (VERSION 3.10)
2+
project ("cc_mqtt5_cc_tools_qt_plugin")
3+
4+
# Configuration variables
5+
# OPT_QT_MAJOR_VERSION - The major Qt version, defaults to 5
6+
7+
######################################################################
8+
9+
if ("${OPT_QT_MAJOR_VERSION}" STREQUAL "")
10+
set(OPT_QT_MAJOR_VERSION 5)
11+
endif()
12+
13+
if ("${CMAKE_CXX_STANDARD}" STREQUAL "")
14+
set(CMAKE_CXX_STANDARD 17)
15+
endif()
16+
17+
if ("${CMAKE_CXX_STANDARD}" VERSION_LESS "17")
18+
message (FATAL_ERROR "Use C++17 or later (instead of C++${CMAKE_CXX_STANDARD}) to compile this project.")
19+
endif()
20+
21+
find_package(LibComms REQUIRED)
22+
find_package(cc_mqtt5 REQUIRED)
23+
find_package(cc_tools_qt REQUIRED)
24+
find_package(Qt${OPT_QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Core)
25+
26+
set (CMAKE_AUTOMOC ON)
27+
set (CMAKE_AUTOUIC ON)
28+
set (CMAKE_AUTORCC ON)
29+
30+
include(${LibComms_DIR}/CC_Compile.cmake)
31+
cc_compile(WARN_AS_ERR)
32+
cc_msvc_force_warn_opt(/W4)
33+
34+
include(GNUInstallDirs)
35+
36+
set (CORE_LIB_NAME "cc_tools_qt_plugin_cc_mqtt5_protocol_core")
37+
38+
######################################################################
39+
40+
function (cc_plugin_core)
41+
set (name ${CORE_LIB_NAME})
42+
set (src
43+
cc_tools_qt_plugin/cc_mqtt5/field/BinData.cpp
44+
cc_tools_qt_plugin/cc_mqtt5/field/EnableEnum.cpp
45+
cc_tools_qt_plugin/cc_mqtt5/field/Length.cpp
46+
cc_tools_qt_plugin/cc_mqtt5/field/MsgId.cpp
47+
cc_tools_qt_plugin/cc_mqtt5/field/PacketId.cpp
48+
cc_tools_qt_plugin/cc_mqtt5/field/PropertiesList.cpp
49+
cc_tools_qt_plugin/cc_mqtt5/field/Property.cpp
50+
cc_tools_qt_plugin/cc_mqtt5/field/ProtocolName.cpp
51+
cc_tools_qt_plugin/cc_mqtt5/field/Qos.cpp
52+
cc_tools_qt_plugin/cc_mqtt5/field/ReasonCode.cpp
53+
cc_tools_qt_plugin/cc_mqtt5/field/String.cpp
54+
cc_tools_qt_plugin/cc_mqtt5/field/Topic.cpp
55+
cc_tools_qt_plugin/cc_mqtt5/field/VarLenInt.cpp
56+
cc_tools_qt_plugin/cc_mqtt5/message/Auth.cpp
57+
cc_tools_qt_plugin/cc_mqtt5/message/Connack.cpp
58+
cc_tools_qt_plugin/cc_mqtt5/message/Connect.cpp
59+
cc_tools_qt_plugin/cc_mqtt5/message/Disconnect.cpp
60+
cc_tools_qt_plugin/cc_mqtt5/message/Pingreq.cpp
61+
cc_tools_qt_plugin/cc_mqtt5/message/Pingresp.cpp
62+
cc_tools_qt_plugin/cc_mqtt5/message/Puback.cpp
63+
cc_tools_qt_plugin/cc_mqtt5/message/Pubcomp.cpp
64+
cc_tools_qt_plugin/cc_mqtt5/message/Publish.cpp
65+
cc_tools_qt_plugin/cc_mqtt5/message/Pubrec.cpp
66+
cc_tools_qt_plugin/cc_mqtt5/message/Pubrel.cpp
67+
cc_tools_qt_plugin/cc_mqtt5/message/Suback.cpp
68+
cc_tools_qt_plugin/cc_mqtt5/message/Subscribe.cpp
69+
cc_tools_qt_plugin/cc_mqtt5/message/Unsuback.cpp
70+
cc_tools_qt_plugin/cc_mqtt5/message/Unsubscribe.cpp
71+
cc_tools_qt_plugin/cc_mqtt5/Message.cpp
72+
cc_tools_qt_plugin/cc_mqtt5/frame/FrameTransportMessage.cpp
73+
cc_tools_qt_plugin/cc_mqtt5/factory/AllMessagesDynMemMsgFactory.cpp
74+
)
75+
76+
add_library (${name} STATIC ${src})
77+
target_link_libraries (${name} PUBLIC cc::cc_mqtt5 cc::comms cc::cc_tools_qt Qt${OPT_QT_MAJOR_VERSION}::Widgets Qt${OPT_QT_MAJOR_VERSION}::Core)
78+
target_include_directories (${name} PUBLIC ${PROJECT_SOURCE_DIR})
79+
target_compile_options(${name} PRIVATE
80+
$<$<CXX_COMPILER_ID:MSVC>:/bigobj /wd4127 /wd5054>
81+
$<$<CXX_COMPILER_ID:GNU>:-ftemplate-depth=2048 -fconstexpr-depth=4096 -Wno-unused-local-typedefs>
82+
$<$<CXX_COMPILER_ID:Clang>:-ftemplate-depth=2048 -fconstexpr-depth=4096 -Wno-unused-local-typedefs>
83+
)
84+
85+
endfunction()
86+
87+
######################################################################
88+
89+
function (cc_plugin protocol has_config_widget)
90+
string(TOLOWER "cc_tools_plugin_${protocol}" name)
91+
92+
if (NOT "${name}" MATCHES ".*_protocol$")
93+
string(APPEND name "_protocol")
94+
endif ()
95+
96+
set (meta_file "${CMAKE_CURRENT_SOURCE_DIR}/cc_tools_qt_plugin/cc_mqtt5/plugin/Plugin_${protocol}.json")
97+
set (stamp_file "${CMAKE_CURRENT_BINARY_DIR}/${protocol}_refresh_stamp.txt")
98+
99+
if ((NOT EXISTS ${stamp_file}) OR (${meta_file} IS_NEWER_THAN ${stamp_file}))
100+
execute_process(
101+
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/cc_tools_qt_plugin/cc_mqtt5/plugin/Plugin_${protocol}.h)
102+
103+
execute_process(
104+
COMMAND ${CMAKE_COMMAND} -E touch ${stamp_file})
105+
endif ()
106+
107+
set (src
108+
cc_tools_qt_plugin/cc_mqtt5/plugin/Protocol_${protocol}.cpp
109+
cc_tools_qt_plugin/cc_mqtt5/plugin/Plugin_${protocol}.cpp
110+
cc_tools_qt_plugin/cc_mqtt5/plugin/Plugin_${protocol}.h
111+
)
112+
113+
if (has_config_widget)
114+
list (APPEND src cc_tools_qt_plugin/cc_mqtt5/plugin/ConfigWidget_${protocol}.cpp)
115+
endif ()
116+
117+
set(extra_link_opts)
118+
if (CMAKE_COMPILER_IS_GNUCC)
119+
set(extra_link_opts "-Wl,--no-undefined")
120+
endif ()
121+
122+
add_library (${name} MODULE ${src} ${moc})
123+
target_link_libraries (${name} ${CORE_LIB_NAME} cc::cc_tools_qt Qt${OPT_QT_MAJOR_VERSION}::Widgets Qt${OPT_QT_MAJOR_VERSION}::Core ${extra_link_opts})
124+
target_compile_options(${name} PRIVATE
125+
$<$<CXX_COMPILER_ID:MSVC>:/bigobj /wd4127 /wd5054>
126+
$<$<CXX_COMPILER_ID:GNU>:-ftemplate-depth=2048 -fconstexpr-depth=4096>
127+
$<$<CXX_COMPILER_ID:Clang>:-ftemplate-depth=2048 -fconstexpr-depth=4096>
128+
)
129+
130+
install (
131+
TARGETS ${name}
132+
DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cc_tools_qt/plugin)
133+
134+
install (
135+
FILES cc_tools_qt_plugin/cc_mqtt5/plugin/${protocol}.cfg
136+
DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/cc_tools_qt)
137+
138+
endfunction()
139+
140+
######################################################################
141+
142+
if (TARGET cc::cc_tools_qt)
143+
get_target_property(cc_inc cc::cc_tools_qt INTERFACE_INCLUDE_DIRECTORIES)
144+
145+
if (NOT cc_inc)
146+
message (FATAL_ERROR "No include directories are specified for cc::cc_tools_qt")
147+
endif ()
148+
149+
# Global include is required for "moc"
150+
include_directories (${cc_inc})
151+
endif ()
152+
153+
cc_plugin_core()
154+
155+
cc_plugin ("CC_MQTT_v5" FALSE)

0 commit comments

Comments
 (0)