Skip to content

Commit bc7c22f

Browse files
authored
Merge pull request #88 from christophfroehlich/ros2-boost
Make filters compile with MSVC
2 parents e47fe49 + 8d41d1b commit bc7c22f

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,30 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1111
endif()
1212
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
1313

14+
if(WIN32)
15+
add_compile_definitions(
16+
# For math constants
17+
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=vs-2019
18+
_USE_MATH_DEFINES
19+
# Minimize Windows namespace collision
20+
NOMINMAX
21+
WIN32_LEAN_AND_MEAN
22+
)
23+
# set the same behavior for windows as it is on linux
24+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
25+
endif()
26+
1427
##############################################################################
1528
# Find dependencies
1629
##############################################################################
1730

1831
find_package(ament_cmake REQUIRED)
1932
find_package(pluginlib REQUIRED)
2033
find_package(rclcpp REQUIRED)
34+
35+
if(WIN32 AND POLICY CMP0167)
36+
cmake_policy(SET CMP0167 NEW)
37+
endif()
2138
find_package(Boost QUIET COMPONENTS headers)
2239
if(NOT Boost_headers_FOUND)
2340
find_package(Boost REQUIRED)

include/filters/median.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ bool MedianFilter<T>::update(const T & data_in, T & data_out)
165165
for (size_t row = 0; row < length; ++row) {
166166
temp_storage_[row] = (*data_storage_)[row];
167167
}
168-
data_out = median(&temp_storage_[0], length);
168+
data_out = median(&temp_storage_[0], static_cast<int>(length));
169169

170170
return true;
171171
}

test/test_realtime_circular_buffer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
*/
2929

3030
#include <gtest/gtest.h>
31-
#include <sys/time.h>
3231

3332
#include <vector>
34-
#include <utility>
33+
3534
#include "filters/realtime_circular_buffer.hpp"
3635

3736
TEST(RealtimeCircularBuffer, InitializationScalar)

0 commit comments

Comments
 (0)