Skip to content

Commit e6826ad

Browse files
committed
ported mrpt_expr
1 parent 2eff91a commit e6826ad

File tree

8 files changed

+87
-59
lines changed

8 files changed

+87
-59
lines changed

cmakemodules/DeclareMRPTLib.cmake

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ function(mrpt_lib_target_requires_cpp17 _TARGET)
2020
target_compile_features(${_TARGET} ${INTERF_TYPE} cxx_std_17)
2121
endfunction()
2222

23-
# Minimize the time and memory required to build and load debug info:
24-
#-----------------------------------------------------------------------
25-
function(mrpt_reduced_debug_symbols TARGET_)
26-
get_property(CUR_FLAGS_ TARGET ${TARGET_} PROPERTY COMPILE_OPTIONS)
27-
set(cxxflags_ "$ENV{CXXFLAGS}")
28-
separate_arguments(cxxflags_)
29-
if (("-g" IN_LIST CUR_FLAGS_) OR ("-g" IN_LIST cxxflags_))
30-
if (MRPT_COMPILER_IS_GCC)
31-
target_compile_options(${TARGET_} PRIVATE -g1)
32-
elseif(MRPT_COMPILER_IS_CLANG)
33-
target_compile_options(${TARGET_} PRIVATE -gline-tables-only)
34-
endif()
35-
endif()
36-
endfunction()
3723

3824
# handle_special_simd_flags(): Add custom flags to a set of source files
3925
# Only for Intel-compatible archs

modules/mrpt_common/cmake/mrpt_cmake_functions.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,18 @@ macro(mrpt_version_to_hexadecimal OUT_VAR IN_VERSION)
664664
(${VERSION_NUMBER_MINOR} << 8) + \
665665
(${VERSION_NUMBER_PATCH})" OUTPUT_FORMAT HEXADECIMAL )
666666
endmacro()
667+
668+
# Minimize the time and memory required to build and load debug info:
669+
#-----------------------------------------------------------------------
670+
function(mrpt_reduced_debug_symbols TARGET_)
671+
get_property(CUR_FLAGS_ TARGET ${TARGET_} PROPERTY COMPILE_OPTIONS)
672+
set(cxxflags_ "$ENV{CXXFLAGS}")
673+
separate_arguments(cxxflags_)
674+
if (("-g" IN_LIST CUR_FLAGS_) OR ("-g" IN_LIST cxxflags_))
675+
if (MRPT_COMPILER_IS_GCC)
676+
target_compile_options(${TARGET_} PRIVATE -g1)
677+
elseif(MRPT_COMPILER_IS_CLANG)
678+
target_compile_options(${TARGET_} PRIVATE -gline-tables-only)
679+
endif()
680+
endif()
681+
endfunction()

modules/mrpt_expr/CMakeLists.txt

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1-
# See "DeclareMRPTLib.cmake"
1+
# ------------------------------------------------------------------------------
2+
# Mobile Robot Programming Toolkit (MRPT)
3+
#
4+
# Copyright (c) 2005-2025, Jose Luis Blanco-Claraco, contributors (see Git history)
5+
# All rights reserved.
6+
# Released under BSD-3 license. See LICENSE file
7+
# ------------------------------------------------------------------------------
8+
cmake_minimum_required(VERSION 3.16)
29

3-
list(APPEND expr_EXTRA_SRCS "${MRPT_LIBS_ROOT}/expr/*.cpp" "${MRPT_LIBS_ROOT}/expr/*.h")
4-
list(APPEND expr_EXTRA_SRCS_NAME "expr" "expr")
10+
# Tell CMake we'll use C++ for use in its tests/flags
11+
project(mrpt_expr LANGUAGES C CXX)
512

6-
define_mrpt_lib(
7-
expr # Lib name
8-
# Dependencies:
9-
mrpt-system
10-
)
13+
# MRPT CMake scripts: "mrpt_xxx()"
14+
find_package(mrpt_common REQUIRED)
15+
find_package(mrpt_system REQUIRED)
1116

12-
if(BUILD_mrpt-expr)
13-
# Don't export ALL symbols for the huge exprtk lib
14-
set_target_properties(expr PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 0)
17+
# define lib:
18+
set(LIB_SRCS
19+
src/CRuntimeCompiledExpression.cpp
20+
src/CRuntimeCompiledExpression_unittest.cpp
21+
)
1522

16-
# Minimize debug info for this module:
17-
mrpt_reduced_debug_symbols(expr)
18-
endif()
23+
set(LIB_PUBLIC_HDRS
24+
include/mrpt/3rdparty/exprtk.hpp
25+
include/mrpt/expr/mrpt-expr_export.h
26+
include/mrpt/expr/CRuntimeCompiledExpression.h
27+
)
28+
29+
mrpt_add_library(
30+
TARGET ${PROJECT_NAME}
31+
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
32+
PUBLIC_LINK_LIBRARIES
33+
mrpt::mrpt_system
34+
# PRIVATE_LINK_LIBRARIES
35+
CMAKE_DEPENDENCIES
36+
mrpt_system
37+
)
38+
39+
# Don't export ALL symbols for the huge exprtk lib
40+
set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 0)
41+
# Minimize debug info for this module:
42+
mrpt_reduced_debug_symbols(${PROJECT_NAME})

modules/mrpt_expr/package.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<!-- This is a ROS package file, intended to allow this library to be built
4+
side-by-side to ROS packages in a catkin/ament environment.
5+
-->
6+
<package format="3">
7+
<name>mrpt_expr</name>
8+
<version>2.20.0</version>
9+
<description>The MRPT C++ library mrpt_expr</description>
10+
11+
<maintainer email="[email protected]">Jose-Luis Blanco-Claraco</maintainer>
12+
<license file="LICENSE">BSD</license>
13+
14+
<url type="website">https://github.com/MRPT/</url>
15+
16+
<!-- BUILD TOOLS -->
17+
<buildtool_depend>cmake</buildtool_depend>
18+
19+
<depend>mrpt_common</depend>
20+
<depend>mrpt_system</depend>
21+
22+
<export>
23+
<build_type>cmake</build_type>
24+
</export>
25+
26+
</package>

modules/mrpt_expr/src/CRuntimeCompiledExpression.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
| Released under BSD License. See: https://www.mrpt.org/License |
88
+------------------------------------------------------------------------+ */
99

10-
#include "expr-precomp.h" // Precompiled headers
11-
//
1210
#include <mrpt/core/exceptions.h>
1311
#include <mrpt/expr/CRuntimeCompiledExpression.h>
1412
#include <mrpt/system/string_utils.h>

modules/mrpt_expr/src/expr-precomp.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

modules/mrpt_expr/src/expr-precomp.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

modules/mrpt_system/src/datetime.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040

4141
#include <cmath> // floor()
4242
#include <ctime>
43-
#include <iostream> // for the << operator
4443

4544
using namespace mrpt;
4645
using namespace mrpt::system;
4746
using namespace std;
4847

48+
constexpr auto EPOCH_OFFSET = static_cast<uint64_t>(116444736) * 1000000000;
49+
4950
// Required to ensure INVALID_TIMESTAMP returns a "const T&":
5051
const TTimeStamp& mrpt::system::InvalidTimeStamp()
5152
{
@@ -222,7 +223,7 @@ string mrpt::system::dateTimeToString(const mrpt::system::TTimeStamp t)
222223
return string("INVALID_TIMESTAMP");
223224
}
224225

225-
uint64_t tmp = (t.time_since_epoch().count() - ((uint64_t)116444736 * 1000000000));
226+
uint64_t tmp = (t.time_since_epoch().count() - EPOCH_OFFSET);
226227
time_t auxTime = tmp / (uint64_t)10000000;
227228
auto secFractions = calcSecFractions(tmp);
228229
tm* ptm = gmtime(&auxTime);
@@ -248,7 +249,7 @@ string mrpt::system::dateTimeLocalToString(const mrpt::system::TTimeStamp t)
248249
return string("INVALID_TIMESTAMP");
249250
}
250251

251-
uint64_t tmp = (t.time_since_epoch().count() - ((uint64_t)116444736 * 1000000000));
252+
uint64_t tmp = (t.time_since_epoch().count() - EPOCH_OFFSET);
252253
time_t auxTime = tmp / (uint64_t)10000000;
253254
auto secFractions = calcSecFractions(tmp);
254255

@@ -283,7 +284,7 @@ double mrpt::system::extractDayTimeFromTimestamp(const mrpt::system::TTimeStamp
283284
FileTimeToSystemTime((FILETIME*)&t, &sysT);
284285
return sysT.wHour * 3600.0 + sysT.wMinute * 60.0 + sysT.wSecond + sysT.wMilliseconds * 0.001;
285286
#else
286-
time_t auxTime = (t - ((uint64_t)116444736 * 1000000000)) / (uint64_t)10000000;
287+
time_t auxTime = (t - EPOCH_OFFSET) / (uint64_t)10000000;
287288
tm* ptm = gmtime(&auxTime);
288289
ASSERTMSG_(ptm, "Malformed timestamp");
289290
return ptm->tm_hour * 3600.0 + ptm->tm_min * 60.0 + ptm->tm_sec;
@@ -303,7 +304,7 @@ string mrpt::system::timeLocalToString(
303304
}
304305
auto t = tt.time_since_epoch().count();
305306

306-
uint64_t tmp = (t - ((uint64_t)116444736 * 1000000000));
307+
uint64_t tmp = (t - EPOCH_OFFSET);
307308
const time_t auxTime = tmp / (uint64_t)10000000;
308309

309310
#if !defined(HAVE_LOCALTIME_R)
@@ -337,7 +338,7 @@ string mrpt::system::timeToString(const mrpt::system::TTimeStamp tt)
337338
}
338339
auto t = tt.time_since_epoch().count();
339340

340-
uint64_t tmp = (t - ((uint64_t)116444736 * 1000000000));
341+
uint64_t tmp = (t - EPOCH_OFFSET);
341342
time_t auxTime = tmp / (uint64_t)10000000;
342343
auto secFractions = calcSecFractions(tmp);
343344
tm* ptm = gmtime(&auxTime);
@@ -361,7 +362,7 @@ string mrpt::system::dateToString(const mrpt::system::TTimeStamp tt)
361362
}
362363
auto t = tt.time_since_epoch().count();
363364

364-
uint64_t tmp = (t - ((uint64_t)116444736 * 1000000000));
365+
uint64_t tmp = (t - EPOCH_OFFSET);
365366
time_t auxTime = tmp / (uint64_t)10000000;
366367
tm* ptm = gmtime(&auxTime);
367368
if (!ptm)

0 commit comments

Comments
 (0)