map/das-dn/CMakeLists.txt

279 lines
8.6 KiB
CMake
Raw Normal View History

2024-11-15 16:12:14 +08:00
cmake_minimum_required (VERSION 3.20)
2024-07-08 10:27:17 +08:00
project (application C CXX)
set (VERSION 1.0.1)
2024-11-15 16:12:14 +08:00
# 指定C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
2024-07-08 10:27:17 +08:00
2024-11-15 16:12:14 +08:00
option (USE_MQTT "use mqtt protocol" OFF)
2024-12-03 20:27:52 +08:00
option (USE_CRYPTO "use own crypto" OFF)
option (USE_UUID "use uuid lib" OFF)
2024-10-15 14:10:59 +08:00
option (USE_WEBSOCKET "use websocket" ON)
2024-07-08 10:27:17 +08:00
option (USE_SQLITE3 "use sqlite3" ON)
2024-12-03 10:36:06 +08:00
option (USE_ADS "use ads" ON)
2024-07-08 10:27:17 +08:00
if (USE_SQLITE3)
2024-10-14 20:26:21 +08:00
option (USE_SQLITE_CONFIG "use sqlite config" OFF)
2024-07-08 10:27:17 +08:00
if (USE_SQLITE_CONFIG)
add_definitions(-DUSE_SQLITE_CONFIG)
message (STATUS "Using sqlite3 config file.")
endif ()
endif ()
2025-01-10 09:12:01 +08:00
# set (CMAKE_BUILD_TYPE Release)
2024-12-03 10:36:06 +08:00
2024-07-08 10:27:17 +08:00
option (USE_32BITS "Build 32Bits application?" OFF)
if (USE_32BITS)
message (STATUS "Using 32Bits Platform: ${CMAKE_SYSTEM_PROCESSOR} host: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
add_compile_options (-m32)
add_link_options (-m32)
endif()
add_definitions(-DUSE_32BITS)
else ()
message (STATUS "Using 64Bits Platform")
add_definitions(-DNOPOLL_64BIT_PLATFORM)
endif (USE_32BITS)
2024-12-26 14:54:03 +08:00
2024-07-08 10:27:17 +08:00
if (CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_compile_options ("-O0")
add_compile_options ("-Wall")
message("Debug mode:${CMAKE_C_FLAGS_DEBUG}")
elseif (CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
add_compile_options ("-O3")
add_compile_options ("-Wall")
message ("Release mode:${CMAKE_C_FLAGS_RELEASE}")
else ()
message ("else:${CMAKE_BUILD_TYPE}")
message ("else:${CMAKE_C_FLAGS_RELEASE}")
endif()
2024-12-03 10:36:06 +08:00
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Target platform is 32-bit.")
add_definitions(-DUSE_32BITS)
else()
message(STATUS "Target platform is 64-bit.")
endif()
2024-07-08 10:27:17 +08:00
2024-11-15 16:12:14 +08:00
find_package(miniocpp REQUIRED)
2024-11-20 15:43:54 +08:00
set (APP_LIBS ${APP_LIBS} miniocpp::miniocpp)
2024-11-15 16:12:14 +08:00
2024-07-08 10:27:17 +08:00
include_directories (
inc
inc/json
2024-12-03 20:27:52 +08:00
cmg)
2024-07-08 10:27:17 +08:00
set (APP_SRCS
cmg/main.cpp
cmg/changemaster.cpp
2024-10-14 20:26:21 +08:00
cmg/ry.cpp
2024-12-03 10:36:06 +08:00
comm/ryFileDef.cpp
2024-07-08 10:27:17 +08:00
comm/process.cpp
comm/netproc.cpp
comm/portproc.cpp
comm/public.cpp
comm/soe.cpp
comm/ycbw.cpp
comm/yklog.cpp
comm/ytlog.cpp
comm/yxbw.cpp
comm/iec104.cpp
hostiec104/host_iec104.cpp
hostmodbusrtu/host_modbus_rtu.cpp
hostmodbustcp/host_modbus_tcp.cpp
2024-11-20 15:43:54 +08:00
hostmodbustcpbf/host_modbus_tcp_bf.cpp
2024-07-08 10:27:17 +08:00
rtustatusproc/rtustatus.cpp
subiec104/sub_iec104.cpp
2024-11-20 15:43:54 +08:00
submodbustcp/sub_modbus_tcp.cpp
2024-07-08 10:27:17 +08:00
zjd3100proc/zjd3100pro.cpp
2024-11-15 16:12:14 +08:00
minio/ftp2minio.cpp
2024-07-08 10:27:17 +08:00
)
set (APP_SRCS ${APP_SRCS}
third_party/json/jsoncpp.cpp)
2024-12-03 20:27:52 +08:00
if (USE_CRYPTO)
include_directories (inc/crypto)
set (APP_SRCS ${APP_SRCS}
third_party/base64/base64.c
third_party/md5/md5.c
third_party/aes/aes.c
third_party/aes/error.c
third_party/aes/platform_util.c)
endif ()
2024-07-08 10:27:17 +08:00
2024-12-03 20:27:52 +08:00
if (USE_UUID)
include_directories (inc/uuid)
set (APP_SRCS ${APP_SRCS}
third_party/uuid/clear.c
third_party/uuid/compare.c
third_party/uuid/copy.c
third_party/uuid/gen_uuid.c
third_party/uuid/isnull.c
third_party/uuid/pack.c
third_party/uuid/parse.c
third_party/uuid/unpack.c
third_party/uuid/unparse.c
third_party/uuid/uuid_time.c
third_party/uuid/randutils.c)
endif ()
2024-07-08 10:27:17 +08:00
set (APP_SRCS ${APP_SRCS}
third_party/zlog/buf.c
third_party/zlog/category_table.c
third_party/zlog/category.c
third_party/zlog/conf.c
third_party/zlog/event.c
third_party/zlog/format.c
third_party/zlog/level_list.c
third_party/zlog/level.c
third_party/zlog/mdc.c
third_party/zlog/record_table.c
third_party/zlog/record.c
third_party/zlog/rotater.c
third_party/zlog/rule.c
third_party/zlog/spec.c
third_party/zlog/thread.c
third_party/zlog/zc_arraylist.c
third_party/zlog/zc_hashtable.c
third_party/zlog/zc_profile.c
third_party/zlog/zc_util.c
third_party/zlog/zlog.c)
if (USE_WEBSOCKET)
2024-12-03 20:27:52 +08:00
option (USE_NOPOLL "use nopoll websocket lib" OFF)
if (USE_NOPOLL)
include_directories (inc/nopoll)
set (APP_SRCS ${APP_SRCS}
third_party/nopoll/nopoll.c
third_party/nopoll/nopoll_conn.c
third_party/nopoll/nopoll_conn_opts.c
third_party/nopoll/nopoll_listener.c
third_party/nopoll/nopoll_ctx.c
third_party/nopoll/nopoll_decl.c
third_party/nopoll/nopoll_io.c
third_party/nopoll/nopoll_log.c
third_party/nopoll/nopoll_msg.c)
add_definitions(-DUSE_WEBSOCKET)
add_definitions(-DNOPOLL_OS_UNIX=1)
add_definitions(-DSHOW_DEBUG_LOG)
add_definitions(-DNOPOLL_HAVE_VASPRINTF=1)
add_definitions(-DNOPOLL_HAVE_TLSv10_ENABLED=1)
add_definitions(-DNOPOLL_HAVE_TLSv11_ENABLED=1)
add_definitions(-DNOPOLL_HAVE_TLSv12_ENABLED=1)
add_definitions(-DNOPOLL_HAVE_TLS_FLEXIBLE_ENABLED=1)
else ()
include_directories (inc/websockets)
set (APP_SRCS ${APP_SRCS}
third_party/websockets/easywsclient.cpp
)
endif ()
2024-07-08 10:27:17 +08:00
set (APP_LIBS ${APP_LIBS} ssl crypto)
endif ()
2024-12-03 10:36:06 +08:00
if (USE_ADS)
add_definitions(-DCONFIG_DEFAULT_LOGLEVEL=1)
include_directories (third_party/AdsLib)
set (APP_SRCS ${APP_SRCS} hostadsbf/hostadsbf.cpp)
set (APP_SRCS ${APP_SRCS}
third_party/AdsLib/AdsDef.cpp
third_party/AdsLib/AdsDevice.cpp
third_party/AdsLib/AdsFile.cpp
third_party/AdsLib/AdsLib.cpp
third_party/AdsLib/ECatAccess.cpp
third_party/AdsLib/Frame.cpp
third_party/AdsLib/LicenseAccess.cpp
third_party/AdsLib/Log.cpp
third_party/AdsLib/RouterAccess.cpp
third_party/AdsLib/RTimeAccess.cpp
third_party/AdsLib/Sockets.cpp
third_party/AdsLib/RegistryAccess.cpp
third_party/AdsLib/SymbolAccess.cpp
2024-12-05 11:04:47 +08:00
# third_party/AdsLib/Beckhoff/ParameterList.cpp
2024-12-03 10:36:06 +08:00
third_party/AdsLib/Standalone/AdsLib.cpp
third_party/AdsLib/Standalone/AmsConnection.cpp
third_party/AdsLib/Standalone/AmsNetId.cpp
third_party/AdsLib/Standalone/AmsPort.cpp
third_party/AdsLib/Standalone/AmsRouter.cpp
third_party/AdsLib/Standalone/NotificationDispatcher.cpp
)
endif ()
2024-07-08 10:27:17 +08:00
if (USE_MQTT)
2024-12-03 20:27:52 +08:00
include_directories (inc/mqtt)
2024-07-08 10:27:17 +08:00
set(APP_SRCS ${APP_SRCS}
2024-08-09 08:50:19 +08:00
third_party/mqtt/actions.c
third_party/mqtt/callbacks.c
third_party/mqtt/connect.c
third_party/mqtt/handle_auth.c
third_party/mqtt/handle_connack.c
third_party/mqtt/handle_disconnect.c
third_party/mqtt/handle_ping.c
third_party/mqtt/handle_pubackcomp.c
third_party/mqtt/handle_publish.c
third_party/mqtt/handle_pubrec.c
third_party/mqtt/handle_pubrel.c
third_party/mqtt/handle_suback.c
third_party/mqtt/handle_unsuback.c
third_party/mqtt/helpers.c
third_party/mqtt/logging_mosq.c
third_party/mqtt/loop.c
third_party/mqtt/memory_mosq.c
third_party/mqtt/messages_mosq.c
third_party/mqtt/misc_mosq.c
third_party/mqtt/mosquitto.c
third_party/mqtt/net_mosq_ocsp.c
third_party/mqtt/net_mosq.c
third_party/mqtt/options.c
third_party/mqtt/packet_datatypes.c
third_party/mqtt/packet_mosq.c
third_party/mqtt/property_mosq.c
third_party/mqtt/read_handle.c
third_party/mqtt/send_connect.c
third_party/mqtt/send_disconnect.c
third_party/mqtt/send_mosq.c
third_party/mqtt/send_publish.c
third_party/mqtt/send_subscribe.c
third_party/mqtt/send_unsubscribe.c
third_party/mqtt/send_mosq.c
third_party/mqtt/socks_mosq.c
third_party/mqtt/srv_mosq.c
third_party/mqtt/strings_mosq.c
third_party/mqtt/thread_mosq.c
third_party/mqtt/time_mosq.c
third_party/mqtt/tls_mosq.c
third_party/mqtt/utf8_mosq.c
third_party/mqtt/util_mosq.c
third_party/mqtt/util_topic.c
third_party/mqtt/will_mosq.c)
2024-07-08 10:27:17 +08:00
# set (APP_SRCS ${APP_SRCS} hwmqtt/hwmqtt.cpp)
add_definitions(-DUSE_MQTT)
add_definitions(-DWITH_SOCKS)
add_definitions(-DWITH_THREADING)
add_definitions(-DWITH_UNIX_SOCKETS)
# add_definitions(-DWITH_TLS)
# add_definitions(-DWITH_TLS_PSK)
endif (USE_MQTT)
if (USE_SQLITE3)
2024-12-03 20:27:52 +08:00
include_directories (inc/sqlite)
2024-07-08 10:27:17 +08:00
set (APP_SRCS ${APP_SRCS}
third_party/sqlite/KompexSQLiteBlob.cpp
third_party/sqlite/KompexSQLiteDatabase.cpp
third_party/sqlite/KompexSQLiteStatement.cpp
third_party/sqlite/sqlite3.c)
add_definitions(-DUSE_SQLITE3)
endif ()
include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
link_directories (${LINK_DIR})
2024-11-20 15:43:54 +08:00
set (APP_LIBS ${APP_LIBS} pthread)
set (APP_LIBS ${APP_LIBS} dl)
set (APP_LIBS ${APP_LIBS} rt)
2024-07-08 10:27:17 +08:00
2024-10-21 10:53:15 +08:00
#add_link_options (-static)
2024-07-08 10:27:17 +08:00
add_executable (application ${APP_SRCS})
target_link_libraries (application ${APP_LIBS})
2024-10-31 14:32:23 +08:00