Blame view

src/CMakeLists.txt 2.71 KB
210d2652   Steven de Ridder   Initial commit.
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
  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}/../logutils
  )
  
  # 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}
      logutils
  )
  
  include(installation)
  install_component()