Skip to content

Commit 442cc55

Browse files
authored
Compatibility tweaks (#78)
1 parent ec46a5e commit 442cc55

5 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/rmq/rmqio/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ target_link_libraries(rmqio PUBLIC
3232
Boost::boost
3333
)
3434

35+
# boost::asio::chrono maps to boost::chrono on platforms without std::chrono
36+
# (e.g. Solaris/C++03, IBM XL). Use header-only mode to avoid needing
37+
# libboost_chrono, and fall back to linking it if available elsewhere.
38+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "XL")
39+
target_compile_definitions(rmqio PUBLIC BOOST_CHRONO_HEADER_ONLY)
40+
else()
41+
find_library(Boost_CHRONO_LIBRARY NAMES boost_chrono)
42+
if(Boost_CHRONO_LIBRARY)
43+
target_link_libraries(rmqio PUBLIC ${Boost_CHRONO_LIBRARY})
44+
endif()
45+
endif()
46+
3547
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro" )
3648
# _RWSTD_ALLOCATOR tells the solaris <memory> header to define a std::allocator
3749
# which conforms better to the C++ standard, which is expected by Boost. Without

src/rmq/rmqio/rmqio_asiotimer.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515

1616
#include <rmqio_asiotimer.h>
1717

18-
namespace {
19-
void instantiateTemplates()
20-
{
21-
// Instantiate the templates to ensure that they compile.
22-
BloombergLP::rmqio::AsioEventLoop eventLoop;
23-
BloombergLP::rmqio::AsioTimerFactory timerFactory(eventLoop);
24-
BloombergLP::rmqio::AsioTimer timer(eventLoop.context(),
25-
BloombergLP::bsls::TimeInterval(1));
26-
}
27-
} // namespace
18+
namespace BloombergLP {
19+
namespace rmqio {
20+
template class basic_AsioTimer<DefaultClockType>;
21+
template class basic_AsioTimerFactory<DefaultClockType>;
22+
} // namespace rmqio
23+
} // namespace BloombergLP

src/tests/integration/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if (NOT DEFINED ENV{PYTHON_BINARY})
1616
execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv ${CMAKE_CURRENT_BINARY_DIR}/.venv)
1717
set (ENV{VIRTUAL_ENV} ${CMAKE_CURRENT_BINARY_DIR}/.venv)
1818
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/.venv/bin/pip install -r ${CMAKE_CURRENT_LIST_DIR}/requirements.txt)
19+
if(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
20+
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/.venv/bin/pip install telnetlib3)
21+
endif()
1922
set(PYTHON_BINARY ${CMAKE_CURRENT_BINARY_DIR}/.venv/bin/python)
2023
else()
2124
set(PYTHON_BINARY $ENV{PYTHON_BINARY})
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
requests
22
pytest
3-
telnetlib3

src/tests/integration/rmqapitests/fixtures.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import requests
2020
from requests.auth import HTTPBasicAuth
2121
from typing import Any
22-
from telnetlib3 import Telnet
22+
try:
23+
from telnetlib import Telnet
24+
except ImportError:
25+
from telnetlib3 import Telnet
2326
from contextlib import contextmanager
2427
import logging
2528
import re

0 commit comments

Comments
 (0)