CMakeLists.txt modifications

This commit is contained in:
Korina Šimičević
2024-01-03 14:54:25 +01:00
committed by Ivica Siladić
parent 6abe93fcc9
commit 6f5c179929
5 changed files with 45 additions and 41 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project(async-mqtt5 VERSION 0.0.1 LANGUAGES NONE) project(async-mqtt5 VERSION 0.0.1 LANGUAGES CXX)
include(cmake/project-is-top-level.cmake) include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake) include(cmake/variables.cmake)
@ -19,10 +19,13 @@ target_include_directories(
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
) )
target_compile_features(async_mqtt5 INTERFACE cxx_std_20) target_compile_features(async_mqtt5 INTERFACE cxx_std_17)
find_package(Boost 1.82 REQUIRED) find_package(Boost 1.82 REQUIRED)
target_link_libraries(async_mqtt5 INTERFACE Boost::headers) target_link_libraries(async_mqtt5
INTERFACE
Boost::headers
)
if(NOT CMAKE_SKIP_INSTALL_RULES) if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/install-rules.cmake) include(cmake/install-rules.cmake)

View File

@ -5,30 +5,27 @@ project(async-mqtt5-examples CXX)
include(../cmake/project-is-top-level.cmake) include(../cmake/project-is-top-level.cmake)
if(PROJECT_IS_TOP_LEVEL) if(PROJECT_IS_TOP_LEVEL)
find_package(async_mqtt5 REQUIRED) find_package(async-mqtt5 REQUIRED)
endif() endif()
function(add_example name) function(add_example name)
add_executable("${name}" ${ARGN}) add_executable("${name}" ${ARGN})
target_compile_features("${name}" PRIVATE cxx_std_20) target_compile_features("${name}" PRIVATE cxx_std_20) # for coroutines
target_link_libraries("${name}" PRIVATE Async::MQTT5) target_link_libraries("${name}" PRIVATE Async::MQTT5)
endfunction() endfunction()
foreach(f callbacks cpp20_coroutines futures publisher receiver) foreach(f publisher receiver)
add_example("${f}" "${f}.cpp") add_example("${f}" "${f}.cpp")
endforeach() endforeach()
#[[ set(EXAMPLES
add_example(
misc
src/run_examples.cpp
network_connection.cpp
openssl-tls.cpp
tcp.cpp tcp.cpp
websocket-tcp.cpp openssl_tls.cpp
websocket-tls.cpp websocket_tcp.cpp
websocket_tls.cpp
) )
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
target_link_libraries(misc PRIVATE OpenSSL::SSL) add_executable(examples src/run_examples.cpp ${EXAMPLES})
]] target_compile_features(examples PRIVATE cxx_std_17)
target_link_libraries(examples PRIVATE Async::MQTT5 OpenSSL::SSL)

View File

@ -5,7 +5,7 @@ project(async-mqtt5-tests CXX)
include(../../cmake/project-is-top-level.cmake) include(../../cmake/project-is-top-level.cmake)
if(PROJECT_IS_TOP_LEVEL) if(PROJECT_IS_TOP_LEVEL)
find_package(async_mqtt5 REQUIRED) find_package(async-mqtt5 REQUIRED)
enable_testing() enable_testing()
endif() endif()
@ -14,16 +14,20 @@ add_executable(
src/run_tests.cpp src/run_tests.cpp
test/cancellation.cpp test/cancellation.cpp
test/client_broker.cpp test/client_broker.cpp
test/compilation_checks.cpp
test/coroutine.cpp test/coroutine.cpp
test/publish_send_op.cpp test/publish_send_op.cpp
test/serialization.cpp test/serialization.cpp
test/session.cpp test/session.cpp
test/string_validation.cpp
test/subscribe_op.cpp
) )
target_include_directories(mqtt-test PRIVATE include) target_include_directories(mqtt-test PRIVATE include)
target_compile_features(mqtt-test PRIVATE cxx_std_20) target_compile_features(mqtt-test PRIVATE cxx_std_17)
target_compile_definitions(mqtt-test PRIVATE BOOST_TEST_NO_MAIN=1)
find_package(Boost 1.82 REQUIRED unit_test_framework) find_package(OpenSSL)
target_link_libraries(mqtt-test PRIVATE Async::MQTT5 Boost::unit_test_framework) target_link_libraries(mqtt-test PRIVATE Async::MQTT5 OpenSSL::SSL)
add_test(NAME mqtt-test COMMAND mqtt-test) add_test(NAME mqtt-test COMMAND mqtt-test)

View File

@ -1,30 +1,17 @@
#include <boost/test/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
#include <test_common/protocol_logging.hpp> #include <test_common/protocol_logging.hpp>
namespace { boost::unit_test::test_suite* init_tests(
int /*argc*/, char* /*argv*/[]
void setup_mqtt() { ) {
async_mqtt5::test::logging_enabled() = true; async_mqtt5::test::logging_enabled() = true;
} return nullptr;
}
#ifdef BOOST_TEST_DYN_LINK
static bool init_tests() {
setup_mqtt();
return true;
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
return boost::unit_test::unit_test_main(&init_tests, argc, argv); return boost::unit_test::unit_test_main(&init_tests, argc, argv);
} }
#else
boost::unit_test::test_suite* init_unit_test_suite(int, char** const) {
setup_mqtt();
return nullptr;
}
#endif
/* /*
* usage: ./mqtt-test [boost test --arg=val]* * usage: ./mqtt-test [boost test --arg=val]*

View File

@ -19,5 +19,18 @@
} }
] ]
} }
} },
"vcpkg-configuration": {
"default-registry": {
"kind": "git",
"repository": "https://github.com/microsoft/vcpkg",
"baseline": "4cac260c4b7331538d31886f57739fea0bffa27e"
}
},
"overrides": [
{
"name": "openssl",
"version-string": "1.1.1n"
}
]
} }