Skip to content

Commit

Permalink
fix: lanelet2_io and lanelet2_projection static link
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Nov 27, 2023
1 parent 31d3a91 commit 219e3de
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 23 deletions.
5 changes: 0 additions & 5 deletions lanelet2_core/src/BasicRegulatoryElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ RegulatoryElementDataPtr constructAllWayStopData(Id id, const AttributeMap& attr
}
} // namespace

static RegisterRegulatoryElement<TrafficLight> regTraffic;
static RegisterRegulatoryElement<RightOfWay> regRightOfWay;
static RegisterRegulatoryElement<TrafficSign> regTrafficSign;
static RegisterRegulatoryElement<SpeedLimit> regSpeedLimit;
static RegisterRegulatoryElement<AllWayStop> regAllWayStop;
#if __cplusplus < 201703L
constexpr char TrafficLight::RuleName[];
constexpr char RightOfWay::RuleName[];
Expand Down
6 changes: 6 additions & 0 deletions lanelet2_core/src/RegulatoryElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class ToConstVisitor : public RuleParameterVisitor {
} // namespace

static RegisterRegulatoryElement<GenericRegulatoryElement> genRegelem;
static RegisterRegulatoryElement<TrafficLight> regTraffic;
static RegisterRegulatoryElement<RightOfWay> regRightOfWay;
static RegisterRegulatoryElement<TrafficSign> regTrafficSign;
static RegisterRegulatoryElement<SpeedLimit> regSpeedLimit;
static RegisterRegulatoryElement<AllWayStop> regAllWayStop;

#if __cplusplus < 201703L
constexpr char GenericRegulatoryElement::RuleName[];

Expand Down
4 changes: 2 additions & 2 deletions lanelet2_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ if (NOT BUILD_TESTING STREQUAL OFF)
include(GoogleTest)
file(GLOB PROJECT_SOURCE_FILES_TEST "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp")
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_compile_definitions("${PROJECT_NAME}_test" PRIVATE -DPKG_DIR="${CMAKE_CURRENT_LIST_DIR}")
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

if (WIN32)
if (WIN32 AND BUILD_SHARED_LIBS)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
add_dependencies("${PROJECT_NAME}_test" lanelet2_maps)
endif ()
8 changes: 0 additions & 8 deletions lanelet2_io/src/BinHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
#include <fstream>

#include "lanelet2_io/Exceptions.h"
#include "lanelet2_io/io_handlers/Factory.h"
#include "lanelet2_io/io_handlers/Serialize.h"

namespace lanelet {
namespace io_handlers {

namespace {
// register with factories
RegisterParser<BinParser> regParser;
RegisterWriter<BinWriter> regWriter;

} // namespace

void BinWriter::write(const std::string& filename, const LaneletMap& laneletMap, ErrorMessages& /*errors*/,
const io::Configuration& /*params*/) const {
std::ofstream fs(filename, std::ofstream::binary);
Expand Down
8 changes: 8 additions & 0 deletions lanelet2_io/src/Factory.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#include "lanelet2_io/io_handlers/Factory.h"

#include "lanelet2_io/Exceptions.h"
#include "lanelet2_io/io_handlers/BinHandler.h"
#include "lanelet2_io/io_handlers/OsmHandler.h"

namespace lanelet {
namespace io_handlers {
namespace {
// register with factories
RegisterParser<BinParser> regBinParser;
RegisterWriter<BinWriter> regBinWriter;
RegisterParser<OsmParser> regOsmParser;
RegisterWriter<OsmWriter> regOsmWriter;

std::string format(const std::vector<std::string>& strings, const std::string& delim = ", ") {
std::string formatted;
for (const auto& str : strings) {
Expand Down
2 changes: 0 additions & 2 deletions lanelet2_io/src/OsmHandlerLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace io_handlers {
using Errors = std::vector<std::string>;

namespace {
// register with factories
RegisterParser<OsmParser> regParser;
using traits::to2D;
bool isValid(const LineStrings3d& lss) {
BasicPolygon2d ls(utils::concatenate(lss, [](const auto& elem) { return to2D(elem).basicLineString(); }));
Expand Down
3 changes: 0 additions & 3 deletions lanelet2_io/src/OsmHandlerWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ namespace io_handlers {

using Errors = std::vector<std::string>;
namespace {
// register with factories
RegisterWriter<OsmWriter> regWriter;

struct UnresolvedRole {
Id relationId{};
Id referencedRoleId{};
Expand Down
3 changes: 2 additions & 1 deletion lanelet2_io/test/TestBinHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <boost/archive/binary_oarchive.hpp>
#include <cstdio>
#include <fstream>
#include <string>

#include "TestSetup.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -115,7 +116,7 @@ TEST(BinHandler, explicitIO) { // NOLINT

TEST(BinHandler, fullMap) {
Origin origin({49, 8.4, 0});
std::string filenameIn = "../lanelet2_maps/res/mapping_example.osm";
std::string filenameIn = std::string(PKG_DIR) + "/../lanelet2_maps/res/mapping_example.osm";
auto map = lanelet::load(filenameIn, origin);
auto llt = map->laneletLayer.find(44968);
writeAndLoad(*llt);
Expand Down
2 changes: 1 addition & 1 deletion lanelet2_io/test/TestSimpleUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TEST(lanelet2_io, exampleUsage) { // NOLINT
using namespace lanelet;
Origin origin({49, 8.4, 0});
std::string filenameIn = "../lanelet2_maps/res/mapping_example.osm";
std::string filenameIn = std::string(PKG_DIR) + "/../lanelet2_maps/res/mapping_example.osm";
LaneletMapPtr laneletMap = lanelet::load(filenameIn, origin);

lanelet::test_setup::Tempfile file("file.osm");
Expand Down
2 changes: 1 addition & 1 deletion lanelet2_projection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (NOT BUILD_TESTING STREQUAL OFF)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

if (WIN32)
if (WIN32 AND BUILD_SHARED_LIBS)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
Expand Down

0 comments on commit 219e3de

Please sign in to comment.