CMakeLists.txt 2.72 KB
cmake_minimum_required(VERSION 3.0)
LIST( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
include(projectheader)
project_header(qmqtt)

option( ${PROJECT_NAME}_SHARED "Build a shared library.  Turn off for static." ON )
option( ${PROJECT_NAME}_WEBSOCKETS "Enable WebSockets for MQTT" OFF )
option( ${PROJECT_NAME}_SSL "Enable SSL support for MQTT" OFF )

set( ws_component )
set( ws_libname )
set( qt5_min_version "5.3.0" )

if ( ${PROJECT_NAME}_WEBSOCKETS )
    set( ws_component WebSockets )
    set( ws_libname   Qt5::WebSockets )
    set( qt5_min_version "5.7.0" )
endif()

if ( NOT ${PROJECT_NAME}_SSL)
    set( ssl_defs QT_NO_SSL )
endif()

find_package( Qt5 ${qt5_min_version} COMPONENTS Core Network ${ws_component} CONFIG REQUIRED )

include_directories( SYSTEM
    ${Qt5Core_INCLUDE_DIRS}
    ${Qt5Network_INCLUDE_DIRS}
    ${Qt5WebSockets_INCLUDE_DIRS}
    ${CMAKE_CURRENT_SOURCE_DIR}/../submodules/logutils/src
)

# include(compiler)

set( SRC_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_states.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_configsettings.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_pubsubclient.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_client_p.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_client.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_frame.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_message.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_network.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_routesubscription.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_router.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_socket.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_timer.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_websocket.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_websocketiodevice.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_ssl_socket.cpp
)

include(qtmoc)
create_mocs( SRC_LIST MOC_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_client.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_pubsubclient.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_routesubscription.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_router.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_networkinterface.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_socketinterface.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_timerinterface.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_network_p.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_socket_p.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_timer_p.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_websocket_p.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_websocketiodevice_p.h
    ${CMAKE_CURRENT_SOURCE_DIR}/qmqtt_ssl_socket_p.h
)

link_directories(
    ${CMAKE_BINARY_DIR}/lib
)

include(library)
add_libraries(
    ${Qt5Core_LIBRARIES}
    ${Qt5Network_LIBRARIES}
    ${Qt5WebSocket_LIBRARIES}
)

include(installation)
install_component()