File: CMakeLists.txt

package info (click to toggle)
paho.mqtt.cpp 1.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,672 kB
  • sloc: cpp: 13,068; ansic: 113; sh: 55; makefile: 22
file content (90 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (2)
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
# CMakeLists.txt
#
# CMake file for the Catch2 unit tests in the Eclipse Paho C++ library.
#

#*******************************************************************************
# Copyright (c) 2019-2023 Frank Pagliughi <fpagliughi@mindspring.com>
#
#  All rights reserved. This program and the accompanying materials
#  are made available under the terms of the Eclipse Public License v2.0
#  and Eclipse Distribution License v1.0 which accompany this distribution. 
# 
#  The Eclipse Public License is available at 
#     http://www.eclipse.org/legal/epl-v20.html
#  and the Eclipse Distribution License is available at 
#    http://www.eclipse.org/org/documents/edl-v10.php.
# 
#  Contributors:
#     Frank Pagliughi - Initial implementation
#*******************************************************************************/

# --- Find Catch2 and figure out which major version ---

find_package(Catch2 REQUIRED)

message(STATUS "Found Catch2 v${Catch2_VERSION}")

if (Catch2_VERSION VERSION_LESS "2.0")
    message(FATAL "Catch2 v2.0 or greater required for tests")
endif()

# --- Executables ---

add_executable(unit_tests unit_tests.cpp
    test_async_client.cpp
    test_buffer_ref.cpp
    test_client.cpp
    test_connect_options.cpp
    test_create_options.cpp
    test_disconnect_options.cpp
    test_exception.cpp
    test_message.cpp
    test_persistence.cpp
    test_properties.cpp
    test_response_options.cpp
    test_string_collection.cpp
    test_subscribe_options.cpp
    test_thread_queue.cpp
    test_token.cpp
    test_topic.cpp
    test_topic_matcher.cpp
    test_will_options.cpp
)

if(PAHO_WITH_SSL)
    target_sources(unit_tests PUBLIC 
        ${CMAKE_CURRENT_SOURCE_DIR}/test_ssl_options.cpp
    )
endif()

set_target_properties(unit_tests PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
    CXX_EXTENSIONS OFF
)

if (Catch2_VERSION VERSION_LESS "3.0")
    target_compile_definitions(unit_tests PUBLIC CATCH2_V2)
endif()

# --- Link for executables ---

target_link_libraries(unit_tests
    Catch2::Catch2
    PahoMqttCpp::paho-mqttpp3
)

if(PAHO_BUILD_SHARED)
    target_compile_definitions(unit_tests PUBLIC PAHO_MQTTPP_IMPORTS)

    if(MSVC AND PAHO_BUILD_STATIC)
        target_link_libraries(unit_tests ${LIBS_SYSTEM})
    endif()
endif()

include(CTest)
include(Catch)

catch_discover_tests(unit_tests)