From f6708f5e51d90271a2a79931c5c25e0dcf8920fc Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 21 Nov 2023 12:52:34 +0000 Subject: [PATCH] feat: add lanelet2_matching --- CMakeLists.txt | 2 +- conanfile.py | 2 +- lanelet2_matching/CMakeLists.txt | 78 +++++++++++++------- lanelet2_matching/src/LaneletMatching.cpp | 4 +- lanelet2_matching/src/Utilities.cpp | 2 +- lanelet2_matching/test/lanelet2_matching.cpp | 2 +- 6 files changed, 58 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e79ca135..2ca54015 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,4 +23,4 @@ add_subdirectory(lanelet2_validation) #add_subdirectory(lanelet2_examples) #add_subdirectory(lanelet2_python) add_subdirectory(lanelet2_maps) -#add_subdirectory(lanelet2_matching) +add_subdirectory(lanelet2_matching) diff --git a/conanfile.py b/conanfile.py index 287e2ff7..12b61ecd 100644 --- a/conanfile.py +++ b/conanfile.py @@ -19,7 +19,7 @@ class Lanelet2Conan(ConanFile): proj_list = [ 'lanelet2_core', 'lanelet2_io', - # 'lanelet2_matching', + 'lanelet2_matching', 'lanelet2_projection', 'lanelet2_traffic_rules', 'lanelet2_routing', diff --git a/lanelet2_matching/CMakeLists.txt b/lanelet2_matching/CMakeLists.txt index 54c5dcee..8bf9ef14 100644 --- a/lanelet2_matching/CMakeLists.txt +++ b/lanelet2_matching/CMakeLists.txt @@ -1,4 +1,4 @@ -set(MRT_PKG_VERSION 4.0.0) +#set(MRT_PKG_VERSION 4.0.0) # Modify only if you know what you are doing! cmake_minimum_required(VERSION 3.5.1) project(lanelet2_matching) @@ -6,58 +6,67 @@ project(lanelet2_matching) ################### ## Find packages ## ################### -find_package(mrt_cmake_modules REQUIRED) -include(UseMrtStdCompilerFlags) -include(GatherDeps) +#find_package(mrt_cmake_modules REQUIRED) +#include(UseMrtStdCompilerFlags) +#include(GatherDeps) # You can add a custom.cmake in order to add special handling for this package. E.g. you can do: # list(REMOVE_ITEM DEPENDEND_PACKAGES ...) # To remove libs which cannot be found automatically. You can also "find_package" other, custom dependencies there. # You can also set PROJECT_INSTALL_FILES to install files that are not installed by default. -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") - include("${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") -endif() +#if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") +# include("${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") +#endif() -find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) +#find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) -mrt_parse_package_xml() +#mrt_parse_package_xml() ######################## ## Add python modules ## ######################## # This adds a python module if located under src/{PROJECT_NAME) -mrt_python_module_setup() +#mrt_python_module_setup() -mrt_glob_files(PROJECT_PYTHON_SOURCE_FILES_SRC "python_api/*.cpp") -if (PROJECT_PYTHON_SOURCE_FILES_SRC) - # Add a cpp-python api library. Make sure there are no name collisions with python modules in this project - mrt_add_python_api( ${PROJECT_NAME} - FILES ${PROJECT_PYTHON_SOURCE_FILES_SRC} - ) -endif() +#mrt_glob_files(PROJECT_PYTHON_SOURCE_FILES_SRC "python_api/*.cpp") +#if (PROJECT_PYTHON_SOURCE_FILES_SRC) +# Add a cpp-python api library. Make sure there are no name collisions with python modules in this project +# mrt_add_python_api( ${PROJECT_NAME} +# FILES ${PROJECT_PYTHON_SOURCE_FILES_SRC} +# ) +#endif() ############################ ## Read source code files ## ############################ -mrt_glob_files_recurse(PROJECT_HEADER_FILES_INC "include/*.h" "include/*.hpp" "include/*.cuh") -mrt_glob_files(PROJECT_SOURCE_FILES_INC "src/*.h" "src/*.hpp" "src/*.cuh") -mrt_glob_files(PROJECT_SOURCE_FILES_SRC "src/*.cpp" "src/*.cu") +#mrt_glob_files_recurse(PROJECT_HEADER_FILES_INC "include/*.h" "include/*.hpp" "include/*.cuh") +#mrt_glob_files(PROJECT_SOURCE_FILES_INC "src/*.h" "src/*.hpp" "src/*.cuh") +#mrt_glob_files(PROJECT_SOURCE_FILES_SRC "src/*.cpp" "src/*.cu") +file(GLOB PROJECT_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") ########### ## Build ## ########### # Declare a cpp library -mrt_add_library(${PROJECT_NAME} - INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC} - SOURCES ${PROJECT_SOURCE_FILES_SRC} - ) +#mrt_add_library(${PROJECT_NAME} +# INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC} +# SOURCES ${PROJECT_SOURCE_FILES_SRC} +# ) +add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE_FILES_SRC}) +target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_io lanelet2_projection lanelet2_traffic_rules) + ############# ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). # This command also exports libraries and config files for dependent packages and this supersedes catkin_package. -mrt_install(PROGRAMS scripts FILES res data ${PROJECT_INSTALL_FILES}) +#mrt_install(PROGRAMS scripts FILES res data ${PROJECT_INSTALL_FILES}) +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${PROJECT_INSTALL_FILES} + LIBRARY DESTINATION ${PROJECT_INSTALL_FILES} + RUNTIME DESTINATION ${PROJECT_INSTALL_FILES}) ############# ## Testing ## @@ -66,4 +75,21 @@ mrt_install(PROGRAMS scripts FILES res data ${PROJECT_INSTALL_FILES}) if (CATKIN_ENABLE_TESTING) mrt_add_tests(test) mrt_add_nosetests(test) -endif() +endif () + +if (LANELET2_ENABLE_TESTING) + include(GoogleTest) + find_package(GTest REQUIRED) + file(GLOB PROJECT_SOURCE_FILES_TEST "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp") + add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST}) + target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME}) + + add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") + + gtest_discover_tests("${PROJECT_NAME}_test") + # add_dependencies("${PROJECT_NAME}_test" lanelet2_maps) +endif () \ No newline at end of file diff --git a/lanelet2_matching/src/LaneletMatching.cpp b/lanelet2_matching/src/LaneletMatching.cpp index d39b4c42..54c5a404 100644 --- a/lanelet2_matching/src/LaneletMatching.cpp +++ b/lanelet2_matching/src/LaneletMatching.cpp @@ -28,12 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "LaneletMatching.h" +#include "lanelet2_matching/LaneletMatching.h" #include #include -#include "Utilities.h" +#include "lanelet2_matching/Utilities.h" namespace { template diff --git a/lanelet2_matching/src/Utilities.cpp b/lanelet2_matching/src/Utilities.cpp index 6e615435..0dec70fa 100644 --- a/lanelet2_matching/src/Utilities.cpp +++ b/lanelet2_matching/src/Utilities.cpp @@ -28,7 +28,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Utilities.h" +#include "lanelet2_matching/Utilities.h" #include #include diff --git a/lanelet2_matching/test/lanelet2_matching.cpp b/lanelet2_matching/test/lanelet2_matching.cpp index c47194e8..a00a7d84 100644 --- a/lanelet2_matching/test/lanelet2_matching.cpp +++ b/lanelet2_matching/test/lanelet2_matching.cpp @@ -33,8 +33,8 @@ #include #include -#include "LaneletMatching.h" #include "gtest/gtest.h" +#include "lanelet2_matching/LaneletMatching.h" using namespace lanelet;